use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class DeclarativeReportGenerator method getReportTemplate.
/**
* Get's the report template based on the type and mimetype.
*
* @param mimetype
* @return
*/
private NodeRef getReportTemplate(String mimetype) {
// check that the template root has been correctly bootstraped
if (!fileFolderService.exists(TEMPLATE_ROOT)) {
throw new AlfrescoRuntimeException("Unable to get report template, because the template root folder does not exist in the data dictionary.");
}
String reportTemplateName = getReportTemplateName(mimetype);
NodeRef reportTemplateNodeRef = fileFolderService.searchSimple(TEMPLATE_ROOT, reportTemplateName);
if (reportTemplateNodeRef == null) {
throw new AlfrescoRuntimeException("Unable to get report template, because report template " + reportTemplateName + " does not exist.");
}
// get localise template
return fileFolderService.getLocalizedSibling(reportTemplateNodeRef);
}
use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class RecordFolderServiceImpl method isRecordFolderDeclared.
/**
* @see org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderService#isRecordFolderDeclared(NodeRef)
*/
@Override
public boolean isRecordFolderDeclared(NodeRef nodeRef) {
ParameterCheck.mandatory("nodeRef", nodeRef);
// Check we have a record folder
if (!isRecordFolder(nodeRef)) {
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_RECORD_FOLDER_EXPECTED));
}
boolean result = true;
// Check that each record in the record folder in declared
List<NodeRef> records = recordService.getRecords(nodeRef);
for (NodeRef record : records) {
if (!recordService.isDeclared(record)) {
result = false;
break;
}
}
return result;
}
use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class InplaceRecordServiceImpl method moveRecord.
/**
* @see org.alfresco.module.org_alfresco_module_rm.record.InplaceRecordService#moveRecord(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.repository.NodeRef)
*/
@Override
public void moveRecord(final NodeRef nodeRef, final NodeRef targetNodeRef) {
ParameterCheck.mandatory("nodeRef", nodeRef);
ParameterCheck.mandatory("targetNodeRef", targetNodeRef);
NodeRef sourceParentNodeRef = null;
NodeRef originatingLocation = (NodeRef) nodeService.getProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION);
for (ChildAssociationRef parentAssoc : nodeService.getParentAssocs(nodeRef)) {
if (!parentAssoc.isPrimary() && parentAssoc.getParentRef().equals(originatingLocation)) {
sourceParentNodeRef = parentAssoc.getParentRef();
break;
}
}
if (sourceParentNodeRef == null) {
throw new AlfrescoRuntimeException("Could not find source parent node reference.");
}
SiteInfo sourceSite = siteService.getSite(sourceParentNodeRef);
SiteInfo targetSite = siteService.getSite(targetNodeRef);
if (!sourceSite.equals(targetSite)) {
throw new AlfrescoRuntimeException("The record can only be moved within the same collaboration site.");
}
if (!sourceSite.getSitePreset().equals("site-dashboard")) {
throw new AlfrescoRuntimeException("Only records within a collaboration site can be moved.");
}
final NodeRef source = sourceParentNodeRef;
authenticationUtil.runAsSystem(new RunAsWork<Void>() {
@Override
public Void doWork() {
try {
// Move the record
fileFolderService.moveFrom(nodeRef, source, targetNodeRef, null);
// Update the originating location property
nodeService.setProperty(nodeRef, PROP_RECORD_ORIGINATING_LOCATION, targetNodeRef);
} catch (FileExistsException | FileNotFoundException ex) {
throw new AlfrescoRuntimeException("Can't move node: " + ex);
}
return null;
}
});
}
use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class DateParameterProcessor method handleYear.
private String handleYear(String[] values) {
String style = getStyle(values);
String pattern;
if (SHORT.equalsIgnoreCase(style)) {
pattern = "yy";
} else if (LONG.equalsIgnoreCase(style)) {
pattern = "yyyy";
} else if (WEEK.equalsIgnoreCase(style)) {
pattern = "ww";
} else {
throw new AlfrescoRuntimeException("The pattern 'date.year." + style + "' is not supported!");
}
return new SimpleDateFormat(pattern).format(new Date());
}
use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class DateParameterProcessor method handleDay.
private String handleDay(String[] values) {
String style = getStyle(values);
String pattern;
if (SHORT.equalsIgnoreCase(style)) {
pattern = "EE";
} else if (LONG.equalsIgnoreCase(style)) {
pattern = "EEEE";
} else if (NUMBER.equalsIgnoreCase(style)) {
pattern = "uu";
} else if (MONTH.equalsIgnoreCase(style)) {
pattern = "dd";
} else if (YEAR.equalsIgnoreCase(style)) {
pattern = "DDD";
} else {
throw new AlfrescoRuntimeException("The pattern 'date.day." + style + "' is not supported!");
}
return new SimpleDateFormat(pattern).format(new Date());
}
Aggregations