mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
AVMLockingAwareService lazily creates web project entries.
AVMLockingService should handle the content manager role correctly. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6009 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -333,6 +333,12 @@
|
|||||||
<property name="retryingTransactionHelper">
|
<property name="retryingTransactionHelper">
|
||||||
<ref bean="retryingTransactionHelper"/>
|
<ref bean="retryingTransactionHelper"/>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="nodeService">
|
||||||
|
<ref bean="nodeService"/>
|
||||||
|
</property>
|
||||||
|
<property name="searchService">
|
||||||
|
<ref bean="searchService"/>
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
@@ -825,6 +825,7 @@ public class AVMLockingAwareService implements AVMService
|
|||||||
{
|
{
|
||||||
throw new AVMLockingException(userName + " does not have access to " + path);
|
throw new AVMLockingException(userName + " does not have access to " + path);
|
||||||
}
|
}
|
||||||
|
fLockingService.addWebProject(webProject);
|
||||||
if (fLockingService.getLock(webProject, storePath[1]) == null)
|
if (fLockingService.getLock(webProject, storePath[1]) == null)
|
||||||
{
|
{
|
||||||
List<String> owners = new ArrayList<String>();
|
List<String> owners = new ArrayList<String>();
|
||||||
|
@@ -112,7 +112,6 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
AuthenticationService authService = (AuthenticationService)fContext.getBean("AuthenticationService");
|
AuthenticationService authService = (AuthenticationService)fContext.getBean("AuthenticationService");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lockingService.addWebProject("main");
|
|
||||||
fService.setStoreProperty("main", QName.createQName(null, ".dns.main"),
|
fService.setStoreProperty("main", QName.createQName(null, ".dns.main"),
|
||||||
new PropertyValue(QName.createQName(null, "silly"), "Nothing."));
|
new PropertyValue(QName.createQName(null, "silly"), "Nothing."));
|
||||||
fService.createStore("test");
|
fService.createStore("test");
|
||||||
|
@@ -30,10 +30,12 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.alfresco.model.WCMAppModel;
|
||||||
import org.alfresco.repo.attributes.Attribute;
|
import org.alfresco.repo.attributes.Attribute;
|
||||||
import org.alfresco.repo.attributes.ListAttributeValue;
|
import org.alfresco.repo.attributes.ListAttributeValue;
|
||||||
import org.alfresco.repo.attributes.MapAttributeValue;
|
import org.alfresco.repo.attributes.MapAttributeValue;
|
||||||
import org.alfresco.repo.attributes.StringAttributeValue;
|
import org.alfresco.repo.attributes.StringAttributeValue;
|
||||||
|
import org.alfresco.repo.node.db.DbNodeServiceImpl;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
import org.alfresco.service.cmr.attributes.AttrQueryEquals;
|
import org.alfresco.service.cmr.attributes.AttrQueryEquals;
|
||||||
import org.alfresco.service.cmr.attributes.AttributeService;
|
import org.alfresco.service.cmr.attributes.AttributeService;
|
||||||
@@ -42,6 +44,12 @@ import org.alfresco.service.cmr.avm.AVMExistsException;
|
|||||||
import org.alfresco.service.cmr.avm.AVMNotFoundException;
|
import org.alfresco.service.cmr.avm.AVMNotFoundException;
|
||||||
import org.alfresco.service.cmr.avm.locking.AVMLock;
|
import org.alfresco.service.cmr.avm.locking.AVMLock;
|
||||||
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
|
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
|
||||||
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
import org.alfresco.service.cmr.search.ResultSet;
|
||||||
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
import org.alfresco.service.cmr.security.AuthorityService;
|
import org.alfresco.service.cmr.security.AuthorityService;
|
||||||
import org.alfresco.service.cmr.security.AuthorityType;
|
import org.alfresco.service.cmr.security.AuthorityType;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
@@ -59,6 +67,11 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
|||||||
public static final String USERS = "users";
|
public static final String USERS = "users";
|
||||||
public static final String STORES = "stores";
|
public static final String STORES = "stores";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SearchService for access to web project properties.
|
||||||
|
*/
|
||||||
|
private SearchService fSearchService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AttributeService reference.
|
* AttributeService reference.
|
||||||
*/
|
*/
|
||||||
@@ -74,6 +87,11 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
|||||||
*/
|
*/
|
||||||
private PersonService fPersonService;
|
private PersonService fPersonService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The NodeService.
|
||||||
|
*/
|
||||||
|
private NodeService fNodeService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transaction Helper reference.
|
* Transaction Helper reference.
|
||||||
*/
|
*/
|
||||||
@@ -119,6 +137,16 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
|||||||
fRetryingTransactionHelper = helper;
|
fRetryingTransactionHelper = helper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSearchService(SearchService service)
|
||||||
|
{
|
||||||
|
fSearchService = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodeService(NodeService service)
|
||||||
|
{
|
||||||
|
fNodeService = service;
|
||||||
|
}
|
||||||
|
|
||||||
public void init()
|
public void init()
|
||||||
{
|
{
|
||||||
RetryingTransactionHelper.RetryingTransactionCallback<Object> callback =
|
RetryingTransactionHelper.RetryingTransactionCallback<Object> callback =
|
||||||
@@ -327,7 +355,7 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
|||||||
keys.add(webProject);
|
keys.add(webProject);
|
||||||
if (fAttributeService.getAttribute(keys) != null)
|
if (fAttributeService.getAttribute(keys) != null)
|
||||||
{
|
{
|
||||||
throw new AVMExistsException("Web Project Exists: " + webProject);
|
return;
|
||||||
}
|
}
|
||||||
keys.remove(2);
|
keys.remove(2);
|
||||||
fAttributeService.setAttribute(keys, webProject, new MapAttributeValue());
|
fAttributeService.setAttribute(keys, webProject, new MapAttributeValue());
|
||||||
@@ -516,6 +544,23 @@ public class AVMLockingServiceImpl implements AVMLockingService
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
|
||||||
|
ResultSet results = fSearchService.query(storeRef, "lucene", "@wca\\:avmstore:\"" + webProject + "\" +TYPE:\"wca:webfolder\"");
|
||||||
|
System.out.println(results.getNodeRefs());
|
||||||
|
if (results.getNodeRefs().size() == 1)
|
||||||
|
{
|
||||||
|
List<ChildAssociationRef> children = fNodeService.getChildAssocs(results.getNodeRefs().get(0));
|
||||||
|
for (ChildAssociationRef child : children)
|
||||||
|
{
|
||||||
|
NodeRef childRef = child.getChildRef();
|
||||||
|
if (fNodeService.getType(childRef).equals(WCMAppModel.TYPE_WEBUSER) &&
|
||||||
|
fNodeService.getProperty(childRef, WCMAppModel.PROP_WEBUSERNAME).equals(user) &&
|
||||||
|
fNodeService.getProperty(childRef, WCMAppModel.PROP_WEBUSERROLE).equals("ContentManager"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
String[] storePath = avmPath.split(":");
|
String[] storePath = avmPath.split(":");
|
||||||
if (storePath.length != 2)
|
if (storePath.length != 2)
|
||||||
{
|
{
|
||||||
|
@@ -89,7 +89,7 @@ public interface AVMLockingService
|
|||||||
public List<AVMLock> getUsersLocks(String user);
|
public List<AVMLock> getUsersLocks(String user);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a web project to the locking tables.
|
* Add a web project to the locking tables if it doesn't already exist.
|
||||||
* @param webProject The web project name.
|
* @param webProject The web project name.
|
||||||
*/
|
*/
|
||||||
public void addWebProject(String webProject);
|
public void addWebProject(String webProject);
|
||||||
|
Reference in New Issue
Block a user