org.alfresco.service.cmr.site.SiteInfo Java Examples

The following examples show how to use org.alfresco.service.cmr.site.SiteInfo. 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: SiteExportGet.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Gets the NodeRefs for cm:person nodes in the specified site - excluding admin, guest.
 * @since 4.1.5
 */
private List<NodeRef> getPersonNodesInSiteGroup(SiteInfo site)
{
    // Find the root group
    String siteGroup = AbstractSiteWebScript.buildSiteGroup(site);
    
    // Now get all people in the child groups
    Set<String> siteUsers = authorityService.getContainedAuthorities(
            AuthorityType.USER, siteGroup, false);
    
    // Turn these all into NodeRefs
    List<NodeRef> peopleNodes = new ArrayList<NodeRef>(siteUsers.size());
    for (String authority : siteUsers) 
    {
        if (!USERS_NOT_TO_EXPORT.contains(authority))
        {
            peopleNodes.add(authorityService.getAuthorityNodeRef(authority));
        }
    }
    return peopleNodes;
}
 
Example #2
Source File: SiteServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void testMoveSite_ViaNodeService()
{
    String siteShortName1 = "testMoveSite" + GUID.generate();
    String siteShortName2 = "testMoveSite" + GUID.generate();
    this.siteService.createSite(TEST_SITE_PRESET, siteShortName1, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC);
    this.siteService.createSite(TEST_SITE_PRESET, siteShortName2, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC);
    
    SiteInfo siteInfo1 = this.siteService.getSite(siteShortName1);
    assertNotNull(siteInfo1);
    SiteInfo siteInfo2 = this.siteService.getSite(siteShortName2);
    assertNotNull(siteInfo2);
    
    // move a site through the nodeService - not allowed
    try
    {
        nodeService.moveNode(siteInfo1.getNodeRef(), siteInfo2.getNodeRef(), ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, GUID.generate()));
        fail("Shouldn't be able to move a site via the nodeService");
    }
    catch (AlfrescoRuntimeException expected)
    {
        // Intentionally empty
    }
}
 
Example #3
Source File: SiteServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void testDeleteSite_ViaNodeService()
{
    String siteShortName = "testUpdateSite";
    this.siteService.createSite(TEST_SITE_PRESET, siteShortName, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PUBLIC);
    SiteInfo siteInfo = this.siteService.getSite(siteShortName);
    assertNotNull(siteInfo);
    
    // delete a site through the nodeService - not allowed
    try
    {
        nodeService.deleteNode(siteInfo.getNodeRef());
        fail("Shouldn't be able to delete a site via the nodeService");
    }
    catch (AlfrescoRuntimeException expected)
    {
        // Intentionally empty
    }
}
 
Example #4
Source File: RepoService.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public List<TestSite> getSites(String personId)
{
	List<TestSite> sites = TenantUtil.runAsUserTenant(new TenantRunAsWork<List<TestSite>>()
	{
		@Override
		public List<TestSite> doWork() throws Exception
		{
			List<SiteInfo> results = siteService.listSites(null, null);
			TreeMap<String, TestSite> ret = new TreeMap<String, TestSite>();
			for(SiteInfo siteInfo : results)
			{
				TestSite site = new TestSite(TestNetwork.this, siteInfo/*, null*/);
				ret.put(site.getSiteId(), site);
			}

			return new ArrayList<TestSite>(ret.values());
		}
	}, personId, getId());
	return sites;
}
 
Example #5
Source File: SitesImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public CollectionWithPagingInfo<FavouriteSite> getFavouriteSites(String personId, Parameters parameters)
{
    personId = people.validatePerson(personId);

    Paging paging = parameters.getPaging();
    BeanPropertiesFilter filter = parameters.getFilter();

    PagingResults<SiteInfo> favouriteSites = getFavouriteSites(personId, Util.getPagingRequest(paging));
    List<FavouriteSite> favourites = new ArrayList<FavouriteSite>(favouriteSites.getPage().size());
    for(SiteInfo favouriteSite : favouriteSites.getPage())
    {
        String role = null;
        if(filter.isAllowed(Site.ROLE))
        {
            role = getSiteRole(favouriteSite.getShortName(), personId);
        }
        FavouriteSite favourite = new FavouriteSite(favouriteSite, role);
        favourites.add(favourite);
    }

    return CollectionWithPagingInfo.asPaged(paging, favourites, favouriteSites.hasMoreItems(), favouriteSites.getTotalResultCount().getFirst());
}
 
Example #6
Source File: AbstractFeedCleanerTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@After
public void tearDown() throws Exception
{
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    
    // clean out any remaining feed entries (allows test to be re-runnable)
    feedDAO.deleteFeedEntries(new Date(System.currentTimeMillis()+(120*1000L)));
    
    for (int i = 1; i <= 7; i++)
    {
        SiteInfo site = siteService.getSite("testSite"+i); 
        if (site != null)
        {
            siteService.deleteSite("testSite"+i);
            nodeArchiveService.purgeArchivedNode(nodeArchiveService.getArchivedNode(site.getNodeRef()));
        }
    }
    
    AuthenticationUtil.clearCurrentSecurityContext();
}
 
Example #7
Source File: SiteServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * @see org.alfresco.service.cmr.site.SiteService#createSite(java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean)
 */
public SiteInfo createSite(final String sitePreset, 
                           String passedShortName, 
                           final String title, 
                           final String description, 
                           final boolean isPublic)
{
    // Determine the site visibility
    SiteVisibility visibility = SiteVisibility.PRIVATE;
    if (isPublic == true)
    {
        visibility = SiteVisibility.PUBLIC;
    }
    
    // Create the site
    return createSite(sitePreset, passedShortName, title, description, visibility);
}
 
Example #8
Source File: ForumPostDelete.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
private String doDeleteTopic(TopicInfo topic, SiteInfo site, 
      WebScriptRequest req, JSONObject json, ResourceBundle rb)
{
   // Delete the topic, which removes all its posts too
   discussionService.deleteTopic(topic);
   
   // Add an activity entry for this if it's site based
   if (site != null)
   {
      addActivityEntry("post", "deleted", topic, null, site, req, json);
   }
   
   // All done
   String message = rb.getString(MSG_NODE_DELETED);
   
   return MessageFormat.format(message, topic.getNodeRef());
}
 
Example #9
Source File: SiteServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * @see org.alfresco.service.cmr.site.SiteService#listSites(java.lang.String, int)
 */
public List<SiteInfo> listSites(final String userName, final int size)
{
    // MT share - for activity service remote system callback (deprecated)
    if (tenantService.isEnabled() &&
        TenantUtil.isCurrentDomainDefault() &&
        (AuthenticationUtil.SYSTEM_USER_NAME.equals(AuthenticationUtil.getRunAsUser())) && 
        tenantService.isTenantUser(userName))
    {
        final String tenantDomain = tenantService.getUserDomain(userName);
        
        return TenantUtil.runAsSystemTenant(new TenantRunAsWork<List<SiteInfo>>()
        {
            public List<SiteInfo> doWork() throws Exception
            {
                return listSitesImpl(userName, size);
            }
        }, tenantDomain);
    }
    else
    {
        return listSitesImpl(userName, size);
    }
}
 
Example #10
Source File: SiteServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 #11
Source File: SiteServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Creates a site information object given a site node reference
 * 
 * @param siteNodeRef
 *            site node reference
 * @return SiteInfo site information object
 */
private SiteInfo createSiteInfo(NodeRef siteNodeRef)
{
    SiteInfo siteInfo = null;
    
    // Get the properties
    Map<QName, Serializable> properties = this.directNodeService.getProperties(siteNodeRef);
    String shortName = (String) properties.get(ContentModel.PROP_NAME);
    String sitePreset = (String) properties.get(PROP_SITE_PRESET);
    String title = DefaultTypeConverter.INSTANCE.convert(String.class, properties.get(ContentModel.PROP_TITLE));
    String description = DefaultTypeConverter.INSTANCE.convert(String.class, properties.get(ContentModel.PROP_DESCRIPTION));

    // Get the visibility of the site
    SiteVisibility visibility = getSiteVisibility(siteNodeRef);
    
    // Create and return the site information
    Map<QName, Serializable> customProperties = getSiteCustomProperties(properties);
    
    siteInfo = new SiteInfoImpl(sitePreset, shortName, title, description, visibility, customProperties, siteNodeRef);
    siteInfo.setCreatedDate(DefaultTypeConverter.INSTANCE.convert(Date.class, properties.get(ContentModel.PROP_CREATED)));
    siteInfo.setLastModifiedDate(DefaultTypeConverter.INSTANCE.convert(Date.class, properties.get(ContentModel.PROP_MODIFIED)));
    
    return siteInfo;
}
 
Example #12
Source File: SiteAttributesInitializer.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void initialize(final ContentContext context)
{
    final Object siteAttribute = ContentStoreContext.getContextAttribute(ContentStoreContext.DEFAULT_ATTRIBUTE_SITE);
    if (siteAttribute == null && context instanceof NodeContentContext)
    {
        final NodeRef nodeRef = ((NodeContentContext) context).getNodeRef();
        final SiteInfo site = AuthenticationUtil.runAsSystem(() -> this.siteService.getSite(nodeRef));

        if (site != null)
        {
            ContentStoreContext.setContextAttribute(ContentStoreContext.DEFAULT_ATTRIBUTE_SITE, site.getShortName());
            ContentStoreContext.setContextAttribute(ContentStoreContext.DEFAULT_ATTRIBUTE_SITE_PRESET, site.getSitePreset());
        }
    }
}
 
Example #13
Source File: SiteServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #14
Source File: SitesImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public FavouriteSite getFavouriteSite(String personId, String siteId)
{
    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();
    NodeRef nodeRef = siteInfo.getNodeRef();

    if(favouritesService.isFavourite(personId, nodeRef))
    {
        String role = getSiteRole(siteId, personId);
        return new FavouriteSite(siteInfo, role);
    }
    else
    {
        throw new RelationshipResourceNotFoundException(personId, siteId);
    }
}
 
Example #15
Source File: FavouritesServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private boolean removeFavouriteSite(String userName, NodeRef nodeRef)
  {
  	PrefKeys prefKeys = getPrefKeys(Type.SITE);
boolean exists = false;

SiteInfo siteInfo = siteService.getSite(nodeRef);
if(siteInfo != null)
{
	StringBuilder sitePrefKeyBuilder = new StringBuilder(prefKeys.getSharePrefKey());
	sitePrefKeyBuilder.append(siteInfo.getShortName());
	String sitePrefKey = sitePrefKeyBuilder.toString();

	String siteFavouritedKey = siteFavouritedKey(siteInfo);
	
	exists = preferenceService.getPreference(userName, siteFavouritedKey) != null;
	preferenceService.clearPreferences(userName, sitePrefKey);
}
else
{
	throw new IllegalArgumentException("NodeRef " + nodeRef + " is not a site");
}

  	return exists;
  }
 
Example #16
Source File: AbstractGetBlogWebScript.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Fetches all posts of the given blog
 */
private PagingResults<BlogPostInfo> getBlogPostList(SiteInfo site, NodeRef nonSiteContainer, 
      Date fromDate, Date toDate, String tag, PagingRequest pagingReq)
{
    // Currently we only support CannedQuery-based gets without tags:
    if (tag == null || tag.trim().isEmpty())
    {
        return getBlogResultsImpl(site, nonSiteContainer, fromDate, toDate, pagingReq);
    }
    else
    {
        RangedDateProperty dateRange = new RangedDateProperty(fromDate, toDate, ContentModel.PROP_CREATED);  
        if(site != null)
        {
           return blogService.findBlogPosts(site.getShortName(), dateRange, tag, pagingReq);
        }
        else
        {
           return blogService.findBlogPosts(nonSiteContainer, dateRange, tag, pagingReq);
        }
    }
}
 
Example #17
Source File: SiteTitleDisplayHandler.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public FacetLabel getDisplayLabel(String value)
{
    // Solr returns the site short name encoded
    value = ISO9075.decode(value);
    String title = null;

    if (nonSiteLocationsLabels.containsKey(value))
    {
        title = nonSiteLocationsLabels.get(value);
    }
    else
    {
        SiteService siteService = serviceRegistry.getSiteService();
        SiteInfo siteInfo = siteService.getSite(value);
        title = siteInfo != null ? siteInfo.getTitle() : value;
    }

    return new FacetLabel(value, title, -1);
}
 
Example #18
Source File: SitesImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public SiteMember updateSiteMember(String siteId, SiteMember siteMember)
{
    String siteMemberId = siteMember.getPersonId();
    if(siteMemberId == null)
    {
        throw new InvalidArgumentException("Member id is null");
    }
    siteMemberId = people.validatePerson(siteMemberId);
    SiteInfo siteInfo = validateSite(siteId);
    if(siteInfo == null)
    {
        // site does not exist
        throw new EntityNotFoundException(siteId);
    }
    siteId = siteInfo.getShortName();
    String siteRole = siteMember.getRole();
    if(siteRole == null)
    {
        throw new InvalidArgumentException("Must provide a role");
    }

    /* MNT-10551 : fix */
    if (!siteService.isMember(siteId, siteMember.getPersonId()))
    {
        throw new InvalidArgumentException("User is not a member of the site");
    }

    try
    {
        siteService.setMembership(siteId, siteMember.getPersonId(), siteRole);
    }
    catch (UnknownAuthorityException e)
    {
        throw new InvalidArgumentException("Unknown role '" + siteRole + "'");
    }
    return siteMember;
}
 
Example #19
Source File: CalendarEntryDelete.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected Map<String, Object> executeImpl(SiteInfo site, String eventName,
      WebScriptRequest req, JSONObject json, Status status, Cache cache) 
{
   CalendarEntry entry = calendarService.getCalendarEntry(
         site.getShortName(), eventName);
   
   if (entry == null)
   {
      status.setCode(Status.STATUS_NOT_FOUND);
      return null;
   }
   
   // Special case for "deleting" an instance of a recurring event 
   if (req.getParameter("date") != null && entry.getRecurrenceRule() != null)
   {
      // Have an ignored event generated
      createIgnoreEvent(req, entry);
      
      // Mark as ignored
      status.setCode(Status.STATUS_NO_CONTENT, "Recurring entry ignored");
      return null;
   }
   
   // Delete the calendar entry
   calendarService.deleteCalendarEntry(entry);
   
   // Record this in the activity feed
   addActivityEntry("deleted", entry, site, req, json);

   // All done
   status.setCode(Status.STATUS_NO_CONTENT, "Entry deleted");
   return null;
}
 
Example #20
Source File: TemporarySitesTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test public void ensureTestSitesWereCreatedOk() throws Exception
{
    TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback<Void>()
    {
        public Void execute() throws Throwable
        {
            final SiteInfo recoveredSite1 = SITE_SERVICE.getSite(testSite1.getShortName());
            final SiteInfo recoveredSite2 = SITE_SERVICE.getSite(testSite2.getShortName());
            
            assertNotNull("Test site does not exist", recoveredSite1);
            assertNotNull("Test site does not exist", recoveredSite2);
            
            assertEquals("cm:title was wrong", "t", recoveredSite1.getTitle());
            assertEquals("cm:description was wrong", "d", recoveredSite1.getDescription());
            assertEquals("preset was wrong", "sitePreset", recoveredSite1.getSitePreset());
            
            assertEquals("site visibility was wrong", SiteVisibility.PUBLIC, recoveredSite1.getVisibility());
            
            for (String siteShortName : new String[] { testSite1.getShortName(), testSite2.getShortName() })
            {
                assertNotNull("site had no doclib container node", SITE_SERVICE.getContainer(siteShortName, SiteService.DOCUMENT_LIBRARY));
            }
            
            return null;
        }
    });
}
 
Example #21
Source File: AbstractCommentsWebScript.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * returns SiteInfo needed for post activity
 * @param req
 * @return
 */
protected SiteInfo getSiteInfo(WebScriptRequest req, boolean searchForSiteInJSON)
{
    String siteName = req.getParameter(JSON_KEY_SITE);

    if (siteName == null && searchForSiteInJSON )
    {
        JSONObject json = parseJSON(req);
        if (json != null){
            if (json.containsKey(JSON_KEY_SITE))
            {
                siteName = (String) json.get(JSON_KEY_SITE);
            }
            else if (json.containsKey(JSON_KEY_SITE_ID))
            {
                siteName = (String) json.get(JSON_KEY_SITE_ID);
            }
        }
    }
    if (siteName != null)
    {
        SiteInfo site = siteService.getSite(siteName);
        return site;
    }

    return null;
}
 
Example #22
Source File: ForumPostRepliesPost.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected Map<String, Object> executeImpl(SiteInfo site, NodeRef nodeRef,
      TopicInfo topic, PostInfo post, WebScriptRequest req, JSONObject json,
      Status status, Cache cache) 
{
   // If they're trying to create a reply to a topic, they actually
   //  mean to create the reply on the primary post
   if (post == null)
   {
      post = discussionService.getPrimaryPost(topic);
      if (post == null)
      {
         throw new WebScriptException(Status.STATUS_PRECONDITION_FAILED,
               "First (primary) post was missing from the topic, can't fetch");
      }
   }
   else if (topic == null)
   {
      String error = "Node was of the wrong type, only Topic and Post are supported";
      throw new WebScriptException(Status.STATUS_BAD_REQUEST, error);
   }
   
   // Have the reply created
   PostInfo reply = doCreatePost(post, topic, req, json);
   
   // Add the activity entry for the reply change
   addActivityEntry("reply", "created", topic, reply, site, req, json);
   
   // Build the common model parts
   Map<String, Object> model = buildCommonModel(site, topic, reply, req);
   
   // Build the JSON for the new reply post
   model.put(KEY_POSTDATA, renderPost(reply, site));
   
   // All done
   return model;
}
 
Example #23
Source File: FavouritesServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private String siteCreatedAtKey(SiteInfo siteInfo)
  {
  	PrefKeys prefKeys = getPrefKeys(Type.SITE);

StringBuilder sitePrefKeyBuilder = new StringBuilder(prefKeys.getAlfrescoPrefKey());
sitePrefKeyBuilder.append(siteInfo.getShortName());
String sitePrefKey = sitePrefKeyBuilder.toString();

StringBuilder createdAtKeyBuilder = new StringBuilder(sitePrefKey);
createdAtKeyBuilder.append(".createdAt");
String createdAtKey = createdAtKeyBuilder.toString();
return createdAtKey;
  }
 
Example #24
Source File: RepoService.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public TestSite getSiteNonMember(final String personId)
{
	return TenantUtil.runAsSystemTenant(new TenantRunAsWork<TestSite>()
	{
		@Override
		public TestSite doWork() throws Exception
		{
			TestSite ret = null;
			SiteInfo match = null;
			for(SiteInfo info : siteService.listSites(null, null))
			{
				boolean isMember = siteService.isMember(info.getShortName(), personId);
				if(!isMember)
				{
					match = info;
					break;
				}
			}
			
			if(match != null)
			{
				ret = new TestSite(TestNetwork.this, match);
			}
			
			return ret;
		}
	}, getId());
}
 
Example #25
Source File: SitesImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 #26
Source File: InvitationServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Generates a description for the workflow
 * 
 * @param siteInfo The site to generate a description for
 * @param messageId The resource bundle key to use for the description 
 * @return The workflow description
 */
protected String generateWorkflowDescription(SiteInfo siteInfo, String messageId)
{
    String siteTitle = siteInfo.getTitle();
    if (siteTitle == null || siteTitle.length() == 0)
    {
        siteTitle = siteInfo.getShortName();
    }
    
    Locale locale = (Locale) this.nodeService.getProperty(siteInfo.getNodeRef(), ContentModel.PROP_LOCALE);
    
    return I18NUtil.getMessage(messageId, locale == null ? I18NUtil.getLocale() : locale, siteTitle);
}
 
Example #27
Source File: InvitationServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Moderated invitation implementation
 * 
 * @return the new moderated invitation
 */
private ModeratedInvitation startModeratedInvite(String inviteeComments, String inviteeUserName,
            Invitation.ResourceType resourceType, String resourceName, String inviteeRole)
{
    SiteInfo siteInfo = siteService.getSite(resourceName);

    if (siteService.isMember(resourceName, inviteeUserName))
    {
        if (logger.isDebugEnabled())
            logger.debug("Failed - invitee user is already a member of the site.");

        Object objs[] = { inviteeUserName, "", resourceName };
        throw new InvitationExceptionUserError("invitation.invite.already_member", objs);
    }

    String roleGroup = siteService.getSiteRoleGroup(resourceName, SiteModel.SITE_MANAGER);

    // get the workflow description
    String workflowDescription = generateWorkflowDescription(siteInfo, "invitation.moderated.workflow.description");
    
    Map<QName, Serializable> workflowProps = new HashMap<QName, Serializable>(16);
    workflowProps.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, workflowDescription);
    workflowProps.put(WorkflowModelModeratedInvitation.ASSOC_GROUP_ASSIGNEE, roleGroup);
    workflowProps.put(WorkflowModelModeratedInvitation.WF_PROP_INVITEE_COMMENTS, inviteeComments);
    workflowProps.put(WorkflowModelModeratedInvitation.WF_PROP_INVITEE_ROLE, inviteeRole);
    workflowProps.put(WorkflowModelModeratedInvitation.WF_PROP_INVITEE_USER_NAME, inviteeUserName);
    workflowProps.put(WorkflowModelModeratedInvitation.WF_PROP_RESOURCE_NAME, resourceName);
    workflowProps.put(WorkflowModelModeratedInvitation.WF_PROP_RESOURCE_TYPE, resourceType.toString());

    // get the moderated workflow

    WorkflowDefinition wfDefinition = getWorkflowDefinition(InvitationWorkflowType.MODERATED);
    return (ModeratedInvitation) startWorkflow(wfDefinition, workflowProps);
}
 
Example #28
Source File: InviteSender.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected String getSiteName(Map<String, String> properties)
{
    String siteFullName = properties.get(getWorkflowPropForSiteName());
    SiteInfo site = siteService.getSite(siteFullName);
    if (site == null)
        throw new InvitationException("The site " + siteFullName + " could not be found.");

    String siteName = site.getShortName();
    String siteTitle = site.getTitle();
    if (siteTitle != null && siteTitle.length() > 0)
    {
        siteName = siteTitle;
    }
    return siteName;
}
 
Example #29
Source File: SiteServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Create a private site.
 *
 * Attempt to access a private site by someone that is not a consumer of that site.
 * 
 */
@Test
public void testETHREEOH_1268()
{
    RetryingTransactionCallback<Object> work = new RetryingTransactionCallback<Object>()
    {

        @Override
        public Object execute() throws Throwable
        {
            // USER_ONE - SiteManager
            // GROUP_TWO - Manager

            String siteName = "testALFCOM_XXXX" + UUID.randomUUID();

            // Create a site as user one
            siteService.createSite(TEST_SITE_PRESET, siteName, TEST_TITLE, TEST_DESCRIPTION, SiteVisibility.PRIVATE);

            SiteInfo si = siteService.getSite(siteName);

            assertNotNull("site info is null", si);

            authenticationComponent.setCurrentUser(USER_TWO);

            si = siteService.getSite(siteName);

            assertNull("site info is not null", si);

            authenticationComponent.setSystemUserAsCurrentUser();
            siteService.deleteSite(siteName);
            
            return null;
        }
    };
    transactionService.getRetryingTransactionHelper().doInTransaction(work);
}
 
Example #30
Source File: BlogPostGet.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected Map<String, Object> executeImpl(SiteInfo site, NodeRef nodeRef,
     BlogPostInfo blog, WebScriptRequest req, JSONObject json, Status status, Cache cache) 
{
    if (blog == null)
    {
       throw new WebScriptException(Status.STATUS_NOT_FOUND, "Blog Post Not Found");
    }

    // Build the response
    Map<String, Object> model = new HashMap<String, Object>();
    
    // TODO Fetch this from the BlogPostInfo object
    NodeRef node = blog.getNodeRef();
    Map<String, Object> item = BlogPostLibJs.getBlogPostData(node, services);
    model.put(ITEM, item);
    model.put(POST, blog);
    
    model.put("externalBlogConfig", BlogPostLibJs.hasExternalBlogConfiguration(node, services));
    
    int contentLength = -1;
    String arg = req.getParameter("contentLength");
    if (arg != null)
    {
        try
        {
            contentLength = Integer.parseInt(arg);
        }
        catch (NumberFormatException ignored)
        {
            // Intentionally empty
        }
    }
    
    model.put("contentLength", contentLength);
    
    return model;
}