mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-16 17:55:15 +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:
parent
7440ae18a6
commit
a5d07e1069
@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
lock_service.insufficent_privileges=You have insufficent privileges to release the lock on the node (id: {0}). The node is locked by another user.
|
lock_service.insufficent_privileges=You have insufficent privileges to release the lock on the node (id: {0}). The node is locked by another user.
|
||||||
lock_service.node_locked=The node (id: {0}) could not be locked since it is already locked by another user.
|
lock_service.node_locked=The node (id: {0}) could not be locked since it is already locked by another user.
|
||||||
lock_service.no_op=Can not perform operation since the node (id:{0}) is locked by another user.
|
lock_service.no_op=Can not perform operation since the node (id:{0}) is locked.
|
||||||
lock_service.no_op2=Can not perform operation {0} since the node (id:{1}) is locked by another user.
|
lock_service.no_op2=Can not perform operation {0} since the node (id:{1}) is locked.
|
||||||
|
@ -807,6 +807,12 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="transactionAttributes">
|
<property name="transactionAttributes">
|
||||||
<props>
|
<props>
|
||||||
|
<prop key="getCurrentUserName">PROPAGATION_NOT_SUPPORTED, readOnly</prop>
|
||||||
|
<prop key="invalidateUserSession">PROPAGATION_NOT_SUPPORTED, readOnly</prop>
|
||||||
|
<prop key="invalidateTicket">PROPAGATION_NOT_SUPPORTED, readOnly</prop>
|
||||||
|
<prop key="getCurrentTicket">PROPAGATION_NOT_SUPPORTED, readOnly</prop>
|
||||||
|
<prop key="clearCurrentSecurityContext">PROPAGATION_NOT_SUPPORTED, readOnly</prop>
|
||||||
|
<prop key="isCurrentUserTheSystemUser">PROPAGATION_NOT_SUPPORTED, readOnly</prop>
|
||||||
<prop key="*">${server.transaction.mode.default}</prop>
|
<prop key="*">${server.transaction.mode.default}</prop>
|
||||||
</props>
|
</props>
|
||||||
</property>
|
</property>
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
<bean id="permissionServiceImpl" class="org.alfresco.repo.security.permissions.impl.PermissionServiceImpl">
|
<bean id="permissionServiceImpl" class="org.alfresco.repo.security.permissions.impl.AllowPermissionServiceImpl">
|
||||||
<property name="nodeService">
|
<property name="nodeService">
|
||||||
<ref bean="nodeService" />
|
<ref bean="nodeService" />
|
||||||
</property>
|
</property>
|
||||||
@ -578,6 +578,7 @@
|
|||||||
org.alfresco.service.cmr.security.AuthorityService.getContainingAuthorities=ACL_ALLOW
|
org.alfresco.service.cmr.security.AuthorityService.getContainingAuthorities=ACL_ALLOW
|
||||||
org.alfresco.service.cmr.security.AuthorityService.getShortName=ACL_ALLOW
|
org.alfresco.service.cmr.security.AuthorityService.getShortName=ACL_ALLOW
|
||||||
org.alfresco.service.cmr.security.AuthorityService.getName=ACL_ALLOW
|
org.alfresco.service.cmr.security.AuthorityService.getName=ACL_ALLOW
|
||||||
|
org.alfresco.service.cmr.security.AuthorityService.authorityExists=ACL_METHOD.ROLE_ADMINISTRATOR
|
||||||
</value>
|
</value>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
@ -27,6 +27,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
@ -1743,7 +1744,7 @@ public class ServerConfiguration implements ApplicationListener
|
|||||||
if (platformStr == null || platformStr.length() == 0)
|
if (platformStr == null || platformStr.length() == 0)
|
||||||
return platformTypes;
|
return platformTypes;
|
||||||
|
|
||||||
StringTokenizer token = new StringTokenizer(platformStr.toUpperCase(), ",");
|
StringTokenizer token = new StringTokenizer(platformStr.toUpperCase(Locale.ENGLISH), ",");
|
||||||
String typ = null;
|
String typ = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -214,16 +214,21 @@ public class CifsHelper
|
|||||||
|
|
||||||
// Check the lock status of the file
|
// Check the lock status of the file
|
||||||
|
|
||||||
if ( hasLockedFilesAsOffline())
|
String lockTypeStr = (String) nodeProperties.get(ContentModel.PROP_LOCK_TYPE);
|
||||||
{
|
|
||||||
String lockTypeStr = (String) nodeProperties.get(ContentModel.PROP_LOCK_TYPE);
|
|
||||||
|
|
||||||
if ( lockTypeStr != null)
|
if ( lockTypeStr != null)
|
||||||
{
|
{
|
||||||
// File is locked so mark it as offline
|
// File is locked so mark it as read-only and offline
|
||||||
|
|
||||||
fileInfo.setFileAttributes(fileInfo.getFileAttributes() + FileAttribute.NTOffline);
|
int attr = fileInfo.getFileAttributes();
|
||||||
}
|
|
||||||
|
if (( attr & FileAttribute.ReadOnly) == 0)
|
||||||
|
attr += FileAttribute.ReadOnly;
|
||||||
|
|
||||||
|
if ( hasLockedFilesAsOffline())
|
||||||
|
attr += FileAttribute.NTOffline;
|
||||||
|
|
||||||
|
fileInfo.setFileAttributes( attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,4 +226,24 @@ public class ContentContext extends DiskDeviceContext
|
|||||||
{
|
{
|
||||||
m_urlFileName = urlFileName;
|
m_urlFileName = urlFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close the filesystem context
|
||||||
|
*/
|
||||||
|
public void CloseContext() {
|
||||||
|
|
||||||
|
// Check if file states are enabled
|
||||||
|
|
||||||
|
if ( hasStateTable())
|
||||||
|
{
|
||||||
|
// Shutdown the file state checker thread
|
||||||
|
|
||||||
|
getStateTable().shutdownRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the base class
|
||||||
|
|
||||||
|
super.CloseContext();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -519,20 +519,24 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
{
|
{
|
||||||
// Get the file information for the node
|
// Get the file information for the node
|
||||||
|
|
||||||
|
session.beginTransaction(transactionService, true);
|
||||||
finfo = cifsHelper.getFileInformation(nodeRef);
|
finfo = cifsHelper.getFileInformation(nodeRef);
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
|
|
||||||
if ( logger.isDebugEnabled())
|
if ( logger.isInfoEnabled())
|
||||||
logger.debug("getInfo using cached noderef for path " + path);
|
logger.debug("getInfo using cached noderef for path " + path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the required node was not in the state cache, the parent folder node might be
|
// If the required node was not in the state cache, the parent folder node might be
|
||||||
|
|
||||||
session.beginTransaction(transactionService, true);
|
|
||||||
|
|
||||||
if ( finfo == null)
|
if ( finfo == null)
|
||||||
{
|
{
|
||||||
|
// Start a transaction
|
||||||
|
|
||||||
|
session.beginTransaction(transactionService, true);
|
||||||
|
|
||||||
String[] paths = FileName.splitPath( path);
|
String[] paths = FileName.splitPath( path);
|
||||||
|
|
||||||
if ( paths[0] != null && paths[0].length() > 1)
|
if ( paths[0] != null && paths[0].length() > 1)
|
||||||
@ -548,7 +552,7 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
|
|
||||||
if ( logger.isDebugEnabled())
|
if ( logger.isInfoEnabled())
|
||||||
logger.debug("getInfo using cached noderef for parent " + path);
|
logger.debug("getInfo using cached noderef for parent " + path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -906,6 +910,13 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
if ( params.hasAccessMode(AccessMode.NTDelete) &&
|
if ( params.hasAccessMode(AccessMode.NTDelete) &&
|
||||||
permissionService.hasPermission(nodeRef, PermissionService.DELETE) == AccessStatus.DENIED)
|
permissionService.hasPermission(nodeRef, PermissionService.DELETE) == AccessStatus.DENIED)
|
||||||
throw new AccessDeniedException("No delete access to " + params.getFullPath());
|
throw new AccessDeniedException("No delete access to " + params.getFullPath());
|
||||||
|
|
||||||
|
// Check if the file has a lock
|
||||||
|
|
||||||
|
String lockTypeStr = (String) nodeService.getProperty( nodeRef, ContentModel.PROP_LOCK_TYPE);
|
||||||
|
|
||||||
|
if ( params.hasAccessMode(AccessMode.NTWrite) && lockTypeStr != null)
|
||||||
|
throw new AccessDeniedException("File is locked, no write access to " + params.getFullPath());
|
||||||
|
|
||||||
// Check if there is a file state for the file
|
// Check if there is a file state for the file
|
||||||
|
|
||||||
@ -1042,7 +1053,7 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
|
|
||||||
if ( logger.isDebugEnabled())
|
if ( logger.isInfoEnabled())
|
||||||
logger.debug("Create file using cached noderef for path " + paths[0]);
|
logger.debug("Create file using cached noderef for path " + paths[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1084,6 +1095,7 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
" node: " + nodeRef + "\n" +
|
" node: " + nodeRef + "\n" +
|
||||||
" network file: " + netFile);
|
" network file: " + netFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
return netFile;
|
return netFile;
|
||||||
}
|
}
|
||||||
catch (org.alfresco.repo.security.permissions.AccessDeniedException ex)
|
catch (org.alfresco.repo.security.permissions.AccessDeniedException ex)
|
||||||
@ -1860,6 +1872,12 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
// check that the node exists
|
// check that the node exists
|
||||||
if (nodeService.exists(fstate.getNodeRef()))
|
if (nodeService.exists(fstate.getNodeRef()))
|
||||||
{
|
{
|
||||||
|
// Bump the file states expiry time
|
||||||
|
|
||||||
|
fstate.setExpiryTime(System.currentTimeMillis() + FileState.DefTimeout);
|
||||||
|
|
||||||
|
// Return the cached noderef
|
||||||
|
|
||||||
return fstate.getNodeRef();
|
return fstate.getNodeRef();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -50,6 +50,14 @@ public class FileStateTable implements Runnable
|
|||||||
|
|
||||||
private long m_cacheTimer = 2 * 60000L; // 2 minutes default
|
private long m_cacheTimer = 2 * 60000L; // 2 minutes default
|
||||||
|
|
||||||
|
// File state checker thread
|
||||||
|
|
||||||
|
private Thread m_thread;
|
||||||
|
|
||||||
|
// Shutdown request flag
|
||||||
|
|
||||||
|
private boolean m_shutdown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class constructor
|
* Class constructor
|
||||||
*/
|
*/
|
||||||
@ -59,10 +67,10 @@ public class FileStateTable implements Runnable
|
|||||||
|
|
||||||
// Start the expired file state checker thread
|
// Start the expired file state checker thread
|
||||||
|
|
||||||
Thread th = new Thread(this);
|
m_thread = new Thread(this);
|
||||||
th.setDaemon(true);
|
m_thread.setDaemon(true);
|
||||||
th.setName("FileStateExpire");
|
m_thread.setName("FileStateExpire");
|
||||||
th.start();
|
m_thread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -366,7 +374,9 @@ public class FileStateTable implements Runnable
|
|||||||
|
|
||||||
// Loop forever
|
// Loop forever
|
||||||
|
|
||||||
while (true)
|
m_shutdown = false;
|
||||||
|
|
||||||
|
while ( m_shutdown == false)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Sleep for the required interval
|
// Sleep for the required interval
|
||||||
@ -379,6 +389,18 @@ public class FileStateTable implements Runnable
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for shutdown
|
||||||
|
|
||||||
|
if ( m_shutdown == true)
|
||||||
|
{
|
||||||
|
// Debug
|
||||||
|
|
||||||
|
if ( logger.isDebugEnabled())
|
||||||
|
logger.debug("FileStateExpire thread closing");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -401,6 +423,22 @@ public class FileStateTable implements Runnable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request the file state checker thread to shutdown
|
||||||
|
*/
|
||||||
|
public final void shutdownRequest() {
|
||||||
|
m_shutdown = true;
|
||||||
|
|
||||||
|
if ( m_thread != null)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
m_thread.interrupt();
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump the state cache entries to the specified stream
|
* Dump the state cache entries to the specified stream
|
||||||
*/
|
*/
|
||||||
|
@ -160,7 +160,7 @@ public class Win32NetBIOSLanaMonitor extends Thread
|
|||||||
|
|
||||||
m_listeners = new LanaListener[len];
|
m_listeners = new LanaListener[len];
|
||||||
}
|
}
|
||||||
else if ( lana > m_listeners.length)
|
else if ( lana >= m_listeners.length)
|
||||||
{
|
{
|
||||||
// Extend the LANA listener array
|
// Extend the LANA listener array
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ public class EhCacheTracerJob implements Job
|
|||||||
}
|
}
|
||||||
|
|
||||||
long maxHeapSize = Runtime.getRuntime().maxMemory();
|
long maxHeapSize = Runtime.getRuntime().maxMemory();
|
||||||
long totalSize = 0L;
|
long allCachesTotalSize = 0L;
|
||||||
double estimatedMaxSize = 0L;
|
double estimatedMaxSize = 0L;
|
||||||
// get all the caches
|
// get all the caches
|
||||||
String[] cacheNames = cacheManager.getCacheNames();
|
String[] cacheNames = cacheManager.getCacheNames();
|
||||||
@ -97,16 +97,19 @@ public class EhCacheTracerJob implements Job
|
|||||||
CacheAnalysis analysis = new CacheAnalysis(cache);
|
CacheAnalysis analysis = new CacheAnalysis(cache);
|
||||||
logger.debug(analysis);
|
logger.debug(analysis);
|
||||||
// get the size
|
// get the size
|
||||||
totalSize += analysis.getSize();
|
allCachesTotalSize += analysis.getSize();
|
||||||
estimatedMaxSize += Double.isNaN(analysis.getEstimatedMaxSize()) ? 0.0 : analysis.getEstimatedMaxSize();
|
double cacheEstimatedMaxSize = analysis.getEstimatedMaxSize();
|
||||||
|
estimatedMaxSize += (Double.isNaN(cacheEstimatedMaxSize) || Double.isInfinite(cacheEstimatedMaxSize))
|
||||||
|
? 0.0
|
||||||
|
: cacheEstimatedMaxSize;
|
||||||
}
|
}
|
||||||
// check the size
|
// 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;
|
double maxSizePercentage = estimatedMaxSize / (double)maxHeapSize * 100.0;
|
||||||
String msg = String.format(
|
String msg = String.format(
|
||||||
"EHCaches currently consume %5.2f MB or %3.2f percent of system VM size. \n" +
|
"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.",
|
"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,
|
sizePercentage,
|
||||||
estimatedMaxSize / 1024.0 / 1024.0,
|
estimatedMaxSize / 1024.0 / 1024.0,
|
||||||
maxSizePercentage);
|
maxSizePercentage);
|
||||||
@ -156,11 +159,22 @@ public class EhCacheTracerJob implements Job
|
|||||||
{
|
{
|
||||||
// calculate the cache deep size - EHCache 1.1 is always returning 0L
|
// calculate the cache deep size - EHCache 1.1 is always returning 0L
|
||||||
List<Serializable> keys = cache.getKeys();
|
List<Serializable> keys = cache.getKeys();
|
||||||
|
// only count a maximum of 1000 entities
|
||||||
|
int count = 0;
|
||||||
for (Serializable key : keys)
|
for (Serializable key : keys)
|
||||||
{
|
{
|
||||||
Element element = cache.get(key);
|
Element element = cache.get(key);
|
||||||
size += getSize(element);
|
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;
|
sizeMB = (double)size/1024.0/1024.0;
|
||||||
maxSize = cache.getMaxElementsInMemory();
|
maxSize = cache.getMaxElementsInMemory();
|
||||||
currentSize = cache.getMemoryStoreSize();
|
currentSize = cache.getMemoryStoreSize();
|
||||||
|
@ -518,8 +518,14 @@ public class FileFolderServiceImpl implements FileFolderService
|
|||||||
qname,
|
qname,
|
||||||
true);
|
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
|
// get the details after the operation
|
||||||
FileInfo afterFileInfo = toFileInfo(targetNodeRef);
|
FileInfo afterFileInfo = toFileInfo(targetNodeRef);
|
||||||
|
@ -88,4 +88,12 @@ public interface AuthorityDAO
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Set<String> getAllAuthorities(AuthorityType type);
|
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;
|
this.userToAuthorityCache = userToAuthorityCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean authorityExists(String name)
|
||||||
|
{
|
||||||
|
NodeRef ref = getAuthorityOrNull(name);
|
||||||
|
return ref != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addAuthority(String parentName, String childName)
|
public void addAuthority(String parentName, String childName)
|
||||||
{
|
{
|
||||||
NodeRef parentRef = getAuthorityOrNull(parentName);
|
NodeRef parentRef = getAuthorityOrNull(parentName);
|
||||||
|
@ -241,4 +241,9 @@ public class AuthorityServiceImpl implements AuthorityService
|
|||||||
authorityDAO.removeAuthority(parentName, childName);
|
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 auth4;
|
||||||
String auth5;
|
String auth5;
|
||||||
|
|
||||||
|
assertFalse(pubAuthorityService.authorityExists(pubAuthorityService.getName(AuthorityType.GROUP, "one")));
|
||||||
assertEquals(0, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
|
assertEquals(0, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
|
||||||
assertEquals(0, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size());
|
assertEquals(0, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size());
|
||||||
auth1 = pubAuthorityService.createAuthority(AuthorityType.GROUP, null, "one");
|
auth1 = pubAuthorityService.createAuthority(AuthorityType.GROUP, null, "one");
|
||||||
|
assertTrue(pubAuthorityService.authorityExists(auth1));
|
||||||
assertEquals(1, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
|
assertEquals(1, pubAuthorityService.getAllAuthorities(AuthorityType.GROUP).size());
|
||||||
assertEquals(1, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size());
|
assertEquals(1, pubAuthorityService.getAllRootAuthorities(AuthorityType.GROUP).size());
|
||||||
auth2 = pubAuthorityService.createAuthority(AuthorityType.GROUP, null, "two");
|
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 junit.framework.TestCase;
|
||||||
|
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||||
@ -91,7 +92,7 @@ public class SimpleAuthorityServiceTest extends TestCase
|
|||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception
|
protected void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
authenticationService.clearCurrentSecurityContext();
|
AuthenticationUtil.clearCurrentSecurityContext();
|
||||||
tx.rollback();
|
tx.rollback();
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
@ -106,6 +107,8 @@ public class SimpleAuthorityServiceTest extends TestCase
|
|||||||
|
|
||||||
public void testAdminUser()
|
public void testAdminUser()
|
||||||
{
|
{
|
||||||
|
assertFalse(authorityService.authorityExists("woof"));
|
||||||
|
|
||||||
authenticationComponent.setCurrentUser("admin");
|
authenticationComponent.setCurrentUser("admin");
|
||||||
assertTrue(authorityService.hasAdminAuthority());
|
assertTrue(authorityService.hasAdminAuthority());
|
||||||
assertTrue(pubAuthorityService.hasAdminAuthority());
|
assertTrue(pubAuthorityService.hasAdminAuthority());
|
||||||
@ -119,6 +122,7 @@ public class SimpleAuthorityServiceTest extends TestCase
|
|||||||
|
|
||||||
public void testAuthorities()
|
public void testAuthorities()
|
||||||
{
|
{
|
||||||
|
assertFalse(pubAuthorityService.authorityExists("woof"));
|
||||||
assertEquals(1, pubAuthorityService.getAllAuthorities(AuthorityType.ADMIN).size());
|
assertEquals(1, pubAuthorityService.getAllAuthorities(AuthorityType.ADMIN).size());
|
||||||
assertTrue(pubAuthorityService.getAllAuthorities(AuthorityType.ADMIN).contains(
|
assertTrue(pubAuthorityService.getAllAuthorities(AuthorityType.ADMIN).contains(
|
||||||
PermissionService.ADMINISTRATOR_AUTHORITY));
|
PermissionService.ADMINISTRATOR_AUTHORITY));
|
||||||
|
@ -171,5 +171,13 @@ public interface AuthorityService
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getName(AuthorityType type, String shortName);
|
public String getName(AuthorityType type, String shortName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if an authority exists.
|
||||||
|
*
|
||||||
|
* @param name (the long name).
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean authorityExists(String name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user