Class BaseSynchroComponent

    • Method Detail

      • 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,
                                    org.slf4j.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,
                                    org.slf4j.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,​BooleanapplyChanges​(ModifiableDefaultContent content,
                                                      Integer actionId,
                                                      String event,
                                                      org.slf4j.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,​BooleanapplyChanges​(ModifiableDefaultContent content,
                                                      Integer actionId,
                                                      String event,
                                                      boolean ignoreRights,
                                                      org.slf4j.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
      • createContentAction

        public Map<String,​ObjectcreateContentAction​(String contentType,
                                                            String workflowName,
                                                            int initialActionId,
                                                            String lang,
                                                            String contentTitle,
                                                            String contentPrefix,
                                                            org.slf4j.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.
      • _getContentName

        private String _getContentName​(String title,
                                       String lang,
                                       String prefix)
        Gets the content name
        Parameters:
        title - The name
        lang - The lang of the content
        prefix - The prefix to put before the title
        Returns:
        The content name
      • synchronizeMetadata

        public Map<String,​BooleansynchronizeMetadata​(ModifiableDefaultContent content,
                                                             ContentType contentType,
                                                             String logicalMetadataPath,
                                                             String completeMetadataPath,
                                                             List<Object> remoteValue,
                                                             boolean synchronize,
                                                             boolean create,
                                                             org.slf4j.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,​BooleansynchronizeMetadata​(ModifiableDefaultContent content,
                                                             ContentType contentType,
                                                             String logicalMetadataPath,
                                                             ModifiableCompositeMetadata metadataHolder,
                                                             String metadataName,
                                                             List<Object> remoteValue,
                                                             boolean synchronize,
                                                             boolean create,
                                                             org.slf4j.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.
      • _setRichTextMetadata

        private boolean _setRichTextMetadata​(ModifiableCompositeMetadata metadataHolder,
                                             String metadataName,
                                             Object valueToSet,
                                             boolean synchronize,
                                             String title,
                                             org.slf4j.Logger logger)
        Set the richtext 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
      • _setBinaryMetadata

        protected boolean _setBinaryMetadata​(ModifiableCompositeMetadata metadataHolder,
                                             String metadataName,
                                             Object valueToSet,
                                             boolean synchronize,
                                             String title,
                                             org.slf4j.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
      • _getBytesFromValue

        private byte[] _getBytesFromValue​(Object valueToSet)
                                   throws IOException
        Get the bytes array from the value to set
        Parameters:
        valueToSet - the value to set
        Returns:
        the bytes array
        Throws:
        IOException - if an error occurred
      • _getLinesFromValue

        private String[] _getLinesFromValue​(Object valueToSet)
                                     throws IOException
        Get the lines array from valueToSet for the richText
        Parameters:
        valueToSet - the value to set
        Returns:
        the lines array
        Throws:
        IOException - if an error occurred
      • _toTypedArray

        private static <T> T[] _toTypedArray​(Class<?> classToCastTo,
                                             List<Object> list)
        This method have been build to go through the CONTENTIO-95 problem. The toArray() method returns an Object[] and it's not supported by ExternalizableMetadataHelper methods.
        Type Parameters:
        T - The type of the array
        Parameters:
        classToCastTo - The class to cast to
        list - The list to transform to an array
        Returns:
        A typed array.