Class ResourceUtils

java.lang.Object
com.vdoc.sdk.commons.utils.ResourceUtils

public class ResourceUtils extends Object
Resource utility class
Author:
wtoscer
  • Method Details

    • removeAttachment

      public static void removeAttachment(IWorkflowModule workflowModule, IResource resource, String fieldName, String fileName) throws WorkflowModuleException
      Remove an IAttachment for an IResource
      Parameters:
      workflowModule - the module
      resource - the IResource from which we want to remove an IAttachment
      fieldName - the name of the field where the IAttachment is stocked
      fileName - the name of the IAttachment
      Throws:
      WorkflowModuleException - on error
    • copyAttachement

      @Deprecated public static void copyAttachement(IWorkflowModule workflowModule, IResource targetResource, String targetPropertyName, Collection<? extends IAttachment> attachementCollection) throws WorkflowModuleException
      Deprecated.
      use copyAttachment instead
      Copy attachement
      Parameters:
      workflowModule - the module
      targetResource - the target resource
      targetPropertyName - the target property name
      attachementCollection - the attachements
      Throws:
      WorkflowModuleException - on error
    • copyAttachment

      public static void copyAttachment(IWorkflowModule workflowModule, IResource targetResource, String targetPropertyName, Collection<? extends IAttachment> attachementCollection) throws WorkflowModuleException
      Parameters:
      workflowModule - the module
      targetResource - the IResource where we want to copy
      targetPropertyName - the name of the property of the IResource
      attachementCollection - the Collection of IAttachment we want to copy
      Throws:
      WorkflowModuleException - on error
    • copyAttachment

      public static void copyAttachment(IWorkflowModule workflowModule, IResource sourceResource, IResource targetResource, String sourcePropertyName, String targetPropertyName, boolean withReplacement) throws WorkflowModuleException
      copy an file property to another file property. This will duplicate file for safe delete.
      Parameters:
      workflowModule - the resource workflow module
      sourceResource - the source resource
      targetResource - the target resource (can be the same as source)
      sourcePropertyName - the source property
      targetPropertyName - the target property
      withReplacement - if true the target is clean before copy
      Throws:
      WorkflowModuleException - on error
    • copyResource

      public static void copyResource(IWorkflowModule workflowModule, IContext context, IResource sourceResource, IResource targetResource, List<String> propertiesName, Boolean exclude) throws WorkflowModuleException
      Copy the values from the source resource to the target resource
      You can exclude some properties by passing ArrayList propertiesName and the Boolean exclude to true
      You can choose the properties you want to copy by passing ArrayList propertiesName and the Boolean exclude to false
      Parameters:
      workflowModule - the resource workflow module
      context - the user context
      sourceResource - source resource
      targetResource - target resource to copy properties values
      propertiesName - properties to exclude if exclude == true, properties to copy if exclude == false
      exclude - fields to excludeif true / include if false
      Throws:
      WorkflowModuleException - on error
    • copyProperty

      public static void copyProperty(PropertyCopyConfiguration configuration, Boolean ignoreError) throws WorkflowModuleException
      Copy property
      Parameters:
      configuration - the configuration
      ignoreError - true to ignore error
      Throws:
      WorkflowModuleException - on error
    • copyResource

      public static void copyResource(IWorkflowModule workflowModule, IContext context, IResource sourceResource, IResource targetResource, List<String> propertiesName) throws WorkflowModuleException
      Copy the values from the source resource to the target resource.
      You can specify the properties you want to copy by setting the ArrayListinvalid input: '<'String> propertiesName.
      Parameters:
      workflowModule - the workflow module.
      context - the user context.
      sourceResource - source resource to copy properties values from.
      targetResource - target resource to copy properties values to.
      propertiesName - all the properties to copy.
      Throws:
      WorkflowModuleException - on error
    • copyResource

      public static void copyResource(IWorkflowModule workflowModule, IContext context, IResource sourceResource, IResource targetResource, Map<String,String> propertiesMapping) throws WorkflowModuleException
      Copy values from a resource to another by specifying a properties mapping.
      Parameters:
      workflowModule - the workflow module.
      context - the user context.
      sourceResource - source resource to copy properties values from.
      targetResource - target resource to copy properties values to.
      propertiesMapping - a Mapinvalid input: '<'String,String>
      Throws:
      WorkflowModuleException - on error
    • cloneResource

      public static IResource cloneResource(IWorkflowModule workflowModule, IContext context, IResource resource, List<String> propertiesName, Boolean exclude) throws WorkflowModuleException
      Clone a IStorageResource or a IWorkflowInstance
      You can exclude some properties by passing ArrayList propertiesName and set the Boolean exclude argument to Boolean.TRUE.
      You can choose the properties you want to copy by passing ArrayList propertiesName and the Boolean exclude to false
      Parameters:
      workflowModule - the resource workflow module
      context - the user context
      resource - resource to clone
      propertiesName - properties to exclude if exclude == true, properties to copy if exclude == false
      exclude - fields to exclude if true / include if false
      Returns:
      the cloned resource
      Throws:
      WorkflowModuleException - on error
    • cloneLinkedResource

      public static ILinkedResource cloneLinkedResource(IWorkflowModule workflowModule, IContext context, ILinkedResource linkedResource, String parentField, List<String> propertiesName, Boolean exclude) throws WorkflowModuleException
      Clone a ILinkedResource
      You can exclude some properties by passing List propertiesName and the Boolean exclude to true
      You can choose the properties you want to copy by passing List propertiesName and the Boolean exclude to false
      Parameters:
      workflowModule - the resource workflow module
      context - the user context
      linkedResource - resource to clone
      parentField - the field in which the linked Resource is
      propertiesName - properties to exclude if exclude == true, properties to copy if exclude == false
      exclude - fields to exclude if true / include if false
      Returns:
      the cloned resource
      Throws:
      WorkflowModuleException - on error
    • cloneLinkedResource

      public static ILinkedResource cloneLinkedResource(IWorkflowModule workflowModule, IContext context, IWorkflowInstance destinationWorkflowInstance, ILinkedResource linkedResource, String parentField, List<String> propertiesName, Boolean exclude) throws WorkflowModuleException
      Clone a ILinkedResource
      You can exclude some properties by passing ArrayList propertiesName and the Boolean exclude to true
      You can choose the properties you want to copy by passing ArrayList propertiesName and the Boolean exclude to false
      Parameters:
      workflowModule - the resource workflow module
      context - the user context
      destinationWorkflowInstance - the workflowInstance where to copy the linkedresource
      linkedResource - resource to clone
      parentField - the field in which the linked Resource is
      propertiesName - properties to exclude if exclude == true, properties to copy if exclude == false
      exclude - fields to exclude if true / include if false
      Returns:
      the cloned resource
      Throws:
      WorkflowModuleException - on error
    • cloneResource

      public static IResource cloneResource(IWorkflowModule workflowModule, IContext context, IResource resource) throws WorkflowModuleException
      Clone a IResource
      Parameters:
      workflowModule - the resource workflow module
      context - the user context
      resource - resource to clone
      Returns:
      the cloned resource
      Throws:
      WorkflowModuleException - on error
    • cloneLinkedResource

      public static IResource cloneLinkedResource(IWorkflowModule workflowModule, IContext context, ILinkedResource linkedResource, String parentField) throws WorkflowModuleException
      Parameters:
      workflowModule - the resource workflow module
      context - the user context
      linkedResource - resource to clone
      parentField - the parent field
      Returns:
      the cloned resource
      Throws:
      WorkflowModuleException - on error
    • cloneLinkedResource

      public static IResource cloneLinkedResource(IWorkflowModule workflowModule, IContext context, IWorkflowInstance destinationWorkflowInstance, ILinkedResource linkedResource, String parentField) throws WorkflowModuleException
      Parameters:
      workflowModule - the resource workflow module
      context - the user context
      destinationWorkflowInstance - the workflowInstance where to copy the linkedresource
      linkedResource - resource to clone
      parentField - the parent field
      Returns:
      the cloned resource
      Throws:
      WorkflowModuleException - on error