use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class RelationshipServiceImpl method getAssociationDefinitionName.
/**
* Gets the qualified name of the association definition for the given unique name
*
* @param uniqueName The unique name
* @return The qualified name of the association definition for the given unique name
*/
private QName getAssociationDefinitionName(String uniqueName) {
AssociationDefinition associationDefinition = getAssociationDefinition(uniqueName);
if (associationDefinition == null) {
StringBuilder sb = new StringBuilder();
sb.append("The qualified name for '").append(uniqueName).append("' was not found.");
throw new AlfrescoRuntimeException(sb.toString());
}
return associationDefinition.getName();
}
use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class RelationshipServiceImpl method getRelationshipDisplayName.
/**
* Gets the relationship display name of the relationship definition
*
* @param type The type of the relationship definition
* @param title The title of the association definition
* @return The relationship display name of the relationship definition
*/
private RelationshipDisplayName getRelationshipDisplayName(RelationshipType type, String title) {
String sourceText = null;
String targetText = null;
switch(type) {
case BIDIRECTIONAL:
sourceText = title;
targetText = title;
break;
case PARENTCHILD:
String[] sourceAndTarget = splitAssociationDefinitionTitle(title);
sourceText = sourceAndTarget[0];
targetText = sourceAndTarget[1];
break;
default:
StringBuilder sb = new StringBuilder();
sb.append("Unsupported relationship type: '").append(type.toString()).append("'.");
throw new AlfrescoRuntimeException(sb.toString());
}
return new RelationshipDisplayName(sourceText, targetText);
}
use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class ApplyFixMob1573Get method writeCustomContentModel.
private void writeCustomContentModel(M2Model deserializedModel) {
ContentWriter writer = contentService.getWriter(RM_CUSTOM_MODEL_NODE_REF, ContentModel.TYPE_CONTENT, true);
writer.setMimetype(MimetypeMap.MIMETYPE_XML);
writer.setEncoding("UTF-8");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
deserializedModel.toXML(baos);
String updatedModelXml;
try {
updatedModelXml = baos.toString("UTF-8");
writer.putContent(updatedModelXml);
// putContent closes all resources.
// so we don't have to.
} catch (UnsupportedEncodingException uex) {
throw new AlfrescoRuntimeException("Exception when writing custom model xml.", uex);
}
}
use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class BootstrapTestDataGet method executeImpl.
@Override
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
// resolve import argument
boolean importData = false;
if (req.getParameter(ARG_IMPORT) != null) {
importData = Boolean.parseBoolean(req.getParameter(ARG_IMPORT));
}
// resolve rm site
String siteName = RmSiteType.DEFAULT_SITE_NAME;
if (req.getParameter(ARG_SITE_NAME) != null) {
siteName = req.getParameter(ARG_SITE_NAME);
}
if (importData) {
SiteInfo site = siteService.getSite(siteName);
if (site == null) {
throw new AlfrescoRuntimeException("Records Management site does not exist: " + siteName);
}
// resolve documentLibrary (filePlan) container
NodeRef filePlan = siteService.getContainer(siteName, RmSiteType.COMPONENT_DOCUMENT_LIBRARY);
if (filePlan == null) {
filePlan = siteService.createContainer(siteName, RmSiteType.COMPONENT_DOCUMENT_LIBRARY, TYPE_FILE_PLAN, null);
}
// import the RM test data ACP into the the provided filePlan node reference
InputStream is = BootstrapTestDataGet.class.getClassLoader().getResourceAsStream(XML_IMPORT);
if (is == null) {
throw new AlfrescoRuntimeException("The DODExampleFilePlan.xml import file could not be found");
}
Reader viewReader = null;
try {
viewReader = new InputStreamReader(is, CHARSET_NAME);
} catch (UnsupportedEncodingException error) {
throw new AlfrescoRuntimeException("The Character Encoding '" + CHARSET_NAME + "' is not supported.", error);
}
Location location = new Location(filePlan);
importerService.importView(viewReader, location, null, null);
}
// Patch data
BootstrapTestDataGet.patchLoadedData(searchService, nodeService, recordsManagementService, recordsManagementActionService, permissionService, authorityService, recordsManagementSecurityService, recordsManagementSearchBehaviour, dispositionService, recordFolderService);
Map<String, Object> model = new HashMap<String, Object>(1, 1.0f);
model.put("success", true);
return model;
}
use of org.alfresco.error.AlfrescoRuntimeException in project records-management by Alfresco.
the class TransferServiceImpl method transfer.
/**
* @see org.alfresco.module.org_alfresco_module_rm.transfer.TransferService#transfer(NodeRef, boolean)
*/
@Override
public NodeRef transfer(NodeRef nodeRef, boolean isAccession) {
ParameterCheck.mandatory("nodeRef", nodeRef);
// Get the root rm node
NodeRef root = filePlanService.getFilePlan(nodeRef);
// Get the transfer object
NodeRef transferNodeRef = (NodeRef) AlfrescoTransactionSupport.getResource(KEY_TRANSFER_NODEREF);
if (transferNodeRef == null) {
// Calculate a transfer name
QName nodeDbid = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "node-dbid");
Long dbId = (Long) nodeService.getProperty(nodeRef, nodeDbid);
String transferName = StringUtils.leftPad(dbId.toString(), 10, "0");
// Create the transfer object
Map<QName, Serializable> transferProps = new HashMap<QName, Serializable>(2);
transferProps.put(ContentModel.PROP_NAME, transferName);
transferProps.put(PROP_TRANSFER_ACCESSION_INDICATOR, isAccession);
// setup location property from disposition schedule
DispositionAction da = dispositionService.getNextDispositionAction(nodeRef);
if (da != null) {
DispositionActionDefinition actionDef = da.getDispositionActionDefinition();
if (actionDef != null) {
transferProps.put(PROP_TRANSFER_LOCATION, actionDef.getLocation());
}
}
NodeRef transferContainer = filePlanService.getTransferContainer(root);
transferContainerType.disable();
transferType.disable();
try {
transferNodeRef = nodeService.createNode(transferContainer, ContentModel.ASSOC_CONTAINS, QName.createQName(RM_URI, transferName), TYPE_TRANSFER, transferProps).getChildRef();
} finally {
transferContainerType.enable();
transferType.enable();
}
// Bind the hold node reference to the transaction
AlfrescoTransactionSupport.bindResource(KEY_TRANSFER_NODEREF, transferNodeRef);
} else {
// ensure this node has not already in the process of being transferred
List<ChildAssociationRef> transferredAlready = nodeService.getChildAssocs(transferNodeRef, ASSOC_TRANSFERRED, ASSOC_TRANSFERRED);
for (ChildAssociationRef car : transferredAlready) {
if (car.getChildRef().equals(nodeRef)) {
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NODE_ALREADY_TRANSFER, nodeRef.toString()));
}
}
}
// Link the record to the trasnfer object
transferType.disable();
try {
nodeService.addChild(transferNodeRef, nodeRef, ASSOC_TRANSFERRED, ASSOC_TRANSFERRED);
// Set PDF indicator flag
setPDFIndicationFlag(transferNodeRef, nodeRef);
} finally {
transferType.enable();
}
// Set the transferring indicator aspect
nodeService.addAspect(nodeRef, ASPECT_TRANSFERRING, null);
if (isRecordFolder(nodeRef)) {
// add the transferring indicator aspect to all the child records
for (NodeRef record : recordService.getRecords(nodeRef)) {
nodeService.addAspect(record, ASPECT_TRANSFERRING, null);
}
}
return transferNodeRef;
}
Aggregations