use of org.alfresco.service.cmr.site.SiteInfo in project alfresco-remote-api by Alfresco.
the class BlogServiceTest method setUp.
// General methods
@Override
protected void setUp() throws Exception {
super.setUp();
this.authenticationService = (MutableAuthenticationService) getServer().getApplicationContext().getBean("AuthenticationService");
this.authenticationComponent = (AuthenticationComponent) getServer().getApplicationContext().getBean("authenticationComponent");
this.personService = (PersonService) getServer().getApplicationContext().getBean("PersonService");
this.siteService = (SiteService) getServer().getApplicationContext().getBean("SiteService");
this.nodeArchiveService = (NodeArchiveService) getServer().getApplicationContext().getBean("nodeArchiveService");
this.activityService = (ActivityService) getServer().getApplicationContext().getBean("activityService");
ChildApplicationContextFactory activitiesFeed = (ChildApplicationContextFactory) getServer().getApplicationContext().getBean("ActivitiesFeed");
ApplicationContext activitiesFeedCtx = activitiesFeed.getApplicationContext();
this.feedGenerator = (FeedGenerator) activitiesFeedCtx.getBean("feedGenerator");
this.postLookup = (PostLookup) activitiesFeedCtx.getBean("postLookup");
// Authenticate as user
this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
// Create test site
// - only create the site if it doesn't already exist
SiteInfo siteInfo = this.siteService.getSite(SITE_SHORT_NAME_BLOG);
if (siteInfo == null) {
this.siteService.createSite("BlogSitePreset", SITE_SHORT_NAME_BLOG, "BlogSiteTitle", "BlogSiteDescription", SiteVisibility.PUBLIC);
}
// Create users
createUser(USER_ONE, SiteModel.SITE_COLLABORATOR, SITE_SHORT_NAME_BLOG);
createUser(USER_TWO, SiteModel.SITE_COLLABORATOR, SITE_SHORT_NAME_BLOG);
// Blank our lists used to track things the test creates
posts = new ArrayList<String>(5);
drafts = new ArrayList<String>(5);
// Do tests as inviter user
this.authenticationComponent.setCurrentUser(USER_ONE);
}
use of org.alfresco.service.cmr.site.SiteInfo in project alfresco-remote-api by Alfresco.
the class CalendarRestApiTest method tearDown.
@Override
protected void tearDown() throws Exception {
super.tearDown();
// admin user required to delete user
this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
SiteInfo siteInfo = this.siteService.getSite(SITE_SHORT_NAME_CALENDAR);
if (siteInfo != null) {
// delete invite site
siteService.deleteSite(SITE_SHORT_NAME_CALENDAR);
nodeArchiveService.purgeArchivedNode(nodeArchiveService.getArchivedNode(siteInfo.getNodeRef()));
}
// delete the users
deleteUser(USER_ONE);
deleteUser(USER_TWO);
deleteUser(USER_THREE);
deleteUser(USER_FOUR);
}
use of org.alfresco.service.cmr.site.SiteInfo in project alfresco-remote-api by Alfresco.
the class CommentsApiTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
ApplicationContext appContext = getServer().getApplicationContext();
fileFolderService = (FileFolderService) appContext.getBean("fileFolderService");
transactionService = (TransactionService) appContext.getBean("transactionService");
searchService = (SearchService) appContext.getBean("SearchService");
nodeService = (NodeService) appContext.getBean("nodeService");
namespaceService = (NamespaceService) appContext.getBean("namespaceService");
versionService = (VersionService) appContext.getBean("versionService");
personService = (PersonService) getServer().getApplicationContext().getBean("PersonService");
authenticationService = (MutableAuthenticationService) getServer().getApplicationContext().getBean("AuthenticationService");
authenticationComponent = (AuthenticationComponent) getServer().getApplicationContext().getBean("authenticationComponent");
permissionService = (PermissionServiceSPI) getServer().getApplicationContext().getBean("permissionService");
permissionModelDAO = (ModelDAO) getServer().getApplicationContext().getBean("permissionsModelDAO");
siteService = (SiteService) getServer().getApplicationContext().getBean("SiteService");
personService = (PersonService) getServer().getApplicationContext().getBean("PersonService");
nodeArchiveService = (NodeArchiveService) getServer().getApplicationContext().getBean("nodeArchiveService");
activityService = (ActivityService) getServer().getApplicationContext().getBean("activityService");
ChildApplicationContextFactory activitiesFeed = (ChildApplicationContextFactory) getServer().getApplicationContext().getBean("ActivitiesFeed");
ApplicationContext activitiesFeedCtx = activitiesFeed.getApplicationContext();
feedGenerator = (FeedGenerator) activitiesFeedCtx.getBean("feedGenerator");
postLookup = (PostLookup) activitiesFeedCtx.getBean("postLookup");
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
txn = transactionService.getUserTransaction();
txn.begin();
// Get Company Home
rootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
List<NodeRef> results = searchService.selectNodes(rootNodeRef, "/app:company_home", null, namespaceService, false);
if (results.size() == 0) {
throw new AlfrescoRuntimeException("Can't find /app:company_home");
}
companyHomeNodeRef = results.get(0);
// Get Shared
results = searchService.selectNodes(rootNodeRef, "/app:company_home/app:shared", null, namespaceService, false);
if (results.size() == 0) {
throw new AlfrescoRuntimeException("Can't find /app:company_home/app:shared");
}
sharedHomeNodeRef = results.get(0);
results = searchService.selectNodes(rootNodeRef, "/app:company_home/cm:Commenty", null, namespaceService, false);
if (results.size() > 0) {
fileFolderService.delete(results.get(0));
}
nodeRef = fileFolderService.create(companyHomeNodeRef, "Commenty", ContentModel.TYPE_CONTENT).getNodeRef();
versionService.ensureVersioningEnabled(nodeRef, null);
nodeService.setProperty(nodeRef, ContentModel.PROP_AUTO_VERSION_PROPS, true);
createUser(USER2);
createUser(USER_TEST);
txn.commit();
AuthenticationUtil.clearCurrentSecurityContext();
// MNT-12082
// Authenticate as admin
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
// Create test site
// - only create the site if it doesn't already exist
SiteInfo siteInfo = siteService.getSite(SITE_SHORT_NAME);
if (siteInfo == null) {
siteInfo = siteService.createSite("SomeTestSite", SITE_SHORT_NAME, "SiteTitle", "SiteDescription", SiteVisibility.PUBLIC);
}
NodeRef docLibContainer = siteService.getContainer(SITE_SHORT_NAME, DOCLIB_CONTAINER);
if (docLibContainer == null) {
siteService.createContainer(SITE_SHORT_NAME, DOCLIB_CONTAINER, ContentModel.TYPE_FOLDER, null);
}
txn = transactionService.getUserTransaction();
txn.begin();
// Create users
createUser(USER_ONE, SiteModel.SITE_CONSUMER);
createUser(USER_TWO, SiteModel.SITE_CONTRIBUTOR);
createUser(USER_THREE, SiteModel.SITE_COLLABORATOR);
createUser(USER_FOUR, SiteModel.SITE_COLLABORATOR);
// Create site page
sitePage = nodeService.createNode(siteInfo.getNodeRef(), ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, "test"), ContentModel.TYPE_CONTENT).getChildRef();
txn.commit();
}
use of org.alfresco.service.cmr.site.SiteInfo in project alfresco-remote-api by Alfresco.
the class FavouritesImpl method addFavourite.
@Override
public Favourite addFavourite(String personId, Favourite favourite, Parameters parameters) {
Favourite ret = null;
personId = people.validatePerson(personId, true);
Target target = favourite.getTarget();
if (target == null) {
throw new InvalidArgumentException("target is missing");
} else if (target instanceof SiteTarget) {
SiteTarget siteTarget = (SiteTarget) target;
String guid = siteTarget.getSite().getGuid();
SiteInfo siteInfo = sites.validateSite(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, guid));
NodeRef siteNodeRef = siteInfo.getNodeRef();
String siteId = siteInfo.getShortName();
try {
PersonFavourite personFavourite = favouritesService.addFavourite(personId, siteNodeRef);
ret = getFavourite(personFavourite, parameters);
} catch (SiteDoesNotExistException e) {
throw new RelationshipResourceNotFoundException(personId, siteId);
}
} else if (target instanceof DocumentTarget) {
DocumentTarget documentTarget = (DocumentTarget) target;
NodeRef nodeRef = documentTarget.getFile().getGuid();
if (!nodes.nodeMatches(nodeRef, Collections.singleton(ContentModel.TYPE_CONTENT), null)) {
throw new RelationshipResourceNotFoundException(personId, nodeRef.getId());
}
PersonFavourite personFavourite = favouritesService.addFavourite(personId, nodeRef);
ret = getFavourite(personFavourite, parameters);
} else if (target instanceof FolderTarget) {
FolderTarget folderTarget = (FolderTarget) target;
NodeRef nodeRef = folderTarget.getFolder().getGuid();
if (!nodes.nodeMatches(nodeRef, Collections.singleton(ContentModel.TYPE_FOLDER), Collections.singleton(SiteModel.TYPE_SITE))) {
throw new RelationshipResourceNotFoundException(personId, nodeRef.getId());
}
PersonFavourite personFavourite = favouritesService.addFavourite(personId, nodeRef);
ret = getFavourite(personFavourite, parameters);
}
return ret;
}
use of org.alfresco.service.cmr.site.SiteInfo in project alfresco-remote-api by Alfresco.
the class NodesImpl method getActivityInfo.
// note: see also org.alfresco.opencmis.ActivityPosterImpl
protected ActivityInfo getActivityInfo(NodeRef parentNodeRef, NodeRef nodeRef) {
// runAs system, eg. user may not have permission see one or more parents (irrespective of whether in a site context of not)
SiteInfo siteInfo = AuthenticationUtil.runAs(new RunAsWork<SiteInfo>() {
@Override
public SiteInfo doWork() throws Exception {
return siteService.getSite(nodeRef);
}
}, AuthenticationUtil.getSystemUserName());
String siteId = (siteInfo != null ? siteInfo.getShortName() : null);
if (siteId != null && !siteId.equals("")) {
FileInfo fileInfo = fileFolderService.getFileInfo(nodeRef);
if (fileInfo != null) {
boolean isContent = isSubClass(fileInfo.getType(), ContentModel.TYPE_CONTENT);
if (fileInfo.isFolder() || isContent) {
return new ActivityInfo(null, parentNodeRef, siteId, fileInfo);
}
}
} else {
if (logger.isDebugEnabled()) {
logger.debug("Non-site activity, so ignored " + nodeRef);
}
}
return null;
}
Aggregations