Merged V3.2E to HEAD

17385: Minor performance tweaks and code cleanup/consolidation in SiteServiceImpl.
   17386: ETHREEOH-3066 Added supporting logging
   17387: Minor javadoc updates pertinent to the FreeMarker API chapter updates.
   17392: Fix to unreported issue in User Profile where a recent fix incorrectly encoding javascript values as ?html.
      - values passed into JS components in FreeMarker template should use ?js_string operator - not the ?html operator.
   17399: ETHREEOH-3269, ETHREEOH-3271 - Dropdown markup changed for keyboard access
   17400: ETHREEOH-3278 - Navigator is very wide
   17401: Concatenate DocLib JavaScript files

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18120 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2010-01-19 11:11:39 +00:00
parent db17ae8831
commit a1ac5105a6
3 changed files with 74 additions and 66 deletions

View File

@@ -41,18 +41,21 @@ import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.TransformationOptions; import org.alfresco.service.cmr.repository.TransformationOptions;
import org.alfresco.util.TempFileProvider; import org.alfresco.util.TempFileProvider;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.sun.pdfview.PDFFile; import com.sun.pdfview.PDFFile;
import com.sun.pdfview.PDFPage; import com.sun.pdfview.PDFPage;
/** /**
* Makes use of the {@link http://www.pdfbox.org/ PDFBox} library to * Makes use of the {@link https://pdf-renderer.dev.java.net/ PDFRenderer} library to
* perform conversions from PDF files to images. * perform conversions from PDF files to images.
* *
* @author Roy Wetherall * @author Roy Wetherall
*/ */
public class PdfToImageContentTransformer extends AbstractContentTransformer2 public class PdfToImageContentTransformer extends AbstractContentTransformer2
{ {
private static final Log logger = LogFactory.getLog(PdfToImageContentTransformer.class);
/** /**
* Currently the only transformation performed is that of text extraction from PDF documents. * Currently the only transformation performed is that of text extraction from PDF documents.
*/ */
@@ -87,6 +90,18 @@ public class PdfToImageContentTransformer extends AbstractContentTransformer2
ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size()); ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
PDFFile pdffile = new PDFFile(buf); PDFFile pdffile = new PDFFile(buf);
// Log the PDF version of the file being transformed.
if (logger.isInfoEnabled())
{
int pdfMajorVersion = pdffile.getMajorVersion();
int pdfMinorVersion = pdffile.getMinorVersion();
StringBuilder msg = new StringBuilder();
msg.append("File being transformed is of pdf version ")
.append(pdfMajorVersion).append(".").append(pdfMinorVersion);
logger.info(msg.toString());
}
PDFPage page = pdffile.getPage(0); PDFPage page = pdffile.getPage(0);
//get the width and height for the doc at the default zoom //get the width and height for the doc at the default zoom

View File

@@ -268,7 +268,17 @@ public class SiteServiceImpl implements SiteService, SiteModel
{ {
this.retryingTransactionHelper = retryingTransactionHelper; this.retryingTransactionHelper = retryingTransactionHelper;
} }
public void setRoleComparator(Comparator<String> roleComparator)
{
this.roleComparator = roleComparator;
}
public Comparator<String> getRoleComparator()
{
return roleComparator;
}
/** /**
* Checks that all necessary properties and services have been provided. * Checks that all necessary properties and services have been provided.
*/ */
@@ -290,11 +300,11 @@ public class SiteServiceImpl implements SiteService, SiteModel
/** /**
* @see org.alfresco.service.cmr.site.SiteService#createSite(java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean) * @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, public SiteInfo createSite(final String sitePreset,
String passedShortName, String passedShortName,
final String title, final String title,
final String description, final String description,
final boolean isPublic) final boolean isPublic)
{ {
// Determine the site visibility // Determine the site visibility
SiteVisibility visibility = SiteVisibility.PRIVATE; SiteVisibility visibility = SiteVisibility.PRIVATE;
@@ -357,8 +367,6 @@ public class SiteServiceImpl implements SiteService, SiteModel
// Get the current user // Get the current user
final String currentUser = authenticationContext.getCurrentUserName(); final String currentUser = authenticationContext.getCurrentUserName();
// Create the relevant groups and assign permissions // Create the relevant groups and assign permissions
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>() AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
{ {
@@ -395,8 +403,7 @@ public class SiteServiceImpl implements SiteService, SiteModel
} }
else if (SiteVisibility.MODERATED.equals(visibility) == true) else if (SiteVisibility.MODERATED.equals(visibility) == true)
{ {
permissionService.setPermission(siteNodeRef, PermissionService.ALL_AUTHORITIES, SITE_CONSUMER, true); permissionService.setPermission(siteNodeRef, PermissionService.ALL_AUTHORITIES, SITE_CONSUMER, true);
//permissionService.setPermission(siteNodeRef, PermissionService.ALL_AUTHORITIES, PermissionService.READ_PROPERTIES, true);
} }
permissionService.setPermission(siteNodeRef, permissionService.setPermission(siteNodeRef,
PermissionService.ALL_AUTHORITIES, PermissionService.ALL_AUTHORITIES,
@@ -1147,9 +1154,9 @@ public class SiteServiceImpl implements SiteService, SiteModel
{ {
String result = null; String result = null;
List<String> roles = getMembersRoles(shortName, authorityName); List<String> roles = getMembersRoles(shortName, authorityName);
if (roles.isEmpty() == false) if (roles.size() != 0)
{ {
if(roleComparator != null) if (roles.size() > 1 && roleComparator != null)
{ {
// Need to sort the roles into the most important first. // Need to sort the roles into the most important first.
SortedSet<String> sortedRoles = new TreeSet<String>(roleComparator); SortedSet<String> sortedRoles = new TreeSet<String>(roleComparator);
@@ -1161,10 +1168,9 @@ public class SiteServiceImpl implements SiteService, SiteModel
} }
else else
{ {
// don't search on precedence // don't search on precedence or only one result
result = roles.get(0); result = roles.get(0);
} }
} }
return result; return result;
} }
@@ -1210,9 +1216,9 @@ public class SiteServiceImpl implements SiteService, SiteModel
} }
// If there are user permissions then they take priority // If there are user permissions then they take priority
if(result.size() > 0) if (result.size() > 0)
{ {
return result; return result;
} }
// Now do a deep search through all users and groups // Now do a deep search through all users and groups
@@ -1268,22 +1274,8 @@ public class SiteServiceImpl implements SiteService, SiteModel
if (role != null) if (role != null)
{ {
// Check that we are not about to remove the last site manager // Check that we are not about to remove the last site manager
if (SiteModel.SITE_MANAGER.equals(role) == true) checkLastManagerRemoval(shortName, authorityName, role);
{
String mgrGroup = getSiteRoleGroup(shortName, SITE_MANAGER, true);
Set<String> siteUserMangers = this.authorityService.getContainedAuthorities(AuthorityType.USER,
mgrGroup,
true);
Set<String> siteGroupManagers = this.authorityService.getContainedAuthorities(AuthorityType.GROUP,
mgrGroup,
true);
if (siteUserMangers.size() + siteGroupManagers.size() == 1)
{
throw new SiteServiceException(MSG_DO_NOT_CHANGE_MGR, new Object[]{authorityName});
}
}
// If ... // If ...
// -- the current user has change permissions rights on the site // -- the current user has change permissions rights on the site
// or // or
@@ -1376,22 +1368,8 @@ public class SiteServiceImpl implements SiteService, SiteModel
currentRole == null)) currentRole == null))
{ {
// Check that we are not about to remove the last site manager // Check that we are not about to remove the last site manager
if (SiteModel.SITE_MANAGER.equals(currentRole) == true) checkLastManagerRemoval(shortName, authorityName, currentRole);
{
String mgrGroup = getSiteRoleGroup(shortName, SITE_MANAGER, true);
Set<String> siteUserMangers = this.authorityService.getContainedAuthorities(AuthorityType.USER,
mgrGroup,
true);
Set<String> siteGroupManagers = this.authorityService.getContainedAuthorities(AuthorityType.GROUP,
mgrGroup,
true);
if (siteUserMangers.size() + siteGroupManagers.size() == 1)
{
throw new SiteServiceException(MSG_DO_NOT_CHANGE_MGR, new Object[]{authorityName});
}
}
// Run as system user // Run as system user
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>() AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
{ {
@@ -1510,8 +1488,7 @@ public class SiteServiceImpl implements SiteService, SiteModel
} }
// Add the container aspect // Add the container aspect
Map<QName, Serializable> aspectProps = new HashMap<QName, Serializable>( Map<QName, Serializable> aspectProps = new HashMap<QName, Serializable>(1, 1.0f);
1);
aspectProps.put(SiteModel.PROP_COMPONENT_ID, componentId); aspectProps.put(SiteModel.PROP_COMPONENT_ID, componentId);
this.nodeService.addAspect(containerNodeRef, ASPECT_SITE_CONTAINER, this.nodeService.addAspect(containerNodeRef, ASPECT_SITE_CONTAINER,
aspectProps); aspectProps);
@@ -1666,14 +1643,32 @@ public class SiteServiceImpl implements SiteService, SiteModel
return ""; return "";
} }
} }
public void setRoleComparator(Comparator<String> roleComparator) { /**
this.roleComparator = roleComparator; * Helper to check that we are not removing the last Site Manager from a site
} *
* @param shortName
public Comparator<String> getRoleComparator() { * @param authorityName
return roleComparator; * @param role
} */
private void checkLastManagerRemoval(final String shortName, final String authorityName, final String role)
{
// Check that we are not about to remove the last site manager
if (SiteModel.SITE_MANAGER.equals(role) == true)
{
String mgrGroup = getSiteRoleGroup(shortName, SITE_MANAGER, true);
Set<String> siteUserMangers = this.authorityService.getContainedAuthorities(
AuthorityType.USER, mgrGroup, true);
if (siteUserMangers.size() <= 1)
{
Set<String> siteGroupManagers = this.authorityService.getContainedAuthorities(
AuthorityType.GROUP, mgrGroup, true);
if (siteUserMangers.size() + siteGroupManagers.size() == 1)
{
throw new SiteServiceException(MSG_DO_NOT_CHANGE_MGR, new Object[] {authorityName});
}
}
}
}
} }

View File

@@ -207,7 +207,6 @@ public class People extends BaseTemplateProcessorExtension implements Initializi
* Gets the members (people) of a group (including all sub-groups) * Gets the members (people) of a group (including all sub-groups)
* *
* @param group the group to retrieve members for * @param group the group to retrieve members for
* @param recurse recurse into sub-groups
* *
* @return list of nodes representing the group members * @return list of nodes representing the group members
*/ */
@@ -236,7 +235,7 @@ public class People extends BaseTemplateProcessorExtension implements Initializi
* *
* @param person the user (cm:person) to get the containing groups for * @param person the user (cm:person) to get the containing groups for
* *
* @return the containing groups as a JavaScript array, can be null * @return the containing groups as a List of TemplateNode objects, can be null
*/ */
public List<TemplateNode> getContainerGroups(TemplateNode person) public List<TemplateNode> getContainerGroups(TemplateNode person)
{ {
@@ -272,11 +271,11 @@ public class People extends BaseTemplateProcessorExtension implements Initializi
} }
/** /**
* Return true if the specified user is an Administrator authority. * Return true if the specified user is an Guest authority.
* *
* @param person to test * @param person to test
* *
* @return true if an admin, false otherwise * @return true if a guest user, false otherwise
*/ */
public boolean isGuest(TemplateNode person) public boolean isGuest(TemplateNode person)
{ {
@@ -287,8 +286,7 @@ public class People extends BaseTemplateProcessorExtension implements Initializi
/** /**
* Gets a map of capabilities (boolean assertions) for the given person. * Gets a map of capabilities (boolean assertions) for the given person.
* *
* @param person * @param person the person
* the person
* @return the capability map * @return the capability map
*/ */
public Map<String, Boolean> getCapabilities(final TemplateNode person) public Map<String, Boolean> getCapabilities(final TemplateNode person)