Java Code Examples for org.alfresco.service.cmr.site.SiteInfo#getNodeRef()
The following examples show how to use
org.alfresco.service.cmr.site.SiteInfo#getNodeRef() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SiteServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testJSAPI() throws Exception { // Create a site with a custom property SiteInfo siteInfo = this.siteService.createSite(TEST_SITE_PRESET, "mySiteWithCustomProperty", TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC); NodeRef siteNodeRef = siteInfo.getNodeRef(); Map<QName, Serializable> properties = new HashMap<QName, Serializable>(1); properties.put(QName.createQName(SiteModel.SITE_CUSTOM_PROPERTY_URL, "additionalInformation"), "information"); this.nodeService.addAspect(siteNodeRef, QName.createQName(SiteModel.SITE_MODEL_URL, "customSiteProperties"), properties); // Create a model to pass to the unit test scripts Map<String, Object> model = new HashMap<String, Object>(); model.put("customSiteName", "mySiteWithCustomProperty"); model.put("preexistingSiteCount", siteService.listSites(null, null).size()); // Execute the unit test script ScriptLocation location = new ClasspathScriptLocation("org/alfresco/repo/site/script/test_siteService.js"); this.scriptService.executeScript(location, model); }
Example 2
Source File: SiteServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testRenameSite() { // test that changing the name of a site generates an appropriate exception try { String siteName = GUID.generate(); SiteInfo siteInfo = createSite(siteName, "doclib", SiteVisibility.PUBLIC); NodeRef childRef = siteInfo.getNodeRef(); Map<QName, Serializable> props = new HashMap<QName, Serializable>(); props.put(ContentModel.PROP_NAME, siteName + "Renamed"); nodeService.addProperties(childRef, props); fail("Should have caught rename"); } catch(SiteServiceException e) { assertTrue(e.getMessage().contains("can not be renamed")); } }
Example 3
Source File: FavouritesServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private PersonFavourite addFavouriteSite(String userName, NodeRef nodeRef) { PersonFavourite favourite = null; SiteInfo siteInfo = siteService.getSite(nodeRef); if(siteInfo != null) { favourite = getFavouriteSite(userName, siteInfo); if(favourite == null) { Map<String, Serializable> preferences = new HashMap<String, Serializable>(1); String siteFavouritedKey = siteFavouritedKey(siteInfo); preferences.put(siteFavouritedKey, Boolean.TRUE); // ISO8601 string format: PreferenceService works with strings only for dates it seems String siteCreatedAtKey = siteCreatedAtKey(siteInfo); Date createdAt = new Date(); String createdAtStr = ISO8601DateFormat.format(createdAt); preferences.put(siteCreatedAtKey, createdAtStr); preferenceService.setPreferences(userName, preferences); favourite = new PersonFavourite(userName, siteInfo.getNodeRef(), Type.SITE, siteInfo.getTitle(), createdAt); QName nodeClass = nodeService.getType(nodeRef); OnAddFavouritePolicy policy = onAddFavouriteDelegate.get(nodeRef, nodeClass); policy.onAddFavourite(userName, nodeRef); } } else { // shouldn't happen, getType recognizes it as a site or subtype logger.warn("Unable to get site for " + nodeRef); } return favourite; }
Example 4
Source File: SitesImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
/** * people/<personId>/sites/<siteId> * * @param siteId String * @param personId String * @return MemberOfSite */ public MemberOfSite getMemberOfSite(String personId, String siteId) { MemberOfSite siteMember = null; personId = people.validatePerson(personId); SiteInfo siteInfo = validateSite(siteId); if(siteInfo == null) { // site does not exist throw new RelationshipResourceNotFoundException(personId, siteId); } // set the site id to the short name (to deal with case sensitivity issues with using the siteId from the url) siteId = siteInfo.getShortName(); String roleStr = siteService.getMembersRole(siteInfo.getShortName(), personId); if(roleStr != null) { Site site = new Site(siteInfo, roleStr); siteMember = new MemberOfSite(site.getId(), siteInfo.getNodeRef(), roleStr); } else { throw new RelationshipResourceNotFoundException(personId, siteId); } return siteMember; }
Example 5
Source File: SiteMembershipRequestsImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
private SiteMembershipRequest inviteToPublicSite(final SiteInfo siteInfo, final String message, final String inviteeId, final String inviteeRole) { SiteMembershipRequest siteMembershipRequest = null; final String siteId = siteInfo.getShortName(); NodeRef siteNodeRef = siteInfo.getNodeRef(); String siteCreator = (String)nodeService.getProperty(siteNodeRef, ContentModel.PROP_CREATOR); final String siteNetwork = networksService.getUserDefaultNetwork(siteCreator); if(StringUtils.isNotEmpty(siteNetwork)) { // MT siteMembershipRequest = TenantUtil.runAsUserTenant(new TenantRunAsWork<SiteMembershipRequest>() { @Override public SiteMembershipRequest doWork() throws Exception { return inviteToSite(siteId, inviteeId, inviteeRole, message); } }, siteCreator, siteNetwork); } else { siteMembershipRequest = AuthenticationUtil.runAs(new RunAsWork<SiteMembershipRequest>() { @Override public SiteMembershipRequest doWork() throws Exception { return inviteToSite(siteId, inviteeId, inviteeRole, message); } }, siteCreator); } return siteMembershipRequest; }
Example 6
Source File: SitesImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public void deleteSite(String siteId, Parameters parameters) { boolean isSiteAdmin = siteService.isSiteAdmin(AuthenticationUtil.getFullyAuthenticatedUser()); SiteInfo siteInfo = validateSite(siteId); if (siteInfo == null) { // site does not exist throw new EntityNotFoundException(siteId); } siteId = siteInfo.getShortName(); NodeRef siteNodeRef = siteInfo.getNodeRef(); // belt-and-braces - double-check before purge/delete (rather than // rollback) if ((isSiteAdmin == false) && (permissionService.hasPermission(siteNodeRef, PermissionService.DELETE) != AccessStatus.ALLOWED)) { throw new AccessDeniedException("Cannot delete site: " + siteId); } // default false (if not provided) boolean permanentDelete = Boolean.valueOf(parameters.getParameter(PARAM_PERMANENT)); if (permanentDelete == true) { // Set as temporary to delete node instead of archiving. nodeService.addAspect(siteNodeRef, ContentModel.ASPECT_TEMPORARY, null); // bypassing trashcan means that purge behaviour will not fire, so // explicitly force cleanup here siteServiceImpl.beforePurgeNode(siteNodeRef); } siteService.deleteSite(siteId); }
Example 7
Source File: ReadOnlyTransactionInGetRestApiTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); ApplicationContext appContext = getServer().getApplicationContext(); this.siteService = (SiteService)appContext.getBean("SiteService"); this.nodeService = (NodeService)appContext.getBean("NodeService"); this.transactionService = (TransactionService)appContext.getBean("TransactionService"); this.nodeArchiveService = (NodeArchiveService)getServer().getApplicationContext().getBean("nodeArchiveService"); // set admin as current user AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); // delete the test site if it's still hanging around from previous runs SiteInfo site = siteService.getSite(TEST_SITE_NAME); if (site != null) { siteService.deleteSite(TEST_SITE_NAME); nodeArchiveService.purgeArchivedNode(nodeArchiveService.getArchivedNode(site.getNodeRef())); } // create the test site, this should create a site but it won't have any containers created SiteInfo siteInfo = this.siteService.createSite("collaboration", TEST_SITE_NAME, "Read Only Test Site", "Test site for ReadOnlyTransactionRestApiTest", SiteVisibility.PUBLIC); this.testSiteNodeRef = siteInfo.getNodeRef(); this.testSiteNodeRefString = this.testSiteNodeRef.toString().replace("://", "/"); // ensure there are no containers present at the start of the test List<ChildAssociationRef> children = nodeService.getChildAssocs(this.testSiteNodeRef); assertTrue("The test site should not have any containers", children.isEmpty()); }
Example 8
Source File: SiteServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void testCustomSiteProperties() { QName additionalInformationQName = QName.createQName(SiteModel.SITE_CUSTOM_PROPERTY_URL, "additionalInformation"); // Create a site String siteShortName = "mySiteTest" + UUID.randomUUID(); SiteInfo siteInfo = this.siteService.createSite(TEST_SITE_PRESET, siteShortName, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC); checkSiteInfo(siteInfo, TEST_SITE_PRESET, siteShortName, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC); assertNull(siteInfo.getCustomProperty(additionalInformationQName)); assertNotNull(siteInfo.getCustomProperties()); assertTrue(siteInfo.getCustomProperties().isEmpty()); // Add an aspect with a custom property NodeRef siteNodeRef = siteInfo.getNodeRef(); Map<QName, Serializable> properties = new HashMap<QName, Serializable>(1); properties.put(additionalInformationQName, "information"); this.nodeService.addAspect(siteNodeRef, QName.createQName(SiteModel.SITE_MODEL_URL, "customSiteProperties"), properties); // Get the site again siteInfo = this.siteService.getSite(siteShortName); assertNotNull(siteInfo); assertEquals("information", siteInfo.getCustomProperty(additionalInformationQName)); assertNotNull(siteInfo.getCustomProperties()); assertFalse(siteInfo.getCustomProperties().isEmpty()); assertEquals(1, siteInfo.getCustomProperties().size()); assertEquals("information", siteInfo.getCustomProperties().get(additionalInformationQName)); }
Example 9
Source File: FavouritesServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private void extractFavouriteSite(String userName, Type type, Map<PersonFavouriteKey, PersonFavourite> sortedFavouriteNodes, Map<String, Serializable> preferences, String key) { // preference value indicates whether the site has been favourited Serializable pref = preferences.get(key); Boolean isFavourite = (Boolean)pref; if(isFavourite) { PrefKeys sitePrefKeys = getPrefKeys(Type.SITE); int length = sitePrefKeys.getSharePrefKey().length(); String siteId = key.substring(length); try { SiteInfo siteInfo = siteService.getSite(siteId); if(siteInfo != null) { StringBuilder builder = new StringBuilder(sitePrefKeys.getAlfrescoPrefKey()); builder.append(siteId); builder.append(".createdAt"); String createdAtPrefKey = builder.toString(); String createdAtStr = (String)preferences.get(createdAtPrefKey); Date createdAt = null; if(createdAtStr != null) { createdAt = (createdAtStr != null ? ISO8601DateFormat.parse(createdAtStr): null); } PersonFavourite personFavourite = new PersonFavourite(userName, siteInfo.getNodeRef(), Type.SITE, siteId, createdAt); sortedFavouriteNodes.put(personFavourite.getKey(), personFavourite); } } catch(AccessDeniedException ex) { // the user no longer has access to this site, skip over the favourite // TODO remove the favourite preference return; } } }
Example 10
Source File: FavouritesServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private PersonFavourite getFavouriteSite(String userName, SiteInfo siteInfo) { PersonFavourite favourite = null; String siteFavouritedKey = siteFavouritedKey(siteInfo); String siteCreatedAtKey = siteCreatedAtKey(siteInfo); Boolean isFavourited = false; Serializable s = preferenceService.getPreference(userName, siteFavouritedKey); if(s != null) { if(s instanceof String) { isFavourited = Boolean.valueOf((String)s); } else if(s instanceof Boolean) { isFavourited = (Boolean)s; } else { throw new AlfrescoRuntimeException("Unexpected favourites preference value"); } } if(isFavourited) { String createdAtStr = (String)preferenceService.getPreference(userName, siteCreatedAtKey); Date createdAt = (createdAtStr == null ? null : ISO8601DateFormat.parse(createdAtStr)); favourite = new PersonFavourite(userName, siteInfo.getNodeRef(), Type.SITE, siteInfo.getTitle(), createdAt); } return favourite; }
Example 11
Source File: SWSDPPatch.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected String applyInternal() throws Exception { SiteInfo siteInfo = siteService.getSite("swsdp"); if(siteInfo != null) { NodeRef nodeRef = siteInfo.getNodeRef(); NodeRef surfConfigNodeRef = nodeService.getChildByName(nodeRef, ContentModel.ASSOC_CONTAINS, "surf-config"); if(surfConfigNodeRef == null) { return I18NUtil.getMessage(MSG_MISSING_SURFCONFIG); } else { for(ChildAssociationRef childRef : nodeService.getChildAssocs(surfConfigNodeRef, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL)) { hiddenAspect.showNode(childRef.getChildRef(), true); } } return I18NUtil.getMessage(MSG_SITE_PATCHED); } else { return I18NUtil.getMessage(MSG_SKIPPED); } }
Example 12
Source File: DiscussionRestApiTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected void setUp() throws Exception { super.setUp(); this.authenticationService = (MutableAuthenticationService)getServer().getApplicationContext().getBean("AuthenticationService"); this.authenticationComponent = (AuthenticationComponent)getServer().getApplicationContext().getBean("authenticationComponent"); this.policyBehaviourFilter = (BehaviourFilter)getServer().getApplicationContext().getBean("policyBehaviourFilter"); this.transactionService = (TransactionService)getServer().getApplicationContext().getBean("transactionService"); this.permissionService = (PermissionService)getServer().getApplicationContext().getBean("PermissionService"); this.personService = (PersonService)getServer().getApplicationContext().getBean("PersonService"); this.siteService = (SiteService)getServer().getApplicationContext().getBean("SiteService"); this.nodeService = (NodeService)getServer().getApplicationContext().getBean("NodeService"); this.internalNodeService = (NodeService)getServer().getApplicationContext().getBean("nodeService"); this.nodeArchiveService = (NodeArchiveService)getServer().getApplicationContext().getBean("nodeArchiveService"); // 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_DISCUSSION); if (siteInfo == null) { siteInfo = this.siteService.createSite("DiscussionSitePreset", SITE_SHORT_NAME_DISCUSSION, "DiscussionSiteTitle", "DiscussionSiteDescription", SiteVisibility.PUBLIC); } final NodeRef siteNodeRef = siteInfo.getNodeRef(); // Create the forum final String forumNodeName = "TestForum"; FORUM_NODE = nodeService.getChildByName(siteInfo.getNodeRef(), ContentModel.ASSOC_CONTAINS, forumNodeName); if (FORUM_NODE == null) { FORUM_NODE = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<NodeRef>() { @Override public NodeRef execute() throws Throwable { Map<QName, Serializable> props = new HashMap<QName, Serializable>(5); props.put(ContentModel.PROP_NAME, forumNodeName); props.put(ContentModel.PROP_TITLE, forumNodeName); return nodeService.createNode( siteNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(forumNodeName), ForumModel.TYPE_FORUM, props ).getChildRef(); } }); } // Create users createUser(USER_ONE, SiteModel.SITE_COLLABORATOR, SITE_SHORT_NAME_DISCUSSION); createUser(USER_TWO, SiteModel.SITE_CONTRIBUTOR, SITE_SHORT_NAME_DISCUSSION); // Do tests as inviter user this.authenticationComponent.setCurrentUser(USER_ONE); }
Example 13
Source File: SiteServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Gets the authorities and their allowed permissions for a site root */ private Map<String, Set<String>> getAllowedPermissionsMap(SiteInfo site) { NodeRef nodeRef = site.getNodeRef(); return getAllowedPermissionsMap(nodeRef); }
Example 14
Source File: TemporaryNodesTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** Site nodes are a special case as they can only be deleted through the SiteService. */ @Test public void ensureSiteNodesAreCleanedUp() throws Throwable { // Note that because we need to test that the Rule's 'after' behaviour has worked correctly, we cannot // use the Rule that has been declared in the normal way - otherwise nothing would be cleaned up until // after our test method. // Therefore we have to manually poke the Rule to get it to cleanup during test execution. // NOTE! This is *not* how a JUnit Rule would normally be used. TemporaryNodes myTemporaryNodes = new TemporaryNodes(APP_CONTEXT_INIT); // Currently this is a no-op, but just in case that changes. myTemporaryNodes.before(); // and ensure that the site node is gone. SiteInfo createdSite = TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback<SiteInfo>() { public SiteInfo execute() throws Throwable { return SITE_SERVICE.createSite("sitePreset", SITE_SHORT_NAME, "site title", "site description", SiteVisibility.PUBLIC); } }); final NodeRef siteNodeRef = createdSite.getNodeRef(); myTemporaryNodes.addNodeRef(siteNodeRef); // Now trigger the Rule's cleanup behaviour. myTemporaryNodes.after(); // and ensure that the site node is gone. TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback<Void>() { public Void execute() throws Throwable { if (NODE_SERVICE.exists(siteNodeRef)) { fail("Node '" + NODE_SERVICE.getProperty(siteNodeRef, ContentModel.PROP_NAME) + "' still exists."); } return null; } }); }
Example 15
Source File: SiteServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * This test method ensures that public sites can be created and that their site info is correct. * It also tests that a duplicate site cannot be created. */ @Test public void testCreateSite() throws Exception { // Create a public site String mySiteTest = "mySiteTest" + UUID.randomUUID(); SiteInfo siteInfo = this.siteService.createSite(TEST_SITE_PRESET, mySiteTest, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC); checkSiteInfo(siteInfo, TEST_SITE_PRESET, mySiteTest, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC); String name = "!£$%^&*()_+=-[]{}"; //Calls deprecated method (still creates a public Site) siteInfo = this.siteService.createSite(TEST_SITE_PRESET, name, TEST_TITLE, TEST_DESCRIPTION, true); checkSiteInfo(siteInfo, TEST_SITE_PRESET, name, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC); siteInfo = this.siteService.getSite(name); checkSiteInfo(siteInfo, TEST_SITE_PRESET, name, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC); name = "éÃóúÃ�ÉÃ�ÓÚ"; siteInfo = this.siteService.createSite(TEST_SITE_PRESET, name, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC); checkSiteInfo(siteInfo, TEST_SITE_PRESET, name, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC); siteInfo = this.siteService.getSite(name); checkSiteInfo(siteInfo, TEST_SITE_PRESET, name, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC); NodeRef siteNodeRef = siteInfo.getNodeRef(); assertEquals(siteInfo.getShortName(), this.siteService.getSiteShortName(siteNodeRef)); // Localize the title and description Locale locale = Locale.getDefault(); try { I18NUtil.setLocale(Locale.FRENCH); nodeService.setProperty(siteNodeRef, ContentModel.PROP_TITLE, "Localized-title"); nodeService.setProperty(siteNodeRef, ContentModel.PROP_DESCRIPTION, "Localized-description"); siteInfo = this.siteService.getSite(name); checkSiteInfo(siteInfo, TEST_SITE_PRESET, name, "Localized-title", "Localized-description", SiteVisibility.PUBLIC); } finally { I18NUtil.setLocale(locale); } // Test for duplicate site error try { this.siteService.createSite(TEST_SITE_PRESET, mySiteTest, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC); fail("Shouldn't allow duplicate site short names."); } catch (AlfrescoRuntimeException exception) { // Expected } try { //Create a site with an invalid site type this.siteService.createSite(TEST_SITE_PRESET, "InvalidSiteType", TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC, ServiceRegistry.CMIS_SERVICE); fail("Shouldn't allow invalid site type."); } catch (SiteServiceException ssexception) { // Expected } }
Example 16
Source File: SiteServiceTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
public void testSiteCustomProperties() throws Exception { QName custPropSingle = QName.createQName(SiteModel.SITE_CUSTOM_PROPERTY_URL, "additionalInformation"); QName custPropMuliple = QName.createQName(SiteModel.SITE_CUSTOM_PROPERTY_URL, "siteTags"); // Create a site with custom properties, one single and one multiple SiteInfo siteInfo = this.siteService.createSite("testPreset", "mySiteWithCustomProperty2", "testTitle", "testDescription", SiteVisibility.PUBLIC); NodeRef siteNodeRef = siteInfo.getNodeRef(); Map<QName, Serializable> properties = new HashMap<QName, Serializable>(1); properties.put(custPropSingle, "information"); properties.put(custPropMuliple, (Serializable)Arrays.asList(new String[]{ "tag1", "tag2", "tag333" })); this.nodeService.addAspect(siteNodeRef, QName.createQName(SiteModel.SITE_MODEL_URL, "customSiteProperties"), properties); this.createdSites.add("mySiteWithCustomProperty2"); // Get the detail so of the site Response response = sendRequest(new GetRequest(URL_SITES + "/mySiteWithCustomProperty2"), 200); JSONObject result = new JSONObject(response.getContentAsString()); assertNotNull(result); JSONObject customProperties = result.getJSONObject("customProperties"); assertNotNull(customProperties); JSONObject addInfo = customProperties.getJSONObject("{http://www.alfresco.org/model/sitecustomproperty/1.0}additionalInformation"); assertNotNull(addInfo); assertEquals("{http://www.alfresco.org/model/sitecustomproperty/1.0}additionalInformation", addInfo.get("name")); assertEquals("information", addInfo.get("value")); assertEquals("{http://www.alfresco.org/model/dictionary/1.0}text", addInfo.get("type")); assertEquals("Additional Site Information", addInfo.get("title")); JSONObject tags = customProperties.getJSONObject("{http://www.alfresco.org/model/sitecustomproperty/1.0}siteTags"); assertNotNull(tags); assertEquals("{http://www.alfresco.org/model/sitecustomproperty/1.0}siteTags", tags.get("name")); assertEquals(JSONObject.NULL, tags.get("type")); assertEquals(JSONObject.NULL, tags.get("title")); // TODO Fix ALF-2707 so this works System.err.println(response.getContentAsString()); // JSONArray tagsA = tags.getJSONArray("value"); // assertEquals(3, tagsA.length()); // assertEquals("tag1", tagsA.getString(0)); // assertEquals("tag2", tagsA.getString(1)); // assertEquals("tag333", tagsA.getString(2)); }
Example 17
Source File: SitesImpl.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
/** * Create default/fixed preset (Share) site - with DocLib container/component * * @param site * @return */ public Site createSite(Site site, Parameters parameters) { // note: if site id is null then will be generated from the site title site = validateSite(site); SiteInfo siteInfo = null; try { siteInfo = createSite(site); } catch (SiteServiceException sse) { if (sse.getMsgId().equals("site_service.unable_to_create")) { throw new ConstraintViolatedException(sse.getMessage()); } else { throw sse; } } String siteId = siteInfo.getShortName(); NodeRef siteNodeRef = siteInfo.getNodeRef(); // default false (if not provided) boolean skipShareSurfConfig = Boolean.valueOf(parameters.getParameter(PARAM_SKIP_SURF_CONFIGURATION)); if (skipShareSurfConfig == false) { // import default/fixed preset Share surf config importSite(siteId, siteNodeRef); } // pre-create doclib siteService.createContainer(siteId, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null); // default false (if not provided) boolean skipAddToFavorites = Boolean.valueOf(parameters.getParameter(PARAM_SKIP_ADDTOFAVORITES)); if (skipAddToFavorites == false) { String personId = AuthenticationUtil.getFullyAuthenticatedUser(); favouritesService.addFavourite(personId, siteNodeRef); // ignore result } return getSite(siteInfo, true); }
Example 18
Source File: ForumTopicsMineGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected Map<String, Object> executeImpl(SiteInfo site, NodeRef nodeRef, TopicInfo topic, PostInfo post, WebScriptRequest req, JSONObject json, Status status, Cache cache) { // They shouldn't be trying to list of an existing Post or Topic if (topic != null || post != null) { String error = "Can't list Topics inside an existing Topic or Post"; throw new WebScriptException(Status.STATUS_BAD_REQUEST, error); } // Grab the current user to list for String username = AuthenticationUtil.getFullyAuthenticatedUser(); // Get the topics for the user, oldest first PagingResults<TopicInfo> topics = null; PagingRequest paging = buildPagingRequest(req); if (site != null) { topics = discussionService.listTopics(site.getShortName(), username, true, paging); } else { topics = discussionService.listTopics(nodeRef, username, true, paging); } // If they did a site based search, and the component hasn't // been created yet, use the site for the permissions checking if (site != null && nodeRef == null) { nodeRef = site.getNodeRef(); } // Build the common model parts Map<String, Object> model = buildCommonModel(site, topic, post, req); model.put("forum", nodeRef); // Have the topics rendered model.put("data", renderTopics(topics, paging, site)); // All done return model; }
Example 19
Source File: ForumTopicsHotGet.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
@Override protected Map<String, Object> executeImpl(SiteInfo site, NodeRef nodeRef, TopicInfo topic, PostInfo post, WebScriptRequest req, JSONObject json, Status status, Cache cache) { // They shouldn't be trying to list of an existing Post or Topic if (topic != null || post != null) { String error = "Can't list Topics inside an existing Topic or Post"; throw new WebScriptException(Status.STATUS_BAD_REQUEST, error); } // Grab the date range to search over String numDaysS = req.getParameter("numdays"); int numDays = RECENT_POSTS_PERIOD_DAYS; if (numDaysS != null) { numDays = Integer.parseInt(numDaysS); } Date now = new Date(); Date since = new Date(now.getTime() - numDays*ONE_DAY_MS); // Get the topics with recent replies PagingResults<Pair<TopicInfo,Integer>> topicsAndCounts = null; PagingRequest paging = buildPagingRequest(req); if (site != null) { topicsAndCounts = discussionService.listHotTopics(site.getShortName(), since, paging); } else { topicsAndCounts = discussionService.listHotTopics(nodeRef, since, paging); } // For this, we actually only need the topics, not their counts too List<TopicInfo> topics = new ArrayList<TopicInfo>(); for (Pair<TopicInfo,Integer> tc : topicsAndCounts.getPage()) { topics.add(tc.getFirst()); } // If they did a site based search, and the component hasn't // been created yet, use the site for the permissions checking if (site != null && nodeRef == null) { nodeRef = site.getNodeRef(); } // Build the common model parts Map<String, Object> model = buildCommonModel(site, topic, post, req); model.put("forum", nodeRef); // Have the topics rendered model.put("data", renderTopics(topics, topicsAndCounts.getTotalResultCount(), paging, site)); // All done return model; }
Example 20
Source File: MemberOfSite.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
public static MemberOfSite getMemberOfSite(SiteInfo siteInfo, String siteRole) { MemberOfSite memberOfSite = new MemberOfSite(siteInfo.getShortName(), siteInfo.getNodeRef(), siteRole); return memberOfSite; }