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.TransformationOptions;
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.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.
*
* @author Roy Wetherall
*/
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.
*/
@@ -87,6 +90,18 @@ public class PdfToImageContentTransformer extends AbstractContentTransformer2
ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
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);
//get the width and height for the doc at the default zoom

View File

@@ -269,6 +269,16 @@ public class SiteServiceImpl implements SiteService, SiteModel
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.
*/
@@ -357,8 +367,6 @@ public class SiteServiceImpl implements SiteService, SiteModel
// Get the current user
final String currentUser = authenticationContext.getCurrentUserName();
// Create the relevant groups and assign permissions
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
{
@@ -396,7 +404,6 @@ public class SiteServiceImpl implements SiteService, SiteModel
else if (SiteVisibility.MODERATED.equals(visibility) == true)
{
permissionService.setPermission(siteNodeRef, PermissionService.ALL_AUTHORITIES, SITE_CONSUMER, true);
//permissionService.setPermission(siteNodeRef, PermissionService.ALL_AUTHORITIES, PermissionService.READ_PROPERTIES, true);
}
permissionService.setPermission(siteNodeRef,
PermissionService.ALL_AUTHORITIES,
@@ -1147,9 +1154,9 @@ public class SiteServiceImpl implements SiteService, SiteModel
{
String result = null;
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.
SortedSet<String> sortedRoles = new TreeSet<String>(roleComparator);
@@ -1161,10 +1168,9 @@ public class SiteServiceImpl implements SiteService, SiteModel
}
else
{
// don't search on precedence
// don't search on precedence or only one result
result = roles.get(0);
}
}
return result;
}
@@ -1268,21 +1274,7 @@ public class SiteServiceImpl implements SiteService, SiteModel
if (role != null)
{
// 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);
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});
}
}
checkLastManagerRemoval(shortName, authorityName, role);
// If ...
// -- the current user has change permissions rights on the site
@@ -1376,21 +1368,7 @@ public class SiteServiceImpl implements SiteService, SiteModel
currentRole == null))
{
// Check that we are not about to remove the last site manager
if (SiteModel.SITE_MANAGER.equals(currentRole) == true)
{
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});
}
}
checkLastManagerRemoval(shortName, authorityName, currentRole);
// Run as system user
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
@@ -1510,8 +1488,7 @@ public class SiteServiceImpl implements SiteService, SiteModel
}
// Add the container aspect
Map<QName, Serializable> aspectProps = new HashMap<QName, Serializable>(
1);
Map<QName, Serializable> aspectProps = new HashMap<QName, Serializable>(1, 1.0f);
aspectProps.put(SiteModel.PROP_COMPONENT_ID, componentId);
this.nodeService.addAspect(containerNodeRef, ASPECT_SITE_CONTAINER,
aspectProps);
@@ -1667,13 +1644,31 @@ public class SiteServiceImpl implements SiteService, SiteModel
}
}
/**
* Helper to check that we are not removing the last Site Manager from a site
*
* @param shortName
* @param authorityName
* @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);
public void setRoleComparator(Comparator<String> roleComparator) {
this.roleComparator = roleComparator;
if (siteUserMangers.size() + siteGroupManagers.size() == 1)
{
throw new SiteServiceException(MSG_DO_NOT_CHANGE_MGR, new Object[] {authorityName});
}
}
}
public Comparator<String> getRoleComparator() {
return roleComparator;
}
}

View File

@@ -207,7 +207,6 @@ public class People extends BaseTemplateProcessorExtension implements Initializi
* Gets the members (people) of a group (including all sub-groups)
*
* @param group the group to retrieve members for
* @param recurse recurse into sub-groups
*
* @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
*
* @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)
{
@@ -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
*
* @return true if an admin, false otherwise
* @return true if a guest user, false otherwise
*/
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.
*
* @param person
* the person
* @param person the person
* @return the capability map
*/
public Map<String, Boolean> getCapabilities(final TemplateNode person)