use of org.alfresco.service.cmr.site.SiteInfo in project alfresco-remote-api by Alfresco.
the class AbstractDocLink method parseNodeRefFromTemplateArgs.
protected NodeRef parseNodeRefFromTemplateArgs(Map<String, String> templateVars) {
if (templateVars == null) {
return null;
}
String storeTypeArg = templateVars.get(PARAM_STORE_TYPE);
String storeIdArg = templateVars.get(PARAM_STORE_ID);
String idArg = templateVars.get(PARAM_ID);
if (storeTypeArg != null) {
ParameterCheck.mandatoryString("storeTypeArg", storeTypeArg);
ParameterCheck.mandatoryString("storeIdArg", storeIdArg);
ParameterCheck.mandatoryString("idArg", idArg);
/*
* NodeRef based request
* <url>URL_BASE/{store_type}/{store_id}/{id}</url>
*/
return new NodeRef(storeTypeArg, storeIdArg, idArg);
} else {
String siteArg = templateVars.get(PARAM_SITE);
String containerArg = templateVars.get(PARAM_CONTAINER);
String pathArg = templateVars.get(PARAM_PATH);
if (siteArg != null) {
ParameterCheck.mandatoryString("siteArg", siteArg);
ParameterCheck.mandatoryString("containerArg", containerArg);
/*
* Site based request <url>URL_BASE/{site}/{container}</url> or
* <url>URL_BASE/{site}/{container}/{path}</url>
*/
SiteInfo site = siteService.getSite(siteArg);
PropertyCheck.mandatory(this, "site", site);
NodeRef node = siteService.getContainer(site.getShortName(), containerArg);
if (node == null) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Invalid 'container' variable");
}
if (pathArg != null) {
// <url>URL_BASE/{site}/{container}/{path}</url>
StringTokenizer st = new StringTokenizer(pathArg, "/");
while (st.hasMoreTokens()) {
String childName = st.nextToken();
node = nodeService.getChildByName(node, ContentModel.ASSOC_CONTAINS, childName);
if (node == null) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Invalid 'path' variable");
}
}
}
return node;
}
}
return null;
}
use of org.alfresco.service.cmr.site.SiteInfo in project alfresco-remote-api by Alfresco.
the class InviteByTicket method toInviteInfo.
private InviteInfo toInviteInfo(NominatedInvitation invitation) {
final PersonService personService = serviceRegistry.getPersonService();
// get the site info
SiteInfo siteInfo = siteService.getSite(invitation.getResourceName());
String invitationStatus = getInvitationStatus(invitation);
NodeRef inviterRef = personService.getPerson(invitation.getInviterUserName());
TemplateNode inviterPerson = null;
if (inviterRef != null) {
inviterPerson = new TemplateNode(inviterRef, serviceRegistry, null);
}
// fetch the person node for the invitee
NodeRef inviteeRef = personService.getPerson(invitation.getInviteeUserName());
TemplateNode inviteePerson = null;
if (inviteeRef != null) {
inviteePerson = new TemplateNode(inviteeRef, serviceRegistry, null);
}
InviteInfo ret = new InviteInfo(invitationStatus, invitation.getInviterUserName(), inviterPerson, invitation.getInviteeUserName(), inviteePerson, invitation.getRoleName(), invitation.getResourceName(), siteInfo, invitation.getSentInviteDate(), invitation.getInviteId());
return ret;
}
use of org.alfresco.service.cmr.site.SiteInfo 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.service.cmr.site.SiteInfo 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.service.cmr.site.SiteInfo in project records-management by Alfresco.
the class RmSiteType method beforeDeleteNode.
/**
* @see org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy#beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef)
*/
@Behaviour(kind = BehaviourKind.CLASS, notificationFrequency = NotificationFrequency.FIRST_EVENT)
public void beforeDeleteNode(NodeRef nodeRef) {
final SiteInfo siteInfo = siteService.getSite(nodeRef);
if (siteInfo != null) {
// grab the file plan for the RM site
NodeRef filePlan = AuthenticationUtil.runAsSystem(new RunAsWork<NodeRef>() {
@Override
public NodeRef doWork() {
return siteService.getContainer(siteInfo.getShortName(), COMPONENT_DOCUMENT_LIBRARY);
}
});
if (filePlan != null) {
// determine whether the current user has delete capability on the file plan node
AccessStatus accessStatus = capabilityService.getCapabilityAccessState(filePlan, "Delete");
if (AccessStatus.DENIED.equals(accessStatus)) {
throw new AlfrescoRuntimeException("The records management site can not be deleted, because the user doesn't have sufficient privillages to delete the file plan.");
}
// work around for MNT-11038 .. we want to ensure that the RM site can be created once it's been deleted since we only
// allow one short name for the RM site
AuthenticationUtil.runAsSystem(new RunAsWork<Void>() {
@Override
public Void doWork() {
// delete the authority
String siteGroup = siteService.getSiteGroup(siteInfo.getShortName());
authorityService.deleteAuthority(siteGroup, true);
return null;
}
});
filePlanType.disable();
}
}
}
Aggregations