Class BaseSynchroComponent

java.lang.Object
org.ametys.plugins.contentio.synchronize.BaseSynchroComponent
All Implemented Interfaces:
Component, Serviceable

public class BaseSynchroComponent extends Object implements Serviceable, Component
Class for basics operations on SCC.
  • Field Details

  • Constructor Details

  • Method Details

    • service

      public void service(ServiceManager manager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • removeMetadataIfExists

      public boolean removeMetadataIfExists(ModifiableCompositeMetadata metadataHolder, String metadataName, boolean synchronize)
      Remove the metadata if exists
      Parameters:
      metadataHolder - The metadata holder
      metadataName - The name of the metadata
      synchronize - true if the data is synchronize
      Returns:
      true if the metadata have been removed
    • validateContent

      public void validateContent(WorkflowAwareContent content, int validationActionId, Logger logger)
      Validates a content after import
      Parameters:
      content - The content to validate
      validationActionId - Validation action ID to use for this content
      logger - The logger
    • validateContent

      public void validateContent(WorkflowAwareContent content, int validationActionId, boolean ignoreRights, Logger logger)
      Validates a content after import
      Parameters:
      content - The content to validate
      validationActionId - Validation action ID to use for this content
      ignoreRights - true if checking rights needs to be ignored
      logger - The logger
    • applyChanges

      public Map<String,Boolean> applyChanges(ModifiableDefaultContent content, Integer actionId, String event, Logger logger) throws RepositoryException
      Does workflow action
      Parameters:
      content - The synchronized content
      actionId - Workflow action
      event - Type of event
      logger - The logger
      Returns:
      A Map with one or two Boolean, "success" tells if the operation have been done successfully, "error" tells if an error occurs during the content saving. The save can be successful but an error can occurs during the workflow update.
      Throws:
      RepositoryException - if an error occurs when trying to rollback pending changes in the repository.
    • applyChanges

      public Map<String,Boolean> applyChanges(ModifiableDefaultContent content, Integer actionId, String event, boolean ignoreRights, Logger logger) throws RepositoryException
      Does workflow action
      Parameters:
      content - The synchronized content
      actionId - Workflow action
      event - Type of event
      ignoreRights - true if checking rights needs to be ignored
      logger - The logger
      Returns:
      A Map with one or two Boolean, "success" tells if the operation have been done successfully, "error" tells if an error occurs during the content saving. The save can be successful but an error can occurs during the workflow update.
      Throws:
      RepositoryException - if an error occurs when trying to rollback pending changes in the repository.
    • updateRelation

      public boolean updateRelation(ModifiableCompositeMetadata metadataToEdit, String metadataName, Content content, boolean remove)
      Update the invert relation by adding/removing the content to/from the old values.
      Parameters:
      metadataToEdit - Metadata holder to edit
      metadataName - Metadata name to set
      content - The content to add or remove
      remove - true if we wan't to remove the content from the relation
      Returns:
      true if there are changes
    • updateRelation

      public boolean updateRelation(ModifiableCompositeMetadata metadataToEdit, String metadataName, String contentId, boolean remove)
      Update the invert relation by adding/removing the content to/from the old values.
      Parameters:
      metadataToEdit - Metadata holder to edit
      metadataName - Metadata name to set
      contentId - The content to add or remove
      remove - true if we wan't to remove the content from the relation
      Returns:
      true if there are changes
    • updateSCCProperty

      public void updateSCCProperty(DefaultContent content, String collectionId) throws RepositoryException
      Add the current synchronizable collection as property
      Parameters:
      content - The synchronized content
      collectionId - The ID of the collection
      Throws:
      RepositoryException - if an error occurred
    • createContentAction

      public Map<String,Object> createContentAction(String contentType, String workflowName, int initialActionId, String lang, String contentTitle, String contentPrefix, Logger logger)
      Creates content action with result from request
      Parameters:
      contentType - Type of the content to create
      workflowName - Workflow to use for this content
      initialActionId - Action ID for initialization
      lang - The language
      contentTitle - The content title
      contentPrefix - The content prefix for the node creation
      logger - The logger
      Returns:
      A Map with the created content in "content", and a Boolean in "error" if an error occurs.
    • synchronizeMetadata

      public Map<String,Boolean> synchronizeMetadata(ModifiableDefaultContent content, ContentType contentType, String logicalMetadataPath, String completeMetadataPath, List<Object> remoteValue, boolean synchronize, boolean create, Logger logger)
      Fill the metadata with remove value.
      Parameters:
      content - The content to synchronize
      contentType - The content type
      logicalMetadataPath - The logical metadata path without the entries
      completeMetadataPath - The complete metadata path from the root of the content
      remoteValue - The remote value
      synchronize - true if synchronizable
      create - true if content is creating, false if it is updated
      logger - The logger
      Returns:
      A Map with a Boolean in "hasChanges" value if changes has been made, and a Boolean in "error" value if an error occurs.
    • synchronizeMetadata

      public Map<String,Boolean> synchronizeMetadata(ModifiableDefaultContent content, ContentType contentType, String logicalMetadataPath, ModifiableCompositeMetadata metadataHolder, String metadataName, List<Object> remoteValue, boolean synchronize, boolean create, Logger logger)
      Fill the metadata with remote value.
      Parameters:
      content - The content to synchronize
      contentType - The content type
      logicalMetadataPath - The logical metadata path without the entries
      metadataHolder - the metadata holder of the content to synchronize
      metadataName - the name of the metadata
      remoteValue - The remote value
      synchronize - true if synchronizable
      create - true if content is creating, false if it is updated
      logger - The logger
      Returns:
      A Map with a Boolean in "hasChanges" value if changes has been made, and a Boolean in "error" value if an error occurs.
    • _setBinaryMetadata

      protected boolean _setBinaryMetadata(ModifiableCompositeMetadata metadataHolder, String metadataName, Object valueToSet, boolean synchronize, String title, Logger logger)
      Set the binary metadata
      Parameters:
      metadataHolder - the metadata holder
      metadataName - the metadata name
      valueToSet - the value to set
      synchronize - true if the metadata is synchronize
      title - the content title
      logger - the logger
      Returns:
      true if changes were made
    • getMetadataHolder

      Get the metadata holder for the requested metadata path.
      Parameters:
      parentMetadata - Initial metadata
      metadataPath - Metadata path from the parent
      Returns:
      A metadata holder