Java Code Examples for org.alfresco.service.cmr.site.SiteInfo#getTitle()

The following examples show how to use org.alfresco.service.cmr.site.SiteInfo#getTitle() . 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: 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 2
Source File: AbstractUserNotifier.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void addSiteName(String siteId, Map<String, String> siteNames)
{
    if (siteId == null)
    {
        return;
    }
    
    String siteName = siteNames.get(siteId);
    if (siteName == null)
    {
        SiteInfo site = siteService.getSite(siteId);
        if (site == null)
        {
            return;
        }
        
        String siteTitle = site.getTitle();
        if (siteTitle != null && siteTitle.length() > 0)
        {
            siteName = siteTitle;
        }
        else
        {
            siteName = siteId;
        }
        
        siteNames.put(siteId, siteName);
    }
}
 
Example 3
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 4
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 5
Source File: FavouritesServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 6
Source File: FavouritesServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 7
Source File: SiteImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public SiteImpl(SiteInfo siteInfo, SiteRole siteRole, Boolean created)
{
    this.siteId = siteInfo.getShortName();
    this.description = siteInfo.getDescription();
    this.title = siteInfo.getTitle();
    this.visibility = siteInfo.getVisibility().toString();
    this.created = created;
    this.guid = siteInfo.getNodeRef().getId();
}
 
Example 8
Source File: SiteMembershipComparator.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public int compare(SiteMembership o1, SiteMembership o2)
{
    String personId1 = o1.getPersonId();
    String personId2 = o2.getPersonId();
    SiteInfo siteInfo1 = o1.getSiteInfo();
    SiteInfo siteInfo2 = o2.getSiteInfo();
    String shortName1 = siteInfo1.getShortName();
    String shortName2 = siteInfo2.getShortName();
    String firstName1 = o1.getFirstName();
    String firstName2 = o2.getFirstName();
    String lastName1 = o1.getLastName();
    String lastName2 = o2.getLastName();
    String siteRole1 = o1.getRole();
    String siteRole2 = o2.getRole();
    String siteTitle1 = siteInfo1.getTitle();
    String siteTitle2 = siteInfo2.getTitle();

    int personId = safeCompare(personId1, personId2);
    int firstName = safeCompare(firstName1, firstName2);
    int siteShortName = safeCompare(shortName1, shortName2);
    int lastName = safeCompare(lastName1, lastName2);
    int siteRole = safeCompare(siteRole1, siteRole2);
    int siteTitle = safeCompare(siteTitle1, siteTitle2);

    if (siteRole == 0 && siteShortName == 0 && personId == 0)
    {
        // equals contract
        return 0;
    }

    int ret = 0;

    switch (comparatorType)
    {
        case SITES:
        {
            ret = compareSitesBody(shortName1, shortName2, siteRole1, siteRole2, siteTitle1, siteTitle2, siteShortName, siteRole, siteTitle, ret);
            break;
        }
        case MEMBERS:
        {
            ret = compareMembersBody(personId1, personId2, lastName1, lastName2, siteRole1, siteRole2, personId, firstName, lastName, siteRole, ret);
            break;
        }
    }
    
    return ret;
}
 
Example 9
Source File: RepoService.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
public TestSite(TestNetwork account, SiteInfo siteInfo)
{
	this(account, siteInfo.getShortName(), siteInfo.getNodeRef().getId(), siteInfo.getTitle(), siteInfo.getDescription(), siteInfo.getVisibility());
	this.account = account;
	this.siteInfo = siteInfo;
}