use of org.alfresco.service.cmr.repository.ContentReader in project records-management by Alfresco.
the class RecordsManagementSearchServiceImpl method getSavedSearch.
/**
* @see org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService#getSavedSearch(java.lang.String, java.lang.String)
*/
@Override
public SavedSearchDetails getSavedSearch(String siteId, String name) {
// check for mandatory parameters
ParameterCheck.mandatory("siteId", siteId);
ParameterCheck.mandatory("name", name);
SavedSearchDetails result = null;
// get the saved search node
NodeRef searchNode = getSearchNodeRef(siteId, name);
if (searchNode != null) {
// get the json content
ContentReader reader = fileFolderService.getReader(searchNode);
String jsonString = reader.getContentString();
// create the saved search details
result = SavedSearchDetails.createFromJSON(jsonString, namespaceService, this, searchNode);
}
return result;
}
use of org.alfresco.service.cmr.repository.ContentReader in project records-management by Alfresco.
the class ApplyFixMob1573Get method readCustomContentModel.
private M2Model readCustomContentModel() {
ContentReader reader = contentService.getReader(RM_CUSTOM_MODEL_NODE_REF, ContentModel.TYPE_CONTENT);
if (!reader.exists()) {
throw new AlfrescoRuntimeException("RM CustomModel has no content.");
}
InputStream contentIn = null;
M2Model deserializedModel = null;
try {
contentIn = reader.getContentInputStream();
deserializedModel = M2Model.createModel(contentIn);
} finally {
try {
if (contentIn != null) {
contentIn.close();
}
} catch (IOException ignored) {
// Intentionally empty.
}
}
return deserializedModel;
}
use of org.alfresco.service.cmr.repository.ContentReader in project records-management by Alfresco.
the class SplitEmailAction method executeImpl.
/**
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action,
* org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
// get node type
getNodeService().getType(actionedUponNodeRef);
if (logger.isDebugEnabled()) {
logger.debug("split email:" + actionedUponNodeRef);
}
if (getRecordService().isRecord(actionedUponNodeRef)) {
if (!getRecordService().isDeclared(actionedUponNodeRef)) {
ChildAssociationRef parent = getNodeService().getPrimaryParent(actionedUponNodeRef);
/**
* Check whether the email message has already been split - do nothing if it has already been split
*/
List<AssociationRef> refs = getNodeService().getTargetAssocs(actionedUponNodeRef, ImapModel.ASSOC_IMAP_ATTACHMENT);
if (refs.size() > 0) {
if (logger.isDebugEnabled()) {
logger.debug("mail message has already been split - do nothing");
}
return;
}
/**
* Get the content and if its a mime message then create atachments for each part
*/
try {
ContentReader reader = getContentService().getReader(actionedUponNodeRef, ContentModel.PROP_CONTENT);
InputStream is = reader.getContentInputStream();
MimeMessage mimeMessage = new MimeMessage(null, is);
Object content = mimeMessage.getContent();
if (content instanceof Multipart) {
Multipart multipart = (Multipart) content;
for (int i = 0, n = multipart.getCount(); i < n; i++) {
Part part = multipart.getBodyPart(i);
if ("attachment".equalsIgnoreCase(part.getDisposition())) {
createAttachment(actionedUponNodeRef, parent.getParentRef(), part);
}
}
}
} catch (Exception e) {
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NO_READ_MIME_MESSAGE, e.toString()), e);
}
} else {
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EMAIL_DECLARED, actionedUponNodeRef.toString()));
}
} else {
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EMAIL_NOT_RECORD, actionedUponNodeRef.toString()));
}
}
Aggregations