Class AbstractContentEximService

java.lang.Object
org.onehippo.forge.content.exim.repository.jaxrs.AbstractContentEximService
Direct Known Subclasses:
ContentEximExportService, ContentEximImportService, ContentEximProcessStatusService

public abstract class AbstractContentEximService extends Object
AbstractContentEximService.
  • Field Details

    • SYSTEM_CREDENTIALS

      protected static final Credentials SYSTEM_CREDENTIALS
      System session credentials.
    • TEMP_PREFIX

      protected static final String TEMP_PREFIX
      Prefix of the temporary folder or files. e.g, temporary folder in zip content creation.
      See Also:
    • EXIM_EXECUTION_LOG_REL_PATH

      protected static final String EXIM_EXECUTION_LOG_REL_PATH
      The whole execution log file entry name.
      See Also:
    • EXIM_SUMMARY_BINARIES_LOG_REL_PATH

      protected static final String EXIM_SUMMARY_BINARIES_LOG_REL_PATH
      Zip Entry name of the summary log for binaries.
      See Also:
    • EXIM_SUMMARY_DOCUMENTS_LOG_REL_PATH

      protected static final String EXIM_SUMMARY_DOCUMENTS_LOG_REL_PATH
      Zip Entry name of the summary log for documents.
      See Also:
    • BINARY_ATTACHMENT_REL_PATH

      protected static final String BINARY_ATTACHMENT_REL_PATH
      Zip Entry name prefix for the binary attachments.
      See Also:
    • STOP_REQUEST_FILE_REL_PATH

      protected static final String STOP_REQUEST_FILE_REL_PATH
      Stop signal file's relative path under the zip creating base folder. If this file is found in the process, the export or import process will stop right away.
      See Also:
  • Constructor Details

    • AbstractContentEximService

      public AbstractContentEximService()
      Default constructor.
  • Method Details

    • setProcessMonitor

      protected void setProcessMonitor(org.onehippo.forge.content.exim.repository.jaxrs.ProcessMonitor processMonitor)
    • getProcessMonitor

      protected org.onehippo.forge.content.exim.repository.jaxrs.ProcessMonitor getProcessMonitor()
    • getObjectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
      Return the default Jackson ObjectMapper instance.
      Returns:
      ObjectMapper instance
    • getDaemonSession

      protected Session getDaemonSession()
      Return the JCR session given by the DaemonModule. It is not supposed to use this JCR session directly to retrieve or manipulate content. You should use createSession() for that purpose instead.
      Returns:
      the JCR session given by the DaemonModule
    • setDaemonSession

      protected void setDaemonSession(Session daemonSession)
      Set the JCR session, supposed to be set by the DaemonModule.
      Parameters:
      daemonSession - the JCR session given by the DaemonModule
    • createSession

      protected Session createSession() throws LoginException, RepositoryException
      Create a new JCR system session by impersonating the JCR session returned from getDaemonSession().
      Returns:
      a new JCR system session by impersonating the JCR session returned from getDaemonSession()
      Throws:
      LoginException - if impersonation with system credentials fails
      RepositoryException - if repository exception occurs
    • isStopRequested

      protected boolean isStopRequested(org.apache.commons.vfs2.FileObject baseFolder)
      Return true if a stop signal file is found under the base folder.
      Parameters:
      baseFolder - the base folder where zip content files are created temporarily.
      Returns:
      true if a stop signal file is found under the base folder
    • toJsonString

      protected String toJsonString(Object object) throws com.fasterxml.jackson.core.JsonProcessingException
      Return a JSON string by stringifying the object with the Jackson ObjectMapper.
      Parameters:
      object - object to stringify
      Returns:
      a JSON string by stringifying the object with the Jackson ObjectMapper
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException - if JSON stringifying fails
    • attachmentToString

      protected String attachmentToString(org.apache.cxf.jaxrs.ext.multipart.Attachment attachment, String charsetName) throws IOException
      Read the CXF attachment JAX-RS argument and convert it to a string.
      Parameters:
      attachment - CXF attachment JAX-RS argument
      charsetName - charset name used in encoding
      Returns:
      string converted from the CXF attachment JAX-RS argument
      Throws:
      IOException - if IO exception occurs
    • transferAttachmentToFile

      protected void transferAttachmentToFile(org.apache.cxf.jaxrs.ext.multipart.Attachment attachment, File file) throws IOException
      Transfer attachment content into the given file.
      Parameters:
      attachment - attachment
      file - destination file
      Throws:
      IOException - if IO exception occurs
    • recordToResultItem

      protected ResultItem recordToResultItem(ContentMigrationRecord record)
      Convert the ContentMigrationRecord instance to a ResultItem instance.
      Parameters:
      record - a ContentMigrationRecord instance
      Returns:
      a converted ResultItem instance
    • getQueriedNodePaths

      protected Set<String> getQueriedNodePaths(Session session, String statement, String language) throws RepositoryException
      Executes JCR query using the query statement in the query language and collect all the result node paths in a set to return.
      Parameters:
      session - JCR session
      statement - JCR query statement
      language - JCR query language
      Returns:
      a set containing all the nodes from the query result
      Throws:
      RepositoryException - if repository exception occurs
    • overrideExecutionParamsByParameters

      protected void overrideExecutionParamsByParameters(ExecutionParams params, String batchSizeParam, String throttleParam, String publishOnImportParam, String dataUrlSizeThresholdParam, String docbasePropNamesParam, String documentTagsParam, String binaryTagsParam)
      Override params by the give request parameter values.
      Parameters:
      params - ExecutionParams instance
      batchSizeParam - batch size request parameter value
      throttleParam - throttle request parameter value
      publishOnImportParam - publishOnImport request parameter value
      dataUrlSizeThresholdParam - dataUrlSizeThreshold request parameter value
      docbasePropNamesParam - docbasePropNames request parameter value
      documentTagsParam - documentTags request parameter value
      binaryTagsParam - binaryTags request parameter value
    • getAttachmentByContentId

      protected org.apache.cxf.jaxrs.ext.multipart.Attachment getAttachmentByContentId(List<org.apache.cxf.jaxrs.ext.multipart.Attachment> attachments, String contentId)
      Find the attachment in attachments list by the contentId.
      Parameters:
      attachments - attachment list
      contentId - content Id
      Returns:
      the attachment in attachments list found by the contentId
    • applyTagContentProperties

      protected boolean applyTagContentProperties(org.onehippo.forge.content.pojo.model.ContentNode contentNode, Set<String> tagInfos)
      Apply tag field on the content node with give tagInfos list, each item of which should look like "myhippoproject:tags=a,b,c".
      Parameters:
      contentNode - content node
      tagInfos - tag info line like "myhippoproject:tags=a,b,c"
      Returns:
      true if any tag field is added
    • getUserPrincipalName

      protected String getUserPrincipalName(jakarta.ws.rs.core.SecurityContext securityContext, jakarta.servlet.http.HttpServletRequest request)
      Find user principal's name from securityContext or request.
      Parameters:
      securityContext - security context
      request - servlet request
      Returns:
      user principal's name from securityContext or request
    • fillProcessStatusByRequestInfo

      protected void fillProcessStatusByRequestInfo(ProcessStatus process, jakarta.ws.rs.core.SecurityContext securityContext, jakarta.servlet.http.HttpServletRequest request)
      Fill basic info from securityContext and request in process.
      Parameters:
      process - process
      securityContext - security context
      request - servlet request
    • createTeeLogger

      protected org.slf4j.Logger createTeeLogger(org.slf4j.Logger mainLogger, PrintStream secondOutput)
      Create a tee-ing logger.
      Parameters:
      mainLogger - main logger
      secondOutput - output for the second logger
      Returns:
      a tee-ing logger
    • isBinaryPathIncluded

      protected boolean isBinaryPathIncluded(AntPathMatcher pathMatcher, ExecutionParams params, String path)
      Return true if the given path is included in the param's binary path includes parameter.
      Parameters:
      pathMatcher - AntPathMatcher instance
      params - Execution params
      path - binary path
      Returns:
      true if the given path is included in the param's binary path includes parameter
    • isDocumentPathIncluded

      protected boolean isDocumentPathIncluded(AntPathMatcher pathMatcher, ExecutionParams params, String path)
      Return true if the given path is included in the param's document path includes parameter.
      Parameters:
      pathMatcher - AntPathMatcher instance
      params - Execution params
      path - document path
      Returns:
      true if the given path is included in the param's document path includes parameter