use of org.alfresco.service.cmr.site.SiteInfo in project alfresco-repository by Alfresco.
the class SiteServiceImpl method getSiteImpl.
/**
* Get the site implementation given a short name
*
* @param shortName String
* @return SiteInfo
*/
private SiteInfo getSiteImpl(String shortName) {
SiteInfo result = null;
// Get the site node
NodeRef siteNodeRef = getSiteNodeRef(shortName);
if (siteNodeRef != null) {
// Create the site info
result = createSiteInfo(siteNodeRef);
}
// Return the site information
return result;
}
use of org.alfresco.service.cmr.site.SiteInfo in project alfresco-repository by Alfresco.
the class AbstractEventsService method getNodeInfo.
protected NodeInfo getNodeInfo(final NodeRef nodeRef, final String eventType) {
NodeInfo nodeInfo = AuthenticationUtil.runAsSystem(new RunAsWork<NodeInfo>() {
public NodeInfo doWork() throws Exception {
NodeInfo nodeInfo = null;
String txnId = AlfrescoTransactionSupport.getTransactionId();
if (!includeEventType(eventType)) {
nodeInfo = new NodeInfo(eventType, null, null, nodeRef, null, null, null, null, null, null, null, null, false, null, null);
} else if (nodeRef == null || !nodeService.exists(nodeRef)) {
nodeInfo = new NodeInfo(eventType, txnId, null, nodeRef, null, null, null, null, null, null, null, false, true, false, null);
} else {
FileFilterMode.Client filterclient = FileFilterMode.getClient();
Visibility visibility = hiddenAspect.getVisibility(filterclient, nodeRef);
QName type = nodeService.getType(nodeRef);
if (!typeMatches(type)) {
nodeInfo = new NodeInfo(eventType, txnId, null, nodeRef, null, null, null, null, null, null, null, true, true, false, false);
} else if (!visibility.equals(Visibility.Visible)) {
nodeInfo = new NodeInfo(eventType, txnId, null, nodeRef, null, null, null, null, null, null, null, true, true, true, true);
} else {
SiteInfo siteInfo = siteService.getSite(nodeRef);
String siteId = (siteInfo != null ? siteInfo.getShortName() : null);
Set<QName> aspects = nodeService.getAspects(nodeRef);
final String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
List<Path> nodePaths = Collections.singletonList(nodeService.getPath(nodeRef));
Date modifiedTime = (Date) nodeService.getProperty(nodeRef, ContentModel.PROP_MODIFIED);
Long modificationTimestamp = (modifiedTime != null ? modifiedTime.getTime() : null);
Status status = nodeService.getNodeStatus(nodeRef);
Client client = ClientUtil.from(filterclient);
nodeInfo = new NodeInfo(eventType, txnId, name, nodeRef, status, nodePaths, modificationTimestamp, type, aspects, siteId, client, true, true, true, true);
}
}
return nodeInfo;
}
});
return nodeInfo;
}
use of org.alfresco.service.cmr.site.SiteInfo in project alfresco-repository by Alfresco.
the class TemporarySites method createSite.
/**
* This method creates a Share Site (<b>or subtype</b>) and adds it to the internal list of NodeRefs to be tidied up by the rule.
* This method will be run in its own transaction and will be run with the specified user as the fully authenticated user,
* thus ensuring the named user is the creator of the new site.
*
* @param sitePreset the site preset
* @param siteShortName the short name of the new site
* @param siteTitle the title of the new site
* @param siteDescription the description of the new site
* @param visibility the visibility
* @param siteType the site type (must be st:site or subtype)
* @param siteCreator the username of the person who will create the site
* @return the newly created SiteInfo.
*/
public SiteInfo createSite(final String sitePreset, final String siteShortName, final String siteTitle, final String siteDescription, final SiteVisibility visibility, final QName siteType, final String siteCreator) {
final RetryingTransactionHelper transactionHelper = appContextRule.getApplicationContext().getBean("retryingTransactionHelper", RetryingTransactionHelper.class);
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setFullyAuthenticatedUser(siteCreator);
SiteInfo newSite = transactionHelper.doInTransaction(new RetryingTransactionCallback<SiteInfo>() {
public SiteInfo execute() throws Throwable {
final SiteService siteService = appContextRule.getApplicationContext().getBean("siteService", SiteService.class);
SiteInfo newSite = siteService.createSite(sitePreset, siteShortName, siteTitle, siteDescription, visibility, siteType);
// ensure that the Document Library folder is pre-created so that test code can start creating content straight away.
// At the time of writing HEAD does not create this folder automatically, but Thor does.
// So to be safe, I'll pre-check if the node is there.
NodeRef docLibFolder = siteService.getContainer(siteShortName, SiteService.DOCUMENT_LIBRARY);
if (docLibFolder == null) {
docLibFolder = siteService.createContainer(siteShortName, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null);
}
return newSite;
}
});
AuthenticationUtil.popAuthentication();
this.temporarySites.add(newSite);
return newSite;
}
use of org.alfresco.service.cmr.site.SiteInfo in project alfresco-repository by Alfresco.
the class TemporaryNodes method after.
@Override
protected void after() {
final ApplicationContext springContext = appContextRule.getApplicationContext();
final RetryingTransactionHelper transactionHelper = springContext.getBean("retryingTransactionHelper", RetryingTransactionHelper.class);
final CheckOutCheckInService cociService = springContext.getBean("CheckOutCheckInService", CheckOutCheckInService.class);
final DictionaryService dictionaryService = springContext.getBean("DictionaryService", DictionaryService.class);
final NodeService nodeService = springContext.getBean("NodeService", NodeService.class);
final SiteService siteService = springContext.getBean("SiteService", SiteService.class);
final VersionService versionService = springContext.getBean("VersionService", VersionService.class);
// Run as system to ensure all non-system nodes can be deleted irrespective of which user created them.
AuthenticationUtil.runAs(new RunAsWork<Void>() {
@Override
public Void doWork() throws Exception {
transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
// Although we loop through all nodes, this is a cascade-delete and so we may only need to delete the first node.
for (NodeRef node : temporaryNodeRefs) {
// If it's already been deleted, don't worry about it.
if (nodeService.exists(node)) {
// If it has been checked out, cancel the checkout before deletion.
if (cociService.isCheckedOut(node)) {
log.debug("Cancelling checkout of temporary node " + nodeService.getProperty(node, ContentModel.PROP_NAME));
NodeRef workingCopy = cociService.getWorkingCopy(node);
cociService.cancelCheckout(workingCopy);
}
// If it's been versioned, then we need to clean out the version history too.
if (versionService.isVersioned(node)) {
log.debug("Deleting version history of temporary node " + nodeService.getProperty(node, ContentModel.PROP_NAME));
versionService.deleteVersionHistory(node);
}
log.debug("Deleting temporary node " + nodeService.getProperty(node, ContentModel.PROP_NAME));
// Site nodes are a special case which must be deleted through the SiteService.
final QName nodeType = nodeService.getType(node);
if (nodeType.equals(SiteModel.TYPE_SITE) || dictionaryService.isSubClass(nodeType, SiteModel.TYPE_SITE)) {
SiteInfo siteInfo = siteService.getSite(node);
siteService.deleteSite(siteInfo.getShortName());
} else {
nodeService.deleteNode(node);
}
}
}
return null;
}
});
return null;
}
}, AuthenticationUtil.getSystemUserName());
}
use of org.alfresco.service.cmr.site.SiteInfo in project alfresco-repository by Alfresco.
the class ActivityPosterImpl method postFileFolderAdded.
/**
* {@inheritDoc}
*/
@Override
public void postFileFolderAdded(NodeRef nodeRef) {
if (activitiesEnabled && !hiddenAspect.hasHiddenAspect(nodeRef)) {
SiteInfo siteInfo = siteService.getSite(nodeRef);
String siteId = (siteInfo != null ? siteInfo.getShortName() : null);
if (siteId != null && !siteId.equals("")) {
// post only for nodes within sites
NodeRef parentNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef();
String path = null;
boolean isFolder = isFolder(nodeRef);
String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
if (isFolder) {
NodeRef documentLibrary = siteService.getContainer(siteId, SiteService.DOCUMENT_LIBRARY);
path = "/";
try {
path = getPathFromNode(documentLibrary, nodeRef);
} catch (FileNotFoundException error) {
if (logger.isDebugEnabled()) {
logger.debug("No " + SiteService.DOCUMENT_LIBRARY + " container found.");
}
}
}
FileInfo fileInfo = fileFolderService.getFileInfo(nodeRef);
poster.postFileFolderActivity((isFolder ? ActivityType.FOLDER_ADDED : ActivityType.FILE_ADDED), path, getCurrentTenantDomain(), siteId, parentNodeRef, nodeRef, name, APP_TOOL, Client.asType(ClientType.cmis), fileInfo);
}
}
}
Aggregations