mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Morning merge.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@2959 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -81,7 +81,7 @@ public class EhCacheTracerJob implements Job
|
||||
}
|
||||
|
||||
long maxHeapSize = Runtime.getRuntime().maxMemory();
|
||||
long totalSize = 0L;
|
||||
long allCachesTotalSize = 0L;
|
||||
double estimatedMaxSize = 0L;
|
||||
// get all the caches
|
||||
String[] cacheNames = cacheManager.getCacheNames();
|
||||
@@ -97,16 +97,19 @@ public class EhCacheTracerJob implements Job
|
||||
CacheAnalysis analysis = new CacheAnalysis(cache);
|
||||
logger.debug(analysis);
|
||||
// get the size
|
||||
totalSize += analysis.getSize();
|
||||
estimatedMaxSize += Double.isNaN(analysis.getEstimatedMaxSize()) ? 0.0 : analysis.getEstimatedMaxSize();
|
||||
allCachesTotalSize += analysis.getSize();
|
||||
double cacheEstimatedMaxSize = analysis.getEstimatedMaxSize();
|
||||
estimatedMaxSize += (Double.isNaN(cacheEstimatedMaxSize) || Double.isInfinite(cacheEstimatedMaxSize))
|
||||
? 0.0
|
||||
: cacheEstimatedMaxSize;
|
||||
}
|
||||
// check the size
|
||||
double sizePercentage = (double)totalSize / (double)maxHeapSize * 100.0;
|
||||
double sizePercentage = (double)allCachesTotalSize / (double)maxHeapSize * 100.0;
|
||||
double maxSizePercentage = estimatedMaxSize / (double)maxHeapSize * 100.0;
|
||||
String msg = String.format(
|
||||
"EHCaches currently consume %5.2f MB or %3.2f percent of system VM size. \n" +
|
||||
"The estimated maximum size is %5.2f MB or %3.2f percent of system VM size.",
|
||||
(double)totalSize / 1024.0 / 1024.0,
|
||||
(double)allCachesTotalSize / 1024.0 / 1024.0,
|
||||
sizePercentage,
|
||||
estimatedMaxSize / 1024.0 / 1024.0,
|
||||
maxSizePercentage);
|
||||
@@ -156,11 +159,22 @@ public class EhCacheTracerJob implements Job
|
||||
{
|
||||
// calculate the cache deep size - EHCache 1.1 is always returning 0L
|
||||
List<Serializable> keys = cache.getKeys();
|
||||
// only count a maximum of 1000 entities
|
||||
int count = 0;
|
||||
for (Serializable key : keys)
|
||||
{
|
||||
Element element = cache.get(key);
|
||||
size += getSize(element);
|
||||
count++;
|
||||
if (count >= 50)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// the size must be multiplied by the ratio of the count to actual size
|
||||
size = count > 0 ? (long) ((double)size * ((double)keys.size()/(double)count)) : 0L;
|
||||
|
||||
sizeMB = (double)size/1024.0/1024.0;
|
||||
maxSize = cache.getMaxElementsInMemory();
|
||||
currentSize = cache.getMemoryStoreSize();
|
||||
|
@@ -518,8 +518,14 @@ public class FileFolderServiceImpl implements FileFolderService
|
||||
qname,
|
||||
true);
|
||||
}
|
||||
// changed the name property
|
||||
nodeService.setProperty(targetNodeRef, ContentModel.PROP_NAME, newName);
|
||||
|
||||
// Only update the name if it has changed
|
||||
String currentName = (String)nodeService.getProperty(targetNodeRef, ContentModel.PROP_NAME);
|
||||
if (currentName.equals(newName) == false)
|
||||
{
|
||||
// changed the name property
|
||||
nodeService.setProperty(targetNodeRef, ContentModel.PROP_NAME, newName);
|
||||
}
|
||||
|
||||
// get the details after the operation
|
||||
FileInfo afterFileInfo = toFileInfo(targetNodeRef);
|
||||
|
@@ -88,4 +88,12 @@ public interface AuthorityDAO
|
||||
* @return
|
||||
*/
|
||||
Set<String> getAllAuthorities(AuthorityType type);
|
||||
|
||||
/**
|
||||
* Test if an authority already exists.
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
boolean authorityExists(String name);
|
||||
}
|
||||
|
@@ -89,6 +89,13 @@ public class AuthorityDAOImpl implements AuthorityDAO
|
||||
this.userToAuthorityCache = userToAuthorityCache;
|
||||
}
|
||||
|
||||
public boolean authorityExists(String name)
|
||||
{
|
||||
NodeRef ref = getAuthorityOrNull(name);
|
||||
return ref != null;
|
||||
}
|
||||
|
||||
|
||||
public void addAuthority(String parentName, String childName)
|
||||
{
|
||||
NodeRef parentRef = getAuthorityOrNull(parentName);
|
||||
|
@@ -241,4 +241,9 @@ public class AuthorityServiceImpl implements AuthorityService
|
||||
authorityDAO.removeAuthority(parentName, childName);
|
||||
}
|
||||
|
||||
public boolean authorityExists(String name)
|
||||
{
|
||||
return authorityDAO.authorityExists(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -237,9 +237,11 @@ public class AuthorityServiceTest extends TestCase
|
||||
String auth4;
|
||||
String auth5;
|
||||
|
||||
assertFalse(pubAuthorityService.authorityExists(pubAuthorityService.getName(AuthorityType.GROUP, "one")));
|
||||
assertEquals(0, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
|
||||
assertEquals(0, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size());
|
||||
auth1 = pubAuthorityService.createAuthority(AuthorityType.GROUP, null, "one");
|
||||
assertTrue(pubAuthorityService.authorityExists(auth1));
|
||||
assertEquals(1, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
|
||||
assertEquals(1, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size());
|
||||
auth2 = pubAuthorityService.createAuthority(AuthorityType.GROUP, null, "two");
|
||||
|
@@ -207,4 +207,9 @@ public class SimpleAuthorityServiceImpl implements AuthorityService
|
||||
|
||||
}
|
||||
|
||||
public boolean authorityExists(String name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@ import javax.transaction.UserTransaction;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
@@ -91,7 +92,7 @@ public class SimpleAuthorityServiceTest extends TestCase
|
||||
@Override
|
||||
protected void tearDown() throws Exception
|
||||
{
|
||||
authenticationService.clearCurrentSecurityContext();
|
||||
AuthenticationUtil.clearCurrentSecurityContext();
|
||||
tx.rollback();
|
||||
super.tearDown();
|
||||
}
|
||||
@@ -106,6 +107,8 @@ public class SimpleAuthorityServiceTest extends TestCase
|
||||
|
||||
public void testAdminUser()
|
||||
{
|
||||
assertFalse(authorityService.authorityExists("woof"));
|
||||
|
||||
authenticationComponent.setCurrentUser("admin");
|
||||
assertTrue(authorityService.hasAdminAuthority());
|
||||
assertTrue(pubAuthorityService.hasAdminAuthority());
|
||||
@@ -119,6 +122,7 @@ public class SimpleAuthorityServiceTest extends TestCase
|
||||
|
||||
public void testAuthorities()
|
||||
{
|
||||
assertFalse(pubAuthorityService.authorityExists("woof"));
|
||||
assertEquals(1, pubAuthorityService.getAllAuthorities(AuthorityType.ADMIN).size());
|
||||
assertTrue(pubAuthorityService.getAllAuthorities(AuthorityType.ADMIN).contains(
|
||||
PermissionService.ADMINISTRATOR_AUTHORITY));
|
||||
|
Reference in New Issue
Block a user