Class AbstractContentEximService
java.lang.Object
org.onehippo.forge.content.exim.repository.jaxrs.AbstractContentEximService
- Direct Known Subclasses:
ContentEximExportService,ContentEximImportService,ContentEximProcessStatusService
AbstractContentEximService.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringZip Entry name prefix for the binary attachments.protected static final StringThe whole execution log file entry name.protected static final StringZip Entry name of the summary log for binaries.protected static final StringZip Entry name of the summary log for documents.protected static final StringStop signal file's relative path under the zip creating base folder.protected static final CredentialsSystem session credentials.protected static final StringPrefix of the temporary folder or files. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanapplyTagContentProperties(org.onehippo.forge.content.pojo.model.ContentNode contentNode, Set<String> tagInfos) Apply tag field on the content node with givetagInfoslist, each item of which should look like "myhippoproject:tags=a,b,c".protected StringattachmentToString(org.apache.cxf.jaxrs.ext.multipart.Attachment attachment, String charsetName) Read the CXF attachment JAX-RS argument and convert it to a string.protected SessionCreate a new JCR system session by impersonating the JCR session returned fromgetDaemonSession().protected org.slf4j.LoggercreateTeeLogger(org.slf4j.Logger mainLogger, PrintStream secondOutput) Create a tee-ing logger.protected voidfillProcessStatusByRequestInfo(ProcessStatus process, jakarta.ws.rs.core.SecurityContext securityContext, jakarta.servlet.http.HttpServletRequest request) Fill basic info fromsecurityContextandrequestinprocess.protected org.apache.cxf.jaxrs.ext.multipart.AttachmentgetAttachmentByContentId(List<org.apache.cxf.jaxrs.ext.multipart.Attachment> attachments, String contentId) Find the attachment inattachmentslist by thecontentId.protected SessionReturn the JCR session given by the DaemonModule.protected com.fasterxml.jackson.databind.ObjectMapperReturn the default Jackson ObjectMapper instance.protected org.onehippo.forge.content.exim.repository.jaxrs.ProcessMonitorgetQueriedNodePaths(Session session, String statement, String language) Executes JCR query using the querystatementin the querylanguageand collect all the result node paths in a set to return.protected StringgetUserPrincipalName(jakarta.ws.rs.core.SecurityContext securityContext, jakarta.servlet.http.HttpServletRequest request) Find user principal's name fromsecurityContextorrequest.protected booleanisBinaryPathIncluded(AntPathMatcher pathMatcher, ExecutionParams params, String path) Return true if the givenpathis included in theparam's binary path includes parameter.protected booleanisDocumentPathIncluded(AntPathMatcher pathMatcher, ExecutionParams params, String path) Return true if the givenpathis included in theparam's document path includes parameter.protected booleanisStopRequested(org.apache.commons.vfs2.FileObject baseFolder) Return true if a stop signal file is found under the base folder.protected voidoverrideExecutionParamsByParameters(ExecutionParams params, String batchSizeParam, String throttleParam, String publishOnImportParam, String dataUrlSizeThresholdParam, String docbasePropNamesParam, String documentTagsParam, String binaryTagsParam) Overrideparamsby the give request parameter values.protected ResultItemConvert theContentMigrationRecordinstance to aResultIteminstance.protected voidsetDaemonSession(Session daemonSession) Set the JCR session, supposed to be set by the DaemonModule.protected voidsetProcessMonitor(org.onehippo.forge.content.exim.repository.jaxrs.ProcessMonitor processMonitor) protected StringtoJsonString(Object object) Return a JSON string by stringifying theobjectwith the Jackson ObjectMapper.protected voidtransferAttachmentToFile(org.apache.cxf.jaxrs.ext.multipart.Attachment attachment, File file) Transfer attachment content into the givenfile.
-
Field Details
-
SYSTEM_CREDENTIALS
System session credentials. -
TEMP_PREFIX
Prefix of the temporary folder or files. e.g, temporary folder in zip content creation.- See Also:
-
EXIM_EXECUTION_LOG_REL_PATH
The whole execution log file entry name.- See Also:
-
EXIM_SUMMARY_BINARIES_LOG_REL_PATH
Zip Entry name of the summary log for binaries.- See Also:
-
EXIM_SUMMARY_DOCUMENTS_LOG_REL_PATH
Zip Entry name of the summary log for documents.- See Also:
-
BINARY_ATTACHMENT_REL_PATH
Zip Entry name prefix for the binary attachments.- See Also:
-
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
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 usecreateSession()for that purpose instead.- Returns:
- the JCR session given by the DaemonModule
-
setDaemonSession
Set the JCR session, supposed to be set by the DaemonModule.- Parameters:
daemonSession- the JCR session given by the DaemonModule
-
createSession
Create a new JCR system session by impersonating the JCR session returned fromgetDaemonSession().- Returns:
- a new JCR system session by impersonating the JCR session returned from
getDaemonSession() - Throws:
LoginException- if impersonation with system credentials failsRepositoryException- 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 theobjectwith the Jackson ObjectMapper.- Parameters:
object- object to stringify- Returns:
- a JSON string by stringifying the
objectwith 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 argumentcharsetName- 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 givenfile.- Parameters:
attachment- attachmentfile- destination file- Throws:
IOException- if IO exception occurs
-
recordToResultItem
Convert theContentMigrationRecordinstance to aResultIteminstance.- Parameters:
record- aContentMigrationRecordinstance- Returns:
- a converted
ResultIteminstance
-
getQueriedNodePaths
protected Set<String> getQueriedNodePaths(Session session, String statement, String language) throws RepositoryException Executes JCR query using the querystatementin the querylanguageand collect all the result node paths in a set to return.- Parameters:
session- JCR sessionstatement- JCR query statementlanguage- 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) Overrideparamsby the give request parameter values.- Parameters:
params-ExecutionParamsinstancebatchSizeParam- batch size request parameter valuethrottleParam- throttle request parameter valuepublishOnImportParam- publishOnImport request parameter valuedataUrlSizeThresholdParam- dataUrlSizeThreshold request parameter valuedocbasePropNamesParam- docbasePropNames request parameter valuedocumentTagsParam- documentTags request parameter valuebinaryTagsParam- 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 inattachmentslist by thecontentId.- Parameters:
attachments- attachment listcontentId- content Id- Returns:
- the attachment in
attachmentslist found by thecontentId
-
applyTagContentProperties
protected boolean applyTagContentProperties(org.onehippo.forge.content.pojo.model.ContentNode contentNode, Set<String> tagInfos) Apply tag field on the content node with givetagInfoslist, each item of which should look like "myhippoproject:tags=a,b,c".- Parameters:
contentNode- content nodetagInfos- 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 fromsecurityContextorrequest.- Parameters:
securityContext- security contextrequest- servlet request- Returns:
- user principal's name from
securityContextorrequest
-
fillProcessStatusByRequestInfo
protected void fillProcessStatusByRequestInfo(ProcessStatus process, jakarta.ws.rs.core.SecurityContext securityContext, jakarta.servlet.http.HttpServletRequest request) Fill basic info fromsecurityContextandrequestinprocess.- Parameters:
process- processsecurityContext- security contextrequest- servlet request
-
createTeeLogger
Create a tee-ing logger.- Parameters:
mainLogger- main loggersecondOutput- output for the second logger- Returns:
- a tee-ing logger
-
isBinaryPathIncluded
protected boolean isBinaryPathIncluded(AntPathMatcher pathMatcher, ExecutionParams params, String path) Return true if the givenpathis included in theparam's binary path includes parameter.- Parameters:
pathMatcher- AntPathMatcher instanceparams- Execution paramspath- binary path- Returns:
- true if the given
pathis included in theparam's binary path includes parameter
-
isDocumentPathIncluded
protected boolean isDocumentPathIncluded(AntPathMatcher pathMatcher, ExecutionParams params, String path) Return true if the givenpathis included in theparam's document path includes parameter.- Parameters:
pathMatcher- AntPathMatcher instanceparams- Execution paramspath- document path- Returns:
- true if the given
pathis included in theparam's document path includes parameter
-