()
+ {
+ public NodeRef doWork() throws Exception
+ {
+ NodeRef workingCopy = copyService.copy(
+ nodeRef,
+ destinationParentNodeRef,
+ destinationAssocTypeQName,
+ copyQName);
+ return workingCopy;
+ }
+ }, AuthenticationUtil.getSystemUserName());
// Update the working copy name
this.nodeService.setProperty(workingCopy, ContentModel.PROP_NAME, copyName);
diff --git a/source/java/org/alfresco/repo/site/SiteService.java b/source/java/org/alfresco/repo/site/SiteService.java
index d49b678d6f..74fc193cb4 100644
--- a/source/java/org/alfresco/repo/site/SiteService.java
+++ b/source/java/org/alfresco/repo/site/SiteService.java
@@ -74,7 +74,7 @@ public interface SiteService
/**
* List the memebers of the site.
*
- * Name and role filters are optional and if not specified all the memebers of the site are returned.
+ * Name and role filters are optional and if not specified all the members of the site are returned.
*
* @param shortName site short name
* @param nameFilter name filter
diff --git a/source/java/org/alfresco/repo/site/SiteServiceImpl.java b/source/java/org/alfresco/repo/site/SiteServiceImpl.java
index d7f99cc3a8..56fde05061 100644
--- a/source/java/org/alfresco/repo/site/SiteServiceImpl.java
+++ b/source/java/org/alfresco/repo/site/SiteServiceImpl.java
@@ -71,13 +71,14 @@ public class SiteServiceImpl implements SiteService, SiteModel
{
/** Logger */
private static Log logger = LogFactory.getLog(SiteServiceImpl.class);
-
+
/** The DM store where site's are kept */
- public static final StoreRef SITE_STORE = new StoreRef("workspace://SpacesStore");
-
+ public static final StoreRef SITE_STORE = new StoreRef(
+ "workspace://SpacesStore");
+
/** Activiti tool */
private static final String ACTIVITY_TOOL = "siteService";
-
+
/** Services */
private NodeService nodeService;
private FileFolderService fileFolderService;
@@ -88,116 +89,131 @@ public class SiteServiceImpl implements SiteService, SiteModel
private AuthenticationComponent authenticationComponent;
private TaggingService taggingService;
private AuthorityService authorityService;
-
+
/**
* Set node service
*
- * @param nodeService node service
+ * @param nodeService
+ * node service
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
-
+
/**
* Set file folder service
*
- * @param fileFolderService file folder service
+ * @param fileFolderService
+ * file folder service
*/
public void setFileFolderService(FileFolderService fileFolderService)
{
this.fileFolderService = fileFolderService;
}
-
+
/**
* Set search service
*
- * @param searchService search service
+ * @param searchService
+ * search service
*/
public void setSearchService(SearchService searchService)
{
this.searchService = searchService;
}
-
+
/**
* Set permission service
*
- * @param permissionService permission service
+ * @param permissionService
+ * permission service
*/
public void setPermissionService(PermissionService permissionService)
{
this.permissionService = permissionService;
}
-
+
/**
* Set activity service
*
- * @param activityService activity service
+ * @param activityService
+ * activity service
*/
public void setActivityService(ActivityService activityService)
{
this.activityService = activityService;
}
-
+
/**
* Set person service
*
- * @param personService person service
+ * @param personService
+ * person service
*/
public void setPersonService(PersonService personService)
{
this.personService = personService;
}
-
+
/**
* Set authentication component
*
- * @param authenticationComponent authententication component
+ * @param authenticationComponent
+ * authententication component
*/
- public void setAuthenticationComponent(AuthenticationComponent authenticationComponent)
+ public void setAuthenticationComponent(
+ AuthenticationComponent authenticationComponent)
{
this.authenticationComponent = authenticationComponent;
}
-
+
/**
* Set the taggin service
*
- * @param taggingService tagging service
+ * @param taggingService
+ * tagging service
*/
public void setTaggingService(TaggingService taggingService)
{
this.taggingService = taggingService;
}
-
+
/**
* Set the authority service
*
- * @param authorityService authority service
+ * @param authorityService
+ * authority service
*/
public void setAuthorityService(AuthorityService authorityService)
{
this.authorityService = authorityService;
}
-
+
/**
- * @see org.alfresco.repo.site.SiteService#createSite(java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean)
+ * @see org.alfresco.repo.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)
+ public SiteInfo createSite(final String sitePreset, String passedShortName,
+ final String title, final String description, final boolean isPublic)
{
// Remove spaces from shortName
final String shortName = passedShortName.replaceAll(" ", "");
-
+
// Check to see if we already have a site of this name
NodeRef existingSite = getSiteNodeRef(shortName);
if (existingSite != null)
{
// Throw an exception since we have a duplicate site name
- throw new AlfrescoRuntimeException("Unable to create site because the site short name '" + shortName + "' is already in use. Site short names must be unique.");
+ throw new AlfrescoRuntimeException(
+ "Unable to create site because the site short name '"
+ + shortName
+ + "' is already in use. Site short names must be unique.");
}
-
+
// Get the site parent node reference
NodeRef siteParent = getSiteParent(shortName);
-
+
// Create the site node
PropertyMap properties = new PropertyMap(4);
properties.put(ContentModel.PROP_NAME, shortName);
@@ -205,62 +221,73 @@ public class SiteServiceImpl implements SiteService, SiteModel
properties.put(ContentModel.PROP_TITLE, title);
properties.put(ContentModel.PROP_DESCRIPTION, description);
final NodeRef siteNodeRef = this.nodeService.createNode(
- siteParent,
- ContentModel.ASSOC_CONTAINS,
- QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, shortName),
- SiteModel.TYPE_SITE,
- properties).getChildRef();
-
+ siteParent,
+ ContentModel.ASSOC_CONTAINS,
+ QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,
+ shortName), SiteModel.TYPE_SITE, properties)
+ .getChildRef();
+
// Make the new site a tag scope
this.taggingService.addTagScope(siteNodeRef);
-
+
// Clear the sites inherited permissions
- this.permissionService.setInheritParentPermissions(siteNodeRef, false);
-
+ this.permissionService.setInheritParentPermissions(siteNodeRef, false);
+
// Get the current user
final String currentUser = authenticationComponent.getCurrentUserName();
-
+
// Create the relevant groups and assign permissions
- AuthenticationUtil.runAs(
- new AuthenticationUtil.RunAsWork()
+ AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork()
+ {
+ public String doWork() throws Exception
{
- public String doWork() throws Exception
+ // Create the site's groups
+ String siteGroup = authorityService.createAuthority(
+ AuthorityType.GROUP, null, getSiteGroup(shortName,
+ false));
+ Set permissions = permissionService
+ .getSettablePermissions(SiteModel.TYPE_SITE);
+ for (String permission : permissions)
{
- // Create the site's groups
- String siteGroup = authorityService.createAuthority(AuthorityType.GROUP, null, getSiteGroup(shortName, false));
- Set permissions = permissionService.getSettablePermissions(SiteModel.TYPE_SITE);
- for (String permission : permissions)
- {
- // Create a group for the permission
- String permissionGroup = authorityService.createAuthority(AuthorityType.GROUP, siteGroup, getSiteRoleGroup(shortName, permission, false));
-
- // Assign the group the relevant permission on the site
- permissionService.setPermission(siteNodeRef, permissionGroup, permission, true);
- }
-
- // Set the memberhips details
- // - give all authorities read permissions if site is public
- // - give all authorities read permission on permissions so memberships can be calculated
- // - add the current user to the site manager group
- if (isPublic == true)
- {
- permissionService.setPermission(siteNodeRef, PermissionService.ALL_AUTHORITIES, SITE_CONSUMER, true);
- }
- permissionService.setPermission(siteNodeRef, PermissionService.ALL_AUTHORITIES, PermissionService.READ_PERMISSIONS, true);
- authorityService.addAuthority(getSiteRoleGroup(shortName, SiteModel.SITE_MANAGER, true), currentUser);
-
- // Return nothing
- return null;
+ // Create a group for the permission
+ String permissionGroup = authorityService.createAuthority(
+ AuthorityType.GROUP, siteGroup, getSiteRoleGroup(
+ shortName, permission, false));
+
+ // Assign the group the relevant permission on the site
+ permissionService.setPermission(siteNodeRef,
+ permissionGroup, permission, true);
}
-
- }, AuthenticationUtil.getSystemUserName());
-
+
+ // Set the memberhips details
+ // - give all authorities read permissions if site is public
+ // - give all authorities read permission on permissions so
+ // memberships can be calculated
+ // - add the current user to the site manager group
+ if (isPublic == true)
+ {
+ permissionService.setPermission(siteNodeRef,
+ PermissionService.ALL_AUTHORITIES, SITE_CONSUMER,
+ true);
+ }
+ permissionService.setPermission(siteNodeRef,
+ PermissionService.ALL_AUTHORITIES,
+ PermissionService.READ_PERMISSIONS, true);
+ authorityService.addAuthority(getSiteRoleGroup(shortName,
+ SiteModel.SITE_MANAGER, true), currentUser);
+
+ // Return nothing
+ return null;
+ }
+
+ }, AuthenticationUtil.getSystemUserName());
+
// Return created site information
Map customProperties = getSiteCustomProperties(siteNodeRef);
SiteInfo siteInfo = new SiteInfo(sitePreset, shortName, title, description, isPublic, customProperties, siteNodeRef);
return siteInfo;
}
-
+
/**
* Gets a map containing the site's custom properties
*
@@ -289,20 +316,22 @@ public class SiteServiceImpl implements SiteService, SiteModel
{
return getSiteGroup(shortName, true);
}
-
+
/**
- * @see org.alfresco.repo.site.SiteService#getSiteRoleGroup(java.lang.String, java.lang.String)
+ * @see org.alfresco.repo.site.SiteService#getSiteRoleGroup(java.lang.String,
+ * java.lang.String)
*/
public String getSiteRoleGroup(String shortName, String role)
{
return getSiteRoleGroup(shortName, role, true);
}
-
+
/**
- * Helper method to get the name of the site group
+ * Helper method to get the name of the site group
*
- * @param shortName site short name
- * @return String site group name
+ * @param shortName
+ * site short name
+ * @return String site group name
*/
public String getSiteGroup(String shortName, boolean withGroupPrefix)
{
@@ -315,83 +344,93 @@ public class SiteServiceImpl implements SiteService, SiteModel
sb.append(shortName);
return sb.toString();
}
-
+
/**
* Helper method to get the name of the site permission group
*
- * @param shortName site short name
- * @param permission permission name
- * @return String site permission group name
+ * @param shortName
+ * site short name
+ * @param permission
+ * permission name
+ * @return String site permission group name
*/
- public String getSiteRoleGroup(String shortName, String permission, boolean withGroupPrefix)
+ public String getSiteRoleGroup(String shortName, String permission,
+ boolean withGroupPrefix)
{
return getSiteGroup(shortName, withGroupPrefix) + "_" + permission;
}
-
+
/**
- * Gets a sites parent folder based on it's short name
- * ]
- * @param shortName site short name
- * @return NodeRef the site's parent
+ * Gets a sites parent folder based on it's short name ]
+ *
+ * @param shortName
+ * site short name
+ * @return NodeRef the site's parent
*/
private NodeRef getSiteParent(String shortName)
{
// TODO
- // For now just return the site root, later we may build folder structure based on the shortname to
+ // For now just return the site root, later we may build folder
+ // structure based on the shortname to
// spread the sites about
return getSiteRoot();
}
-
+
/**
* Get the node reference that is the site root
*
- * @return NodeRef node reference
+ * @return NodeRef node reference
*/
private NodeRef getSiteRoot()
- {
+ {
// Get the root 'sites' folder
- ResultSet resultSet = this.searchService.query(SITE_STORE, SearchService.LANGUAGE_LUCENE, "TYPE:\"st:sites\"");
+ ResultSet resultSet = this.searchService.query(SITE_STORE,
+ SearchService.LANGUAGE_LUCENE, "TYPE:\"st:sites\"");
if (resultSet.length() == 0)
{
// No root site folder exists
throw new AlfrescoRuntimeException("No root sites folder exists");
- }
- else if (resultSet.length() != 1)
+ } else if (resultSet.length() != 1)
{
// More than one root site folder exits
- throw new AlfrescoRuntimeException("More than one root sites folder exists");
- }
-
+ throw new AlfrescoRuntimeException(
+ "More than one root sites folder exists");
+ }
+
return resultSet.getNodeRef(0);
}
-
+
/**
- * @see org.alfresco.repo.site.SiteService#listSites(java.lang.String, java.lang.String)
+ * @see org.alfresco.repo.site.SiteService#listSites(java.lang.String,
+ * java.lang.String)
*/
public List listSites(String nameFilter, String sitePresetFilter)
{
- // TODO
+ // TODO
// - take into consideration the filters set
- // - take into consideration that the sites may not just be in a flat list under the site root
-
+ // - take into consideration that the sites may not just be in a flat
+ // list under the site root
+
// TODO
// For now just return the list of sites present under the site root
NodeRef siteRoot = getSiteRoot();
- List assocs = this.nodeService.getChildAssocs(siteRoot, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
+ List assocs = this.nodeService.getChildAssocs(
+ siteRoot, ContentModel.ASSOC_CONTAINS,
+ RegexQNamePattern.MATCH_ALL);
List result = new ArrayList(assocs.size());
for (ChildAssociationRef assoc : assocs)
{
result.add(createSiteInfo(assoc.getChildRef()));
}
-
+
return result;
}
-
+
/**
* @see org.alfresco.repo.site.SiteService#listSites(java.lang.String)
*/
public List listSites(String userName)
- {
+ {
List sites = listSites(null, null);
List result = new ArrayList(sites.size());
for (SiteInfo site : sites)
@@ -403,60 +442,66 @@ public class SiteServiceImpl implements SiteService, SiteModel
}
return result;
}
-
+
/**
* Creates a site informatoin object given a site node reference
*
- * @param siteNodeRef site node reference
- * @return SiteInfo site information object
+ * @param siteNodeRef
+ * site node reference
+ * @return SiteInfo site information object
*/
private SiteInfo createSiteInfo(NodeRef siteNodeRef)
{
// Get the properties
- Map properties = this.nodeService.getProperties(siteNodeRef);
- String shortName = (String)properties.get(ContentModel.PROP_NAME);
- String sitePreset = (String)properties.get(PROP_SITE_PRESET);
- String title = (String)properties.get(ContentModel.PROP_TITLE);
- String description = (String)properties.get(ContentModel.PROP_DESCRIPTION);
-
+ Map properties = this.nodeService
+ .getProperties(siteNodeRef);
+ String shortName = (String) properties.get(ContentModel.PROP_NAME);
+ String sitePreset = (String) properties.get(PROP_SITE_PRESET);
+ String title = (String) properties.get(ContentModel.PROP_TITLE);
+ String description = (String) properties
+ .get(ContentModel.PROP_DESCRIPTION);
+
// Determine whether the space is public or not
boolean isPublic = isSitePublic(siteNodeRef);
-
+
// Create and return the site information
Map customProperties = getSiteCustomProperties(siteNodeRef);
SiteInfo siteInfo = new SiteInfo(sitePreset, shortName, title, description, isPublic, customProperties, siteNodeRef);
return siteInfo;
- }
-
+ }
+
/**
* Indicates whether a site is public or not
*
- * @param siteNodeRef site node reference
- * @return boolean true if the site is public, false otherwise
+ * @param siteNodeRef
+ * site node reference
+ * @return boolean true if the site is public, false otherwise
*/
private boolean isSitePublic(NodeRef siteNodeRef)
{
boolean isPublic = false;
- Set permissions = this.permissionService.getAllSetPermissions(siteNodeRef);
+ Set permissions = this.permissionService
+ .getAllSetPermissions(siteNodeRef);
for (AccessPermission permission : permissions)
{
- if (permission.getAuthority().equals(PermissionService.ALL_AUTHORITIES) == true &&
- permission.getPermission().equals(SITE_CONSUMER) == true)
+ if (permission.getAuthority().equals(
+ PermissionService.ALL_AUTHORITIES) == true
+ && permission.getPermission().equals(SITE_CONSUMER) == true)
{
isPublic = true;
break;
- }
+ }
}
return isPublic;
}
-
+
/**
* @see org.alfresco.repo.site.SiteService#getSite(java.lang.String)
*/
public SiteInfo getSite(String shortName)
{
SiteInfo result = null;
-
+
// Get the site node
NodeRef siteNodeRef = getSiteNodeRef(shortName);
if (siteNodeRef != null)
@@ -464,25 +509,25 @@ public class SiteServiceImpl implements SiteService, SiteModel
// Create the site info
result = createSiteInfo(siteNodeRef);
}
-
+
// Return the site information
return result;
}
-
+
/**
* Gets the site's node reference based on its short name
*
- * @param shortName short name
- * @return NodeRef node reference
+ * @param shortName
+ * short name
+ * @return NodeRef node reference
*/
private NodeRef getSiteNodeRef(String shortName)
{
- NodeRef result = null;
- NodeRef siteRoot = getSiteParent(shortName);
+ NodeRef result = null;
+ NodeRef siteRoot = getSiteParent(shortName);
List assoc = this.nodeService.getChildAssocs(
- siteRoot,
- ContentModel.ASSOC_CONTAINS,
- QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, shortName));
+ siteRoot, ContentModel.ASSOC_CONTAINS, QName.createQName(
+ NamespaceService.CONTENT_MODEL_1_0_URI, shortName));
if (assoc.size() == 1)
{
result = assoc.get(0).getChildRef();
@@ -498,34 +543,39 @@ public class SiteServiceImpl implements SiteService, SiteModel
NodeRef siteNodeRef = getSiteNodeRef(siteInfo.getShortName());
if (siteNodeRef == null)
{
- throw new AlfrescoRuntimeException("Can not update site " + siteInfo.getShortName() + " because it does not exist.");
+ throw new AlfrescoRuntimeException("Can not update site "
+ + siteInfo.getShortName() + " because it does not exist.");
}
-
+
// Note: the site preset and short name can not be updated
-
+
// Update the properties of the site
- Map properties = this.nodeService.getProperties(siteNodeRef);
+ Map properties = this.nodeService
+ .getProperties(siteNodeRef);
properties.put(ContentModel.PROP_TITLE, siteInfo.getTitle());
- properties.put(ContentModel.PROP_DESCRIPTION, siteInfo.getDescription());
+ properties
+ .put(ContentModel.PROP_DESCRIPTION, siteInfo.getDescription());
this.nodeService.setProperties(siteNodeRef, properties);
-
+
// Update the isPublic flag
boolean isPublic = isSitePublic(siteNodeRef);
- if (isPublic != siteInfo.getIsPublic());
+ if (isPublic != siteInfo.getIsPublic())
+ ;
{
if (siteInfo.getIsPublic() == true)
{
// Add the permission
- this.permissionService.setPermission(siteNodeRef, PermissionService.ALL_AUTHORITIES, SITE_CONSUMER, true);
- }
- else
+ this.permissionService.setPermission(siteNodeRef,
+ PermissionService.ALL_AUTHORITIES, SITE_CONSUMER, true);
+ } else
{
// Remove the permission
- this.permissionService.deletePermission(siteNodeRef, PermissionService.ALL_AUTHORITIES, SITE_CONSUMER);
+ this.permissionService.deletePermission(siteNodeRef,
+ PermissionService.ALL_AUTHORITIES, SITE_CONSUMER);
}
- }
+ }
}
-
+
/**
* @see org.alfresco.repo.site.SiteService#deleteSite(java.lang.String)
*/
@@ -534,54 +584,70 @@ public class SiteServiceImpl implements SiteService, SiteModel
NodeRef siteNodeRef = getSiteNodeRef(shortName);
if (siteNodeRef == null)
{
- throw new AlfrescoRuntimeException("Can not delete site " + shortName + " because it does not exist.");
+ throw new AlfrescoRuntimeException("Can not delete site "
+ + shortName + " because it does not exist.");
}
-
+
// Delete the node
this.nodeService.deleteNode(siteNodeRef);
// Delete the associatated group's
- AuthenticationUtil.runAs(
- new AuthenticationUtil.RunAsWork()
+ AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork()
+ {
+ public Object doWork() throws Exception
{
- public Object doWork() throws Exception
- {
- authorityService.deleteAuthority(getSiteGroup(shortName, true));
- return null;
- }
- }, AuthenticationUtil.getSystemUserName());
+ authorityService.deleteAuthority(getSiteGroup(shortName, true));
+ return null;
+ }
+ }, AuthenticationUtil.getSystemUserName());
}
-
+
/**
- * @see org.alfresco.repo.site.SiteService#listMembers(java.lang.String, java.lang.String, java.lang.String)
+ * @see org.alfresco.repo.site.SiteService#listMembers(java.lang.String,
+ * java.lang.String, java.lang.String)
*/
- public Map listMembers(String shortName, String nameFilter, String roleFilter)
+ public Map listMembers(String shortName, String nameFilter,
+ String roleFilter)
{
NodeRef siteNodeRef = getSiteNodeRef(shortName);
if (siteNodeRef == null)
{
- throw new AlfrescoRuntimeException("Site " + shortName + " does not exist.");
+ throw new AlfrescoRuntimeException("Site " + shortName
+ + " does not exist.");
}
-
+
Map members = new HashMap(23);
-
- Set permissions = permissionService.getSettablePermissions(SiteModel.TYPE_SITE);
+
+ Set permissions = permissionService
+ .getSettablePermissions(SiteModel.TYPE_SITE);
for (String permission : permissions)
{
- String groupName = getSiteRoleGroup(shortName, permission, true);
- Set users = this.authorityService.getContainedAuthorities(AuthorityType.USER, groupName, true);
- for (String user : users)
+ if (roleFilter == null ||
+ roleFilter.length() == 0 ||
+ roleFilter.equals(permission) == true)
{
- // Add the user and their permission to the returned map
- members.put(user, permission);
- }
- }
-
+ String groupName = getSiteRoleGroup(shortName, permission, true);
+ Set users = this.authorityService.getContainedAuthorities(
+ AuthorityType.USER, groupName, true);
+ for (String user : users)
+ {
+ if (nameFilter == null ||
+ nameFilter.length() == 0 ||
+ nameFilter.equals(user) == true)
+ {
+ // Add the user and their permission to the returned map
+ members.put(user, permission);
+ }
+ }
+ }
+ }
+
return members;
}
/**
- * @see org.alfresco.repo.site.SiteService#getMembersRole(java.lang.String, java.lang.String)
+ * @see org.alfresco.repo.site.SiteService#getMembersRole(java.lang.String,
+ * java.lang.String)
*/
public String getMembersRole(String shortName, String userName)
{
@@ -592,27 +658,31 @@ public class SiteServiceImpl implements SiteService, SiteModel
int index = group.lastIndexOf('_');
if (index != -1)
{
- result = group.substring(index+1);
+ result = group.substring(index + 1);
}
}
return result;
}
-
+
/**
* Helper method to get the permission group for a given user on a site.
* Returns null if the user does not have a explicit membership to the site.
*
- * @param siteShortName site short name
- * @param userName user name
- * @return String permission group, null if no explicit membership set
+ * @param siteShortName
+ * site short name
+ * @param userName
+ * user name
+ * @return String permission group, null if no explicit membership set
*/
private String getPermissionGroup(String siteShortName, String userName)
{
String result = null;
- Set groups = this.authorityService.getContainingAuthorities(AuthorityType.GROUP, userName, true);
+ Set groups = this.authorityService.getContainingAuthorities(
+ AuthorityType.GROUP, userName, true);
for (String group : groups)
{
- if (group.startsWith(PermissionService.GROUP_PREFIX + "site_" + siteShortName) == true)
+ if (group.startsWith(PermissionService.GROUP_PREFIX + "site_"
+ + siteShortName) == true)
{
result = group;
break;
@@ -620,242 +690,284 @@ public class SiteServiceImpl implements SiteService, SiteModel
}
return result;
}
-
+
/**
* @see org.alfresco.repo.site.SiteService#getSiteRoles()
*/
public List getSiteRoles()
{
- Set permissions = permissionService.getSettablePermissions(SiteModel.TYPE_SITE);
+ Set permissions = permissionService
+ .getSettablePermissions(SiteModel.TYPE_SITE);
return new ArrayList(permissions);
}
/**
- * @see org.alfresco.repo.site.SiteService#isMember(java.lang.String, java.lang.String)
+ * @see org.alfresco.repo.site.SiteService#isMember(java.lang.String,
+ * java.lang.String)
*/
public boolean isMember(String shortName, String userName)
{
return (getPermissionGroup(shortName, userName) != null);
}
-
+
/**
- * @see org.alfresco.repo.site.SiteService#removeMembership(java.lang.String, java.lang.String)
+ * @see org.alfresco.repo.site.SiteService#removeMembership(java.lang.String,
+ * java.lang.String)
*/
public void removeMembership(final String shortName, final String userName)
{
final NodeRef siteNodeRef = getSiteNodeRef(shortName);
if (siteNodeRef == null)
{
- throw new AlfrescoRuntimeException("Site " + shortName + " does not exist.");
+ throw new AlfrescoRuntimeException("Site " + shortName
+ + " does not exist.");
}
-
- // TODO what do we do about the user if they are in a group that has rights to the site?
-
+
+ // TODO what do we do about the user if they are in a group that has
+ // rights to the site?
+
// Determine whether the site is private or not
boolean isPublic = isSitePublic(siteNodeRef);
-
+
// Get the current user
String currentUserName = AuthenticationUtil.getCurrentUserName();
-
- // Get the user current role
- final String role = getMembersRole(shortName, userName);
+
+ // Get the user current role
+ final String role = getMembersRole(shortName, userName);
if (role != null)
- {
+ {
// Check that we are not about to remove the last site manager
if (SiteModel.SITE_MANAGER.equals(role) == true)
{
- Set siteMangers = this.authorityService.getContainedAuthorities(
- AuthorityType.USER,
- getSiteRoleGroup(shortName, SITE_MANAGER, true),
- true);
+ Set siteMangers = this.authorityService
+ .getContainedAuthorities(
+ AuthorityType.USER,
+ getSiteRoleGroup(shortName, SITE_MANAGER, true),
+ true);
if (siteMangers.size() == 1)
{
- throw new AlfrescoRuntimeException("A site requires at least one site manager. You can not remove '" + userName + "' from the site memebership because they are currently the only site manager.");
+ throw new AlfrescoRuntimeException(
+ "A site requires at least one site manager. You can not remove '"
+ + userName
+ + "' from the site memebership because they are currently the only site manager.");
}
}
-
+
// If ...
- // -- the current user has change permissions rights on the site
+ // -- the current user has change permissions rights on the site
// or
- // -- the site is public and
- // -- the user is ourselves and
- // -- the users current role is consumer
- if ((permissionService.hasPermission(siteNodeRef, PermissionService.CHANGE_PERMISSIONS) == AccessStatus.ALLOWED)
- ||
- (isPublic == true &&
- currentUserName.equals(userName) == true &&
- role.equals(SiteModel.SITE_CONSUMER) == true))
+ // -- the site is public and
+ // -- the user is ourselves and
+ // -- the users current role is consumer
+ if ((permissionService.hasPermission(siteNodeRef,
+ PermissionService.CHANGE_PERMISSIONS) == AccessStatus.ALLOWED)
+ || (isPublic == true
+ && currentUserName.equals(userName) == true && role
+ .equals(SiteModel.SITE_CONSUMER) == true))
{
// Run as system user
- AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork()
- {
- public Object doWork() throws Exception
- {
- // Remove the user from the current permission group
- String currentGroup = getSiteRoleGroup(shortName, role, true);
- authorityService.removeAuthority(currentGroup, userName);
-
- return null;
- }
- }, AuthenticationUtil.SYSTEM_USER_NAME);
-
+ AuthenticationUtil.runAs(
+ new AuthenticationUtil.RunAsWork()
+ {
+ public Object doWork() throws Exception
+ {
+ // Remove the user from the current permission
+ // group
+ String currentGroup = getSiteRoleGroup(
+ shortName, role, true);
+ authorityService.removeAuthority(currentGroup,
+ userName);
+
+ return null;
+ }
+ }, AuthenticationUtil.SYSTEM_USER_NAME);
+
// Raise events
if (AuthorityType.getAuthorityType(userName) == AuthorityType.USER)
{
- activityService.postActivity(ActivityType.SITE_USER_REMOVED, shortName, ACTIVITY_TOOL, getActivityData(userName, ""));
- }
- else
+ activityService.postActivity(
+ ActivityType.SITE_USER_REMOVED, shortName,
+ ACTIVITY_TOOL, getActivityData(userName, ""));
+ } else
{
// TODO - update this, if sites support groups
- logger.error("setMembership - failed to post activity: unexpected authority type: " + AuthorityType.getAuthorityType(userName));
+ logger
+ .error("setMembership - failed to post activity: unexpected authority type: "
+ + AuthorityType.getAuthorityType(userName));
}
- }
- else
+ } else
{
// Throw a permission exception
- throw new AlfrescoRuntimeException("Access denied, user does not have permissions to delete membership details of the site '" + shortName + "'");
+ throw new AlfrescoRuntimeException(
+ "Access denied, user does not have permissions to delete membership details of the site '"
+ + shortName + "'");
}
- }
- else
+ } else
{
// Throw a permission exception
- throw new AlfrescoRuntimeException("Access denied, user does not have permissions to delete membership details of the site '" + shortName + "'");
- }
+ throw new AlfrescoRuntimeException(
+ "Access denied, user does not have permissions to delete membership details of the site '"
+ + shortName + "'");
+ }
}
/**
- * @see org.alfresco.repo.site.SiteService#setMembership(java.lang.String, java.lang.String, java.lang.String)
+ * @see org.alfresco.repo.site.SiteService#setMembership(java.lang.String,
+ * java.lang.String, java.lang.String)
*/
- public void setMembership(final String shortName, final String userName, final String role)
+ public void setMembership(final String shortName, final String userName,
+ final String role)
{
final NodeRef siteNodeRef = getSiteNodeRef(shortName);
if (siteNodeRef == null)
{
- throw new AlfrescoRuntimeException("Site " + shortName + " does not exist.");
+ throw new AlfrescoRuntimeException("Site " + shortName
+ + " does not exist.");
}
-
+
// Get the user's current role
final String currentRole = getMembersRole(shortName, userName);
-
+
// Do nothing if the role of the user is not being changed
if (currentRole == null || role.equals(currentRole) == false)
{
// Determine whether the site is private or not
boolean isPublic = isSitePublic(siteNodeRef);
-
- // TODO if this is the only site manager do not downgrade their permissions
-
+
+ // TODO if this is the only site manager do not downgrade their
+ // permissions
+
// If we are ...
// -- the current user has change permissions rights on the site
// or we are ...
// -- refering to a public site and
// -- the role being set is consumer and
// -- the user being added is ourselves and
- // -- the member does not already have permissions
+ // -- the member does not already have permissions
// ... then we can set the permissions as system user
- final String currentUserName = AuthenticationUtil.getCurrentUserName();
- if ((permissionService.hasPermission(siteNodeRef, PermissionService.CHANGE_PERMISSIONS) == AccessStatus.ALLOWED)
- ||
- (isPublic == true &&
- role.equals(SiteModel.SITE_CONSUMER) == true &&
- userName.equals(currentUserName) == true &&
- currentRole == null))
+ final String currentUserName = AuthenticationUtil
+ .getCurrentUserName();
+ if ((permissionService.hasPermission(siteNodeRef,
+ PermissionService.CHANGE_PERMISSIONS) == AccessStatus.ALLOWED)
+ || (isPublic == true
+ && role.equals(SiteModel.SITE_CONSUMER) == true
+ && userName.equals(currentUserName) == true && currentRole == null))
{
// Check that we are not about to remove the last site manager
if (SiteModel.SITE_MANAGER.equals(currentRole) == true)
{
- Set siteMangers = this.authorityService.getContainedAuthorities(
- AuthorityType.USER,
- getSiteRoleGroup(shortName, SITE_MANAGER, true),
- true);
+ Set siteMangers = this.authorityService
+ .getContainedAuthorities(AuthorityType.USER,
+ getSiteRoleGroup(shortName, SITE_MANAGER,
+ true), true);
if (siteMangers.size() == 1)
{
- throw new AlfrescoRuntimeException("A site requires at least one site manager. You can not change '" + userName + "' role from the site memebership because they are currently the only site manager.");
+ throw new AlfrescoRuntimeException(
+ "A site requires at least one site manager. You can not change '"
+ + userName
+ + "' role from the site memebership because they are currently the only site manager.");
}
}
-
+
// Run as system user
- AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork()
- {
- public Object doWork() throws Exception
- {
- if (currentRole != null)
+ AuthenticationUtil.runAs(
+ new AuthenticationUtil.RunAsWork()
{
- // Remove the user from the current permission group
- String currentGroup = getSiteRoleGroup(shortName, currentRole, true);
- authorityService.removeAuthority(currentGroup, userName);
- }
-
- // Add the user to the new permission group
- String newGroup = getSiteRoleGroup(shortName, role, true);
- authorityService.addAuthority(newGroup, userName);
-
- return null;
- }
-
- }, AuthenticationUtil.SYSTEM_USER_NAME);
-
+ public Object doWork() throws Exception
+ {
+ if (currentRole != null)
+ {
+ // Remove the user from the current
+ // permission group
+ String currentGroup = getSiteRoleGroup(
+ shortName, currentRole, true);
+ authorityService.removeAuthority(
+ currentGroup, userName);
+ }
+
+ // Add the user to the new permission group
+ String newGroup = getSiteRoleGroup(shortName,
+ role, true);
+ authorityService.addAuthority(newGroup,
+ userName);
+
+ return null;
+ }
+
+ }, AuthenticationUtil.SYSTEM_USER_NAME);
+
if (currentRole == null)
{
if (AuthorityType.getAuthorityType(userName) == AuthorityType.USER)
{
- activityService.postActivity(ActivityType.SITE_USER_JOINED, shortName, ACTIVITY_TOOL, getActivityData(userName, role));
- }
- else
+ activityService.postActivity(
+ ActivityType.SITE_USER_JOINED, shortName,
+ ACTIVITY_TOOL, getActivityData(userName, role));
+ } else
{
// TODO - update this, if sites support groups
- logger.error("setMembership - failed to post activity: unexpected authority type: " + AuthorityType.getAuthorityType(userName));
+ logger
+ .error("setMembership - failed to post activity: unexpected authority type: "
+ + AuthorityType
+ .getAuthorityType(userName));
}
- }
- else
+ } else
{
if (AuthorityType.getAuthorityType(userName) == AuthorityType.USER)
{
- activityService.postActivity(ActivityType.SITE_USER_ROLE_UPDATE, shortName, ACTIVITY_TOOL, getActivityData(userName, role));
- }
- else
+ activityService.postActivity(
+ ActivityType.SITE_USER_ROLE_UPDATE, shortName,
+ ACTIVITY_TOOL, getActivityData(userName, role));
+ } else
{
// TODO - update this, if sites support groups
- logger.error("setMembership - failed to post activity: unexpected authority type: " + AuthorityType.getAuthorityType(userName));
+ logger
+ .error("setMembership - failed to post activity: unexpected authority type: "
+ + AuthorityType
+ .getAuthorityType(userName));
}
- }
- }
- else
- {
+ }
+ } else
+ {
// Raise a permission exception
- throw new AlfrescoRuntimeException("Access denied, user does not have permissions to modify membership details of the site '" + shortName + "'");
+ throw new AlfrescoRuntimeException(
+ "Access denied, user does not have permissions to modify membership details of the site '"
+ + shortName + "'");
}
}
- }
+ }
/**
- * @see org.alfresco.repo.site.SiteService#createContainer(java.lang.String, java.lang.String, org.alfresco.service.namespace.QName, java.util.Map)
+ * @see org.alfresco.repo.site.SiteService#createContainer(java.lang.String,
+ * java.lang.String, org.alfresco.service.namespace.QName,
+ * java.util.Map)
*/
- public NodeRef createContainer(String shortName, String componentId, QName containerType, Map containerProperties)
+ public NodeRef createContainer(String shortName, String componentId,
+ QName containerType, Map containerProperties)
{
// Check for the component id
- if (componentId == null || componentId.length() ==0)
+ if (componentId == null || componentId.length() == 0)
{
throw new AlfrescoRuntimeException("Component id not provided");
}
-
+
// retrieve site
NodeRef siteNodeRef = getSiteNodeRef(shortName);
if (siteNodeRef == null)
{
- throw new AlfrescoRuntimeException("Site " + shortName + " does not exist.");
+ throw new AlfrescoRuntimeException("Site " + shortName
+ + " does not exist.");
}
// retrieve component folder within site
NodeRef containerNodeRef = null;
try
{
- containerNodeRef = findContainer(siteNodeRef, componentId);
- }
- catch(FileNotFoundException e)
+ containerNodeRef = findContainer(siteNodeRef, componentId);
+ } catch (FileNotFoundException e)
{
}
-
+
// create the container node reference
if (containerNodeRef == null)
{
@@ -863,48 +975,53 @@ public class SiteServiceImpl implements SiteService, SiteModel
{
containerType = ContentModel.TYPE_FOLDER;
}
-
+
// create component folder
- FileInfo fileInfo = fileFolderService.create(siteNodeRef, componentId, containerType);
-
- // Get the created container
+ FileInfo fileInfo = fileFolderService.create(siteNodeRef,
+ componentId, containerType);
+
+ // Get the created container
containerNodeRef = fileInfo.getNodeRef();
-
+
// Set the properties if they have been provided
if (containerProperties != null)
{
- Map props = this.nodeService.getProperties(containerNodeRef);
+ Map props = this.nodeService
+ .getProperties(containerNodeRef);
props.putAll(containerProperties);
this.nodeService.setProperties(containerNodeRef, props);
}
-
+
// Add the container aspect
- Map aspectProps = new HashMap(1);
+ Map aspectProps = new HashMap(
+ 1);
aspectProps.put(SiteModel.PROP_COMPONENT_ID, componentId);
- this.nodeService.addAspect(containerNodeRef, ASPECT_SITE_CONTAINER, aspectProps);
-
+ this.nodeService.addAspect(containerNodeRef, ASPECT_SITE_CONTAINER,
+ aspectProps);
+
// Make the container a tag scope
this.taggingService.addTagScope(containerNodeRef);
}
-
+
return containerNodeRef;
}
-
+
/**
* @see org.alfresco.repo.site.SiteService#getContainer(java.lang.String)
*/
public NodeRef getContainer(String shortName, String componentId)
{
- if (componentId == null || componentId.length() ==0)
+ if (componentId == null || componentId.length() == 0)
{
- throw new AlfrescoRuntimeException("Component id not provided");
+ throw new AlfrescoRuntimeException("Component id not provided");
}
-
+
// retrieve site
NodeRef siteNodeRef = getSiteNodeRef(shortName);
if (siteNodeRef == null)
{
- throw new AlfrescoRuntimeException("Site " + shortName + " does not exist.");
+ throw new AlfrescoRuntimeException("Site " + shortName
+ + " does not exist.");
}
// retrieve component folder within site
@@ -912,12 +1029,11 @@ public class SiteServiceImpl implements SiteService, SiteModel
NodeRef containerNodeRef = null;
try
{
- containerNodeRef = findContainer(siteNodeRef, componentId);
+ containerNodeRef = findContainer(siteNodeRef, componentId);
+ } catch (FileNotFoundException e)
+ {
}
- catch(FileNotFoundException e)
- {
- }
-
+
return containerNodeRef;
}
@@ -926,16 +1042,17 @@ public class SiteServiceImpl implements SiteService, SiteModel
*/
public boolean hasContainer(String shortName, String componentId)
{
- if (componentId == null || componentId.length() ==0)
+ if (componentId == null || componentId.length() == 0)
{
- throw new AlfrescoRuntimeException("Component id not provided");
+ throw new AlfrescoRuntimeException("Component id not provided");
}
-
+
// retrieve site
NodeRef siteNodeRef = getSiteNodeRef(shortName);
if (siteNodeRef == null)
{
- throw new AlfrescoRuntimeException("Site " + shortName + " does not exist.");
+ throw new AlfrescoRuntimeException("Site " + shortName
+ + " does not exist.");
}
// retrieve component folder within site
@@ -943,37 +1060,40 @@ public class SiteServiceImpl implements SiteService, SiteModel
boolean hasContainer = false;
try
{
- findContainer(siteNodeRef, componentId);
- hasContainer = true;
- }
- catch(FileNotFoundException e)
+ findContainer(siteNodeRef, componentId);
+ hasContainer = true;
+ } catch (FileNotFoundException e)
{
}
-
+
return hasContainer;
}
-
+
/**
* Locate site "container" folder for component
*
- * @param siteNodeRef site
- * @param componentId component id
- * @return "container" node ref, if it exists
+ * @param siteNodeRef
+ * site
+ * @param componentId
+ * component id
+ * @return "container" node ref, if it exists
* @throws FileNotFoundException
*/
private NodeRef findContainer(NodeRef siteNodeRef, String componentId)
- throws FileNotFoundException
+ throws FileNotFoundException
{
List paths = new ArrayList(1);
paths.add(componentId);
- FileInfo fileInfo = fileFolderService.resolveNamePath(siteNodeRef, paths);
- if (!fileInfo.isFolder())
- {
- throw new AlfrescoRuntimeException("Site container " + fileInfo.getName() + " does not refer to a folder ");
- }
+ FileInfo fileInfo = fileFolderService.resolveNamePath(siteNodeRef,
+ paths);
+ if (!fileInfo.isFolder())
+ {
+ throw new AlfrescoRuntimeException("Site container "
+ + fileInfo.getName() + " does not refer to a folder ");
+ }
return fileInfo.getNodeRef();
}
-
+
private String getActivityData(String userName, String role)
{
String memberFN = "";
@@ -981,10 +1101,12 @@ public class SiteServiceImpl implements SiteService, SiteModel
NodeRef person = personService.getPerson(userName);
if (person != null)
{
- memberFN = (String)nodeService.getProperty(person, ContentModel.PROP_FIRSTNAME);
- memberLN = (String)nodeService.getProperty(person, ContentModel.PROP_LASTNAME);
+ memberFN = (String) nodeService.getProperty(person,
+ ContentModel.PROP_FIRSTNAME);
+ memberLN = (String) nodeService.getProperty(person,
+ ContentModel.PROP_LASTNAME);
}
-
+
try
{
JSONObject activityData = new JSONObject();
@@ -992,10 +1114,10 @@ public class SiteServiceImpl implements SiteService, SiteModel
activityData.put("memberUserName", userName);
activityData.put("memberFirstName", memberFN);
activityData.put("memberLastName", memberLN);
- activityData.put("title", (memberFN + " " + memberLN + " (" + userName + ")").trim());
+ activityData.put("title", (memberFN + " " + memberLN + " ("
+ + userName + ")").trim());
return activityData.toString();
- }
- catch (JSONException je)
+ } catch (JSONException je)
{
// log error, subsume exception
logger.error("Failed to get activity data: " + je);
diff --git a/source/java/org/alfresco/repo/site/SiteServiceImplTest.java b/source/java/org/alfresco/repo/site/SiteServiceImplTest.java
index 993e400057..bb428310b7 100644
--- a/source/java/org/alfresco/repo/site/SiteServiceImplTest.java
+++ b/source/java/org/alfresco/repo/site/SiteServiceImplTest.java
@@ -374,6 +374,20 @@ public class SiteServiceImplTest extends BaseAlfrescoSpringTest
assertTrue(members.containsKey(USER_THREE));
assertEquals(SiteModel.SITE_COLLABORATOR, members.get(USER_THREE));
+ // Get only the site managers
+ members = this.siteService.listMembers("testMembership", null, SiteModel.SITE_MANAGER);
+ assertNotNull(members);
+ assertEquals(1, members.size());
+ assertTrue(members.containsKey(USER_ONE));
+ assertEquals(SiteModel.SITE_MANAGER, members.get(USER_ONE));
+
+ // Get only user two
+ members = this.siteService.listMembers("testMembership", USER_TWO, null);
+ assertNotNull(members);
+ assertEquals(1, members.size());
+ assertTrue(members.containsKey(USER_TWO));
+ assertEquals(SiteModel.SITE_CONSUMER, members.get(USER_TWO));
+
// Change the membership of user two
this.siteService.setMembership("testMembership", USER_TWO, SiteModel.SITE_COLLABORATOR);
diff --git a/source/java/org/alfresco/repo/tenant/TenantInterpreter.java b/source/java/org/alfresco/repo/tenant/TenantInterpreter.java
index 5e43430e2a..8105cdd8c0 100755
--- a/source/java/org/alfresco/repo/tenant/TenantInterpreter.java
+++ b/source/java/org/alfresco/repo/tenant/TenantInterpreter.java
@@ -84,7 +84,14 @@ public class TenantInterpreter extends BaseInterpreter
try
{
AuthenticationUtil.setSystemUserAsCurrentUser();
- return executeCommand(line);
+ RetryingTransactionCallback txnWork = new RetryingTransactionCallback()
+ {
+ public String execute() throws Exception
+ {
+ return executeCommand(line);
+ }
+ };
+ return transactionService.getRetryingTransactionHelper().doInTransaction(txnWork);
}
finally
{
@@ -321,20 +328,13 @@ public class TenantInterpreter extends BaseInterpreter
final String tenantAdminUsername = tenantService.getDomainUser(TenantService.ADMIN_BASENAME, tenantDomain);
AuthenticationUtil.runAs(new RunAsWork()
- {
- public Object doWork() throws Exception
- {
- RetryingTransactionCallback txnWork = new RetryingTransactionCallback()
- {
- public Object execute() throws Exception
- {
- authenticationService.setAuthentication(tenantAdminUsername, newPassword.toCharArray());
- return null;
- }
- };
- return transactionService.getRetryingTransactionHelper().doInTransaction(txnWork);
- }
- }, tenantAdminUsername);
+ {
+ public Object doWork() throws Exception
+ {
+ authenticationService.setAuthentication(tenantAdminUsername, newPassword.toCharArray());
+ return null;
+ }
+ }, tenantAdminUsername);
}
else
diff --git a/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImpl.java b/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImpl.java
index 676a0896e2..725dd9ae32 100644
--- a/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImpl.java
+++ b/source/java/org/alfresco/repo/thumbnail/ThumbnailServiceImpl.java
@@ -49,17 +49,21 @@ import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.util.GUID;
import org.alfresco.util.ParameterCheck;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* @author Roy Wetherall
*/
public class ThumbnailServiceImpl implements ThumbnailService
{
+ /** Logger */
+ private static Log logger = LogFactory.getLog(ThumbnailServiceImpl.class);
+
/** Error messages */
private static final String ERR_NO_CREATE = "Thumbnail could not be created as required transformation is not supported from {0} to {1}";
private static final String ERR_DUPLICATE_NAME = "Thumbnail could not be created because of a duplicate name";
private static final String ERR_NO_PARENT = "Thumbnail has no parent so update cannot take place.";
- private static final String ERR_TOO_PARENT = "Thumbnail has more than one source content node. This is invalid so update cannot take place.";
/** Node service */
private NodeService nodeService;
@@ -140,11 +144,21 @@ public class ThumbnailServiceImpl implements ThumbnailService
ParameterCheck.mandatoryString( "mimetype", mimetype);
ParameterCheck.mandatory("transformationOptions", transformationOptions);
+ if (logger.isDebugEnabled() == true)
+ {
+ logger.debug("Creating thumbnail (node=" + node.toString() + "; contentProperty=" + contentProperty.toString() + "; mimetype=" + mimetype);
+ }
+
NodeRef thumbnail = null;
// Check for duplicate names
if (thumbnailName != null && getThumbnailByName(node, contentProperty, thumbnailName) != null)
{
+ if (logger.isDebugEnabled() == true)
+ {
+ logger.debug("Creating thumbnail: There is already a thumbnail with the name '" + thumbnail + "' (node=" + node.toString() + "; contentProperty=" + contentProperty.toString() + "; mimetype=" + mimetype);
+ }
+
// We can't continue because there is already an thumnail with the given name for that content property
throw new ThumbnailException(ERR_DUPLICATE_NAME);
}
@@ -209,6 +223,11 @@ public class ThumbnailServiceImpl implements ThumbnailService
// Catch the failure to create the thumbnail
if (this.contentService.isTransformable(reader, writer, transformationOptions) == false)
{
+ if (logger.isDebugEnabled() == true)
+ {
+ logger.debug("Creating thumbnail: There is no transformer to generate the thumbnail required (node=" + node.toString() + "; contentProperty=" + contentProperty.toString() + "; mimetype=" + mimetype + ")");
+ }
+
// Throw exception indicating that the thumbnail could not be created
throw new ThumbnailException(MessageFormat.format(ERR_NO_CREATE, reader.getMimetype(), writer.getMimetype()));
}
@@ -239,6 +258,11 @@ public class ThumbnailServiceImpl implements ThumbnailService
*/
public void updateThumbnail(NodeRef thumbnail, TransformationOptions transformationOptions)
{
+ if (logger.isDebugEnabled() == true)
+ {
+ logger.debug("Updating thumbnail (thumbnail=" + thumbnail.toString() + ")");
+ }
+
// First check that we are dealing with a thumbnail
if (ContentModel.TYPE_THUMBNAIL.equals(this.nodeService.getType(thumbnail)) == true)
{
@@ -247,16 +271,13 @@ public class ThumbnailServiceImpl implements ThumbnailService
List parents = this.nodeService.getParentAssocs(thumbnail, ContentModel.ASSOC_THUMBNAILS, RegexQNamePattern.MATCH_ALL);
if (parents.size() == 0)
{
+ if (logger.isDebugEnabled() == true)
+ {
+ logger.debug("Updating thumbnail: The thumbnails parent cannot be found (thumbnail=" + thumbnail.toString() + ")");
+ }
+
throw new ThumbnailException(ERR_NO_PARENT);
}
- // TODO
- // When a node with thumbnails is checked in the assoc's get doubled up. This means we get more than one parent.
- // As a work around simply take the first parent retrieved
- //
- //else if (parents.size() != 1)
- //{
- // throw new ThumbnailException(ERR_TOO_PARENT);
- //}
else
{
node = parents.get(0).getParentRef();
@@ -278,6 +299,11 @@ public class ThumbnailServiceImpl implements ThumbnailService
// Catch the failure to create the thumbnail
if (this.contentService.isTransformable(reader, writer, transformationOptions) == false)
{
+ if (logger.isDebugEnabled() == true)
+ {
+ logger.debug("Updating thumbnail: there is not transformer to update the thumbnail with (thumbnail=" + thumbnail.toString() + ")");
+ }
+
// Throw exception indicating that the thumbnail could not be created
throw new ThumbnailException(MessageFormat.format(ERR_NO_CREATE, reader.getMimetype(), writer.getMimetype()));
}
@@ -287,7 +313,13 @@ public class ThumbnailServiceImpl implements ThumbnailService
this.contentService.transform(reader, writer, transformationOptions);
}
}
- // TODO else should we throw an exception?
+ else
+ {
+ if (logger.isDebugEnabled() == true)
+ {
+ logger.debug("Updating thumbnail: cannot update a thumbnail node that isn't the correct thumbnail type (thumbnail=" + thumbnail.toString() + ")");
+ }
+ }
}
/**
@@ -304,6 +336,11 @@ public class ThumbnailServiceImpl implements ThumbnailService
// If retrieval performance becomes an issue then this code can be replaced
//
+ if (logger.isDebugEnabled() == true)
+ {
+ logger.debug("Getting thumbnail by name (nodeRef=" + node.toString() + "; contentProperty=" + contentProperty.toString() + "; thumbnailName=" + thumbnailName + ")");
+ }
+
// Check that the node has the thumbnailed aspect applied
if (nodeService.hasAspect(node, ContentModel.ASPECT_THUMBNAILED) == true)
{
@@ -339,6 +376,11 @@ public class ThumbnailServiceImpl implements ThumbnailService
// If retrieval performance becomes an issue then this code can be replaced
//
+ if (logger.isDebugEnabled() == true)
+ {
+ logger.debug("Getting thumbnails (nodeRef=" + node.toString() + "; contentProperty=" + contentProperty.toString() + "; mimetype=" + mimetype + ")");
+ }
+
// Check that the node has the thumbnailed aspect applied
if (nodeService.hasAspect(node, ContentModel.ASPECT_THUMBNAILED) == true)
{