mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merge DEV\WCM_SERVICES2 to HEAD
12513 Implementation of Asset.getProperties 12469 Implement paths relative to web app. And unit tests. Asset Test is now clean of TODOs. 12413 Implementation of WCM Asset. Still work remaining but this is 80% of the implementation. 12404 WCM Services - asset service - fix rename/move folder issue (folders are not locked) - sandbox service - fix delete sandbox test 12374 WCM Services - optimise get/is web project 12347 WCM Services - "asset service" - add/remove/has aspect, get aspects 12341 WCM Services - "asset service" checkpoint (locking fixes, bulk import, more tests added) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12547 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -229,6 +229,7 @@
|
|||||||
<property name="webProjectService" ref="WebProjectService"/>
|
<property name="webProjectService" ref="WebProjectService"/>
|
||||||
<property name="sandboxService" ref="SandboxService"/>
|
<property name="sandboxService" ref="SandboxService"/>
|
||||||
<property name="assetService" ref="AssetService"/>
|
<property name="assetService" ref="AssetService"/>
|
||||||
|
<property name="namespaceService" ref="NamespaceService"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
@@ -50,6 +50,7 @@ import org.alfresco.service.cmr.repository.ContentWriter;
|
|||||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
|
import org.alfresco.wcm.util.WCMUtil;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.context.ApplicationContextAware;
|
||||||
@@ -680,8 +681,11 @@ public class AVMLockingAwareService implements AVMService, ApplicationContextAwa
|
|||||||
fService.removeNode(parent, name);
|
fService.removeNode(parent, name);
|
||||||
String[] storePath = parent.split(":");
|
String[] storePath = parent.split(":");
|
||||||
fService.createSnapshot(storePath[0], null, null);
|
fService.createSnapshot(storePath[0], null, null);
|
||||||
fLockingService.removeLocksInDirectory(getWebProject(storePath[0]), storePath[0],
|
String webProject = getWebProject(storePath[0]);
|
||||||
storePath[1] + '/' + name);
|
if (webProject != null)
|
||||||
|
{
|
||||||
|
fLockingService.removeLocksInDirectory(webProject, storePath[0], storePath[1] + '/' + name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -693,7 +697,11 @@ public class AVMLockingAwareService implements AVMService, ApplicationContextAwa
|
|||||||
fService.removeNode(path);
|
fService.removeNode(path);
|
||||||
String[] storePath = path.split(":");
|
String[] storePath = path.split(":");
|
||||||
fService.createSnapshot(storePath[0], null, null);
|
fService.createSnapshot(storePath[0], null, null);
|
||||||
fLockingService.removeLocksInDirectory(getWebProject(storePath[0]), storePath[0], storePath[1]);
|
String webProject = getWebProject(storePath[0]);
|
||||||
|
if (webProject != null)
|
||||||
|
{
|
||||||
|
fLockingService.removeLocksInDirectory(webProject, storePath[0], storePath[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -704,14 +712,26 @@ public class AVMLockingAwareService implements AVMService, ApplicationContextAwa
|
|||||||
{
|
{
|
||||||
// TODO Unresolved: how to deal with directory level locking.
|
// TODO Unresolved: how to deal with directory level locking.
|
||||||
// TODO This assumes that the rename occurs within the same web project.
|
// TODO This assumes that the rename occurs within the same web project.
|
||||||
grabLock(srcParent + '/' + srcName);
|
|
||||||
fService.rename(srcParent, srcName, dstParent, dstName);
|
String srcPath = srcParent + '/' + srcName;
|
||||||
String[] srcStorePath = splitPath(srcParent + '/' + srcName);
|
|
||||||
String[] dstStorePath = splitPath(dstParent + '/' + dstName);
|
AVMNodeDescriptor desc = fService.lookup(-1, srcPath, false);
|
||||||
String webProject = getWebProject(dstStorePath[0]);
|
if (! (desc != null && desc.isDirectory()))
|
||||||
if (webProject != null)
|
|
||||||
{
|
{
|
||||||
fLockingService.modifyLock(webProject, srcStorePath[1], dstStorePath[1], dstStorePath[0], null, null);
|
grabLock(srcParent + '/' + srcName);
|
||||||
|
}
|
||||||
|
|
||||||
|
fService.rename(srcParent, srcName, dstParent, dstName);
|
||||||
|
|
||||||
|
if (! (desc != null && desc.isDirectory()))
|
||||||
|
{
|
||||||
|
String[] srcStorePath = splitPath(srcParent + '/' + srcName);
|
||||||
|
String[] dstStorePath = splitPath(dstParent + '/' + dstName);
|
||||||
|
String webProject = getWebProject(dstStorePath[0]);
|
||||||
|
if (webProject != null)
|
||||||
|
{
|
||||||
|
fLockingService.modifyLock(webProject, srcStorePath[1], dstStorePath[1], dstStorePath[0], null, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -851,18 +871,13 @@ public class AVMLockingAwareService implements AVMService, ApplicationContextAwa
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getWebProject(String name)
|
private String getWebProject(String name)
|
||||||
{
|
{
|
||||||
Map<QName, PropertyValue> results = fService.queryStorePropertyKey(name, QName.createQName(null, ".dns%"));
|
String wpStoreId = WCMUtil.getWebProjectStoreId(name);
|
||||||
if (results.size() != 1)
|
if (WCMUtil.getWebProjectNodeFromWebProjectStore(fService, wpStoreId) != null)
|
||||||
{
|
{
|
||||||
return null;
|
return wpStoreId;
|
||||||
}
|
}
|
||||||
String dnsString = results.keySet().iterator().next().getLocalName();
|
return null;
|
||||||
String storeName = dnsString.substring(dnsString.lastIndexOf('.') + 1, dnsString.length());
|
|
||||||
final int index = storeName.indexOf(STORE_SEPARATOR);
|
|
||||||
return (index == -1
|
|
||||||
? storeName
|
|
||||||
: storeName.substring(0, index));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void grabLock(String path)
|
private void grabLock(String path)
|
||||||
|
@@ -268,17 +268,21 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
AVMService oldService = fService;
|
AVMService oldService = fService;
|
||||||
fService = (AVMService) fContext.getBean("AVMLockingAwareService");
|
fService = (AVMService) fContext.getBean("AVMLockingAwareService");
|
||||||
AuthenticationService authService = (AuthenticationService) fContext.getBean("AuthenticationService");
|
AuthenticationService authService = (AuthenticationService) fContext.getBean("AuthenticationService");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fService.setStoreProperty("main", QName.createQName(null, ".dns.main"), new PropertyValue(DataTypeDefinition.TEXT, "Nothing."));
|
// note: locking applies to WCM web projects, hence relies on WCM sandbox conventions (naming and properties)
|
||||||
fService.createStore("test");
|
fService.setStoreProperty("main", SandboxConstants.PROP_WEB_PROJECT_NODE_REF, new PropertyValue(DataTypeDefinition.NODE_REF, new NodeRef("workspace://SpacesStore/dummy")));
|
||||||
fService.setStoreProperty("test", QName.createQName(null, ".dns.test.main"), new PropertyValue(DataTypeDefinition.TEXT, "Nothing."));
|
|
||||||
|
fService.createStore("main--admin");
|
||||||
|
|
||||||
setupBasicTree0();
|
setupBasicTree0();
|
||||||
authService.authenticateAsGuest();
|
|
||||||
// assertEquals(0, fLockingService.getUsersLocks("admin").size());
|
|
||||||
List<AVMDifference> diffs = fSyncService.compare(-1, "main:/", -1, "test:/", null);
|
List<AVMDifference> diffs = fSyncService.compare(-1, "main:/", -1, "main--admin:/", null);
|
||||||
assertEquals(2, diffs.size());
|
assertEquals(2, diffs.size());
|
||||||
assertEquals("[main:/a[-1] > test:/a[-1], main:/d[-1] > test:/d[-1]]", diffs.toString());
|
assertEquals("[main:/a[-1] > main--admin:/a[-1], main:/d[-1] > main--admin:/d[-1]]", diffs.toString());
|
||||||
|
|
||||||
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
fSyncService.update(diffs, null, false, false, false, false, null, null);
|
||||||
RetryingTransactionHelper.RetryingTransactionCallback<Object> cb = new RetryingTransactionHelper.RetryingTransactionCallback<Object>()
|
RetryingTransactionHelper.RetryingTransactionCallback<Object> cb = new RetryingTransactionHelper.RetryingTransactionCallback<Object>()
|
||||||
{
|
{
|
||||||
@@ -286,7 +290,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
{
|
{
|
||||||
BulkLoader loader = new BulkLoader();
|
BulkLoader loader = new BulkLoader();
|
||||||
loader.setAvmService(fService);
|
loader.setAvmService(fService);
|
||||||
loader.recursiveLoad("source/java/org/alfresco/repo/avm", "main:/");
|
loader.recursiveLoad("source/java/org/alfresco/repo/avm", "main--admin:/");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -304,8 +308,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
fLockingService.removeStoreLocks("main");
|
fLockingService.removeStoreLocks("main");
|
||||||
fLockingService.removeWebProject("main");
|
fLockingService.removeWebProject("main");
|
||||||
authService.authenticate("admin", "admin".toCharArray());
|
authService.authenticate("admin", "admin".toCharArray());
|
||||||
|
fService.purgeStore("main--admin");
|
||||||
fService.purgeStore("test");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1967,6 +1970,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
final String STAGING = "foo-staging"; // note: it is implied that the website/webproject name is the same as staging name
|
final String STAGING = "foo-staging"; // note: it is implied that the website/webproject name is the same as staging name
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
fService.createStore(STAGING);
|
fService.createStore(STAGING);
|
||||||
fService.createDirectory(STAGING+":/", JNDIConstants.DIR_DEFAULT_WWW);
|
fService.createDirectory(STAGING+":/", JNDIConstants.DIR_DEFAULT_WWW);
|
||||||
fService.createDirectory(STAGING+":/" + JNDIConstants.DIR_DEFAULT_WWW, "a");
|
fService.createDirectory(STAGING+":/" + JNDIConstants.DIR_DEFAULT_WWW, "a");
|
||||||
@@ -1975,7 +1979,7 @@ public class AVMServiceTest extends AVMServiceTestBase
|
|||||||
fService.createFile(STAGING+":/" + JNDIConstants.DIR_DEFAULT_WWW + "/a/b/c", "foo").close();
|
fService.createFile(STAGING+":/" + JNDIConstants.DIR_DEFAULT_WWW + "/a/b/c", "foo").close();
|
||||||
fService.createFile(STAGING+":/" + JNDIConstants.DIR_DEFAULT_WWW + "/a/b/c", "bar").close();
|
fService.createFile(STAGING+":/" + JNDIConstants.DIR_DEFAULT_WWW + "/a/b/c", "bar").close();
|
||||||
fService.createStore("area");
|
fService.createStore("area");
|
||||||
fService.setStoreProperty("area", SandboxConstants.PROP_WEBSITE_NAME, new PropertyValue(null, STAGING)); // note: it is implied that the website name is the same as staging name
|
fService.setStoreProperty("area", SandboxConstants.PROP_WEBSITE_NAME, new PropertyValue(null, STAGING)); // note: it is implied that the website name is the same as staging name
|
||||||
fService.createLayeredDirectory(STAGING+":/" + JNDIConstants.DIR_DEFAULT_WWW, "area:/", JNDIConstants.DIR_DEFAULT_WWW);
|
fService.createLayeredDirectory(STAGING+":/" + JNDIConstants.DIR_DEFAULT_WWW, "area:/", JNDIConstants.DIR_DEFAULT_WWW);
|
||||||
fService.createFile("area:/" + JNDIConstants.DIR_DEFAULT_WWW, "figs").close();
|
fService.createFile("area:/" + JNDIConstants.DIR_DEFAULT_WWW, "figs").close();
|
||||||
fService.getFileOutputStream("area:/" + JNDIConstants.DIR_DEFAULT_WWW + "/a/b/c/foo").close();
|
fService.getFileOutputStream("area:/" + JNDIConstants.DIR_DEFAULT_WWW + "/a/b/c/foo").close();
|
||||||
|
@@ -28,6 +28,7 @@ import java.io.File;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
@@ -175,6 +176,40 @@ public interface AssetService
|
|||||||
*/
|
*/
|
||||||
public void updateAssetProperties(AssetInfo asset, Map<QName, Serializable> properties);
|
public void updateAssetProperties(AssetInfo asset, Map<QName, Serializable> properties);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply aspect to asset, with given properties (can be null)
|
||||||
|
*
|
||||||
|
* @param asset
|
||||||
|
* @param aspectName
|
||||||
|
* @param properties
|
||||||
|
*/
|
||||||
|
public void addAspect(AssetInfo asset, QName aspectName, Map<QName, Serializable> properties);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove aspect from asset, and any related properties
|
||||||
|
*
|
||||||
|
* @param asset
|
||||||
|
* @param aspectName
|
||||||
|
*/
|
||||||
|
public void removeAspect(AssetInfo asset, QName aspectName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get set of aspects applied to asset
|
||||||
|
*
|
||||||
|
* @param asset
|
||||||
|
* @return list of aspects
|
||||||
|
*/
|
||||||
|
public Set<QName> getAspects(AssetInfo asset);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True, if asset has given aspect applied
|
||||||
|
*
|
||||||
|
* @param asset
|
||||||
|
* @param aspectName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean hasAspect(AssetInfo asset, QName aspectName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List assets within given sandbox and webApp and path (within webApp), optionally include deleted
|
* List assets within given sandbox and webApp and path (within webApp), optionally include deleted
|
||||||
*
|
*
|
||||||
@@ -182,7 +217,7 @@ public interface AssetService
|
|||||||
* @param webApp
|
* @param webApp
|
||||||
* @param parentFolderPathRelativeToWebApp
|
* @param parentFolderPathRelativeToWebApp
|
||||||
* @param includeDeleted
|
* @param includeDeleted
|
||||||
* @return
|
* @return list of assets
|
||||||
*/
|
*/
|
||||||
public List<AssetInfo> listAssetsWebApp(String sbStoreId, String webApp, String parentFolderPathRelativeToWebApp, boolean includeDeleted);
|
public List<AssetInfo> listAssetsWebApp(String sbStoreId, String webApp, String parentFolderPathRelativeToWebApp, boolean includeDeleted);
|
||||||
|
|
||||||
@@ -192,7 +227,7 @@ public interface AssetService
|
|||||||
* @param sbStoreId
|
* @param sbStoreId
|
||||||
* @param parentFolderPath
|
* @param parentFolderPath
|
||||||
* @param includeDeleted
|
* @param includeDeleted
|
||||||
* @return
|
* @return list of assets
|
||||||
*/
|
*/
|
||||||
public List<AssetInfo> listAssets(String sbStoreId, String parentFolderPath, boolean includeDeleted);
|
public List<AssetInfo> listAssets(String sbStoreId, String parentFolderPath, boolean includeDeleted);
|
||||||
|
|
||||||
@@ -203,7 +238,7 @@ public interface AssetService
|
|||||||
* @param version
|
* @param version
|
||||||
* @param parentFolderPath
|
* @param parentFolderPath
|
||||||
* @param includeDeleted
|
* @param includeDeleted
|
||||||
* @return
|
* @return list of assets
|
||||||
*/
|
*/
|
||||||
public List<AssetInfo> listAssets(String sbStoreId, int version, String parentFolderPath, boolean includeDeleted);
|
public List<AssetInfo> listAssets(String sbStoreId, int version, String parentFolderPath, boolean includeDeleted);
|
||||||
|
|
||||||
|
@@ -35,6 +35,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.mbeans.VirtServerRegistry;
|
import org.alfresco.mbeans.VirtServerRegistry;
|
||||||
@@ -443,13 +444,54 @@ public class AssetServiceImpl implements AssetService
|
|||||||
private void setProperties(String avmPath, Map<QName, Serializable> properties)
|
private void setProperties(String avmPath, Map<QName, Serializable> properties)
|
||||||
{
|
{
|
||||||
NodeRef avmNodeRef = AVMNodeConverter.ToNodeRef(-1, avmPath);
|
NodeRef avmNodeRef = AVMNodeConverter.ToNodeRef(-1, avmPath);
|
||||||
avmNodeService.setProperties(avmNodeRef, properties); // note: assumes lock, if applicable, is taken by caller
|
avmNodeService.setProperties(avmNodeRef, properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.wcm.asset.AssetService#addAspect(org.alfresco.wcm.asset.AssetInfo, org.alfresco.service.namespace.QName, java.util.Map)
|
||||||
|
*/
|
||||||
|
public void addAspect(AssetInfo asset, QName aspectName, Map<QName, Serializable> properties)
|
||||||
|
{
|
||||||
|
addAspect(asset.getAvmPath(), aspectName, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addAspect(String avmPath, QName aspect, Map<QName, Serializable> properties)
|
private void addAspect(String avmPath, QName aspect, Map<QName, Serializable> properties)
|
||||||
{
|
{
|
||||||
NodeRef avmNodeRef = AVMNodeConverter.ToNodeRef(-1, avmPath);
|
NodeRef avmNodeRef = AVMNodeConverter.ToNodeRef(-1, avmPath);
|
||||||
avmNodeService.addAspect(avmNodeRef, aspect, properties); // note: assumes lock, if applicable, is taken by caller
|
avmNodeService.addAspect(avmNodeRef, aspect, properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.wcm.asset.AssetService#removeAspect(org.alfresco.wcm.asset.AssetInfo, org.alfresco.service.namespace.QName)
|
||||||
|
*/
|
||||||
|
public void removeAspect(AssetInfo asset, QName aspectName)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatory("asset", asset);
|
||||||
|
|
||||||
|
NodeRef avmNodeRef = AVMNodeConverter.ToNodeRef(-1, asset.getAvmPath());
|
||||||
|
avmNodeService.removeAspect(avmNodeRef, aspectName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.wcm.asset.AssetService#getAspects(org.alfresco.wcm.asset.AssetInfo)
|
||||||
|
*/
|
||||||
|
public Set<QName> getAspects(AssetInfo asset)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatory("asset", asset);
|
||||||
|
|
||||||
|
NodeRef avmNodeRef = AVMNodeConverter.ToNodeRef(asset.getSandboxVersion(), asset.getAvmPath());
|
||||||
|
return avmNodeService.getAspects(avmNodeRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.wcm.asset.AssetService#hasAspect(org.alfresco.wcm.asset.AssetInfo, org.alfresco.service.namespace.QName)
|
||||||
|
*/
|
||||||
|
public boolean hasAspect(AssetInfo asset, QName aspectName)
|
||||||
|
{
|
||||||
|
ParameterCheck.mandatory("asset", asset);
|
||||||
|
|
||||||
|
NodeRef avmNodeRef = AVMNodeConverter.ToNodeRef(asset.getSandboxVersion(), asset.getAvmPath());
|
||||||
|
return avmNodeService.hasAspect(avmNodeRef, aspectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@@ -199,7 +199,7 @@ public class AssetServiceImplTest extends TestCase
|
|||||||
assetService.createFolder(sbStoreId, path, "myFolder1", null);
|
assetService.createFolder(sbStoreId, path, "myFolder1", null);
|
||||||
|
|
||||||
// create (empty) file
|
// create (empty) file
|
||||||
assetService.createFile(sbStoreId, path+"/myFolder1", "myFile1", null);
|
assetService.createFile(sbStoreId, path+"/myFolder1", "myFile1", null); // ignore return
|
||||||
|
|
||||||
// get assets
|
// get assets
|
||||||
|
|
||||||
@@ -502,12 +502,6 @@ public class AssetServiceImplTest extends TestCase
|
|||||||
checkAssetInfo(myFile1Asset, "myFile1Renamed", path+"/myFolder1/myFolder2/myFile1Renamed", USER_ONE, true, false, false, true, USER_ONE);
|
checkAssetInfo(myFile1Asset, "myFile1Renamed", path+"/myFolder1/myFolder2/myFile1Renamed", USER_ONE, true, false, false, true, USER_ONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// TODO lock issue ...
|
|
||||||
// org.alfresco.service.cmr.avm.AVMNotFoundException: Lock not found for testAsset-1228476617644-rename:/www/avm_webapps/ROOT/myFolder1
|
|
||||||
// at org.alfresco.repo.avm.locking.AVMLockingServiceImpl.modifyLock(AVMLockingServiceImpl.java:490)
|
|
||||||
// at org.alfresco.repo.avm.AVMLockingAwareService.rename(AVMLockingAwareService.java:712)
|
|
||||||
|
|
||||||
public void testRenameFolder()
|
public void testRenameFolder()
|
||||||
{
|
{
|
||||||
// create web project (also creates staging sandbox and admin's author sandbox)
|
// create web project (also creates staging sandbox and admin's author sandbox)
|
||||||
@@ -536,20 +530,18 @@ public class AssetServiceImplTest extends TestCase
|
|||||||
AssetInfo myFolder2Asset = assetService.getAsset(sbStoreId, path+"/myFolder1/myFolder2");
|
AssetInfo myFolder2Asset = assetService.getAsset(sbStoreId, path+"/myFolder1/myFolder2");
|
||||||
checkAssetInfo(myFolder2Asset, "myFolder2", path+"/myFolder1/myFolder2", USER_ONE, false, true, false, false, null);
|
checkAssetInfo(myFolder2Asset, "myFolder2", path+"/myFolder1/myFolder2", USER_ONE, false, true, false, false, null);
|
||||||
|
|
||||||
// TODO lock issue ...
|
// rename folder 1
|
||||||
// org.alfresco.service.cmr.avm.AVMNotFoundException: Lock not found for testAsset-1228476617644-rename:/www/avm_webapps/ROOT/myFolder1
|
|
||||||
// at org.alfresco.repo.avm.locking.AVMLockingServiceImpl.modifyLock(AVMLockingServiceImpl.java:490)
|
|
||||||
//at org.alfresco.repo.avm.AVMLockingAwareService.rename(AVMLockingAwareService.java:712)
|
|
||||||
|
|
||||||
// rename folder
|
|
||||||
myFolder1Asset = assetService.renameAsset(myFolder1Asset, "myFolder1Renamed");
|
myFolder1Asset = assetService.renameAsset(myFolder1Asset, "myFolder1Renamed");
|
||||||
checkAssetInfo(myFolder1Asset, "myFolder1Renamed", path+"/myFolder1Renamed", USER_ONE, false, true, false, false, null);
|
checkAssetInfo(myFolder1Asset, "myFolder1Renamed", path+"/myFolder1Renamed", USER_ONE, false, true, false, false, null);
|
||||||
|
|
||||||
// rename folder
|
// rename folder 2
|
||||||
|
myFolder2Asset = assetService.getAsset(sbStoreId, path+"/myFolder1Renamed/myFolder2");
|
||||||
|
checkAssetInfo(myFolder2Asset, "myFolder2", path+"/myFolder1Renamed/myFolder2", USER_ONE, false, true, false, false, null);
|
||||||
|
|
||||||
myFolder2Asset = assetService.renameAsset(myFolder2Asset, "myFolder2Renamed");
|
myFolder2Asset = assetService.renameAsset(myFolder2Asset, "myFolder2Renamed");
|
||||||
checkAssetInfo(myFolder2Asset, "myFolder2Renamed", path+"/myFolder1/myFolder2Renamed", USER_ONE, false, true, false, false, null);
|
checkAssetInfo(myFolder2Asset, "myFolder2Renamed", path+"/myFolder1Renamed/myFolder2Renamed", USER_ONE, false, true, false, false, null);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
public void testCopyFile()
|
public void testCopyFile()
|
||||||
{
|
{
|
||||||
@@ -573,7 +565,7 @@ public class AssetServiceImplTest extends TestCase
|
|||||||
assetService.createFolder(sbStoreId, path, "myFolder1", null);
|
assetService.createFolder(sbStoreId, path, "myFolder1", null);
|
||||||
assetService.createFolder(sbStoreId, path+"/myFolder1", "myFolder2", null);
|
assetService.createFolder(sbStoreId, path+"/myFolder1", "myFolder2", null);
|
||||||
|
|
||||||
// create (nn-empty) file
|
// create (non-empty) file
|
||||||
final String MYFILE1 = "This is myFile1";
|
final String MYFILE1 = "This is myFile1";
|
||||||
ContentWriter writer = assetService.createFile(sbStoreId, path+"/myFolder1/myFolder2", "myFile1", null);
|
ContentWriter writer = assetService.createFile(sbStoreId, path+"/myFolder1/myFolder2", "myFile1", null);
|
||||||
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||||
@@ -584,9 +576,8 @@ public class AssetServiceImplTest extends TestCase
|
|||||||
AssetInfo myFile1Asset = assetService.getAsset(sbStoreId, path+"/myFolder1/myFolder2/myFile1");
|
AssetInfo myFile1Asset = assetService.getAsset(sbStoreId, path+"/myFolder1/myFolder2/myFile1");
|
||||||
checkAssetInfo(myFile1Asset, "myFile1", path+"/myFolder1/myFolder2/myFile1", USER_ONE, true, false, false, true, USER_ONE);
|
checkAssetInfo(myFile1Asset, "myFile1", path+"/myFolder1/myFolder2/myFile1", USER_ONE, true, false, false, true, USER_ONE);
|
||||||
|
|
||||||
myFile1Asset = assetService.copyAsset(myFile1Asset, path+"/myFolder1");
|
|
||||||
|
|
||||||
// TODO review - copied files are not locked ?
|
// TODO review - copied files are not locked ?
|
||||||
|
myFile1Asset = assetService.copyAsset(myFile1Asset, path+"/myFolder1");
|
||||||
//checkAssetInfo(myFile1Asset, "myFile1", path+"/myFolder1/myFile1", USER_ONE, true, false, false, true, USER_ONE);
|
//checkAssetInfo(myFile1Asset, "myFile1", path+"/myFolder1/myFile1", USER_ONE, true, false, false, true, USER_ONE);
|
||||||
checkAssetInfo(myFile1Asset, "myFile1", path+"/myFolder1/myFile1", USER_ONE, true, false, false, false, null);
|
checkAssetInfo(myFile1Asset, "myFile1", path+"/myFolder1/myFile1", USER_ONE, true, false, false, false, null);
|
||||||
}
|
}
|
||||||
@@ -664,7 +655,7 @@ public class AssetServiceImplTest extends TestCase
|
|||||||
assetService.createFolder(sbStoreId, path+"/myFolder1", "myFolder2", null);
|
assetService.createFolder(sbStoreId, path+"/myFolder1", "myFolder2", null);
|
||||||
|
|
||||||
// create (empty) file
|
// create (empty) file
|
||||||
assetService.createFile(sbStoreId, path+"/myFolder1/myFolder2", "myFile1", null);
|
assetService.createFile(sbStoreId, path+"/myFolder1/myFolder2", "myFile1", null); // ignore return
|
||||||
|
|
||||||
// move file
|
// move file
|
||||||
AssetInfo myFile1Asset = assetService.getAsset(sbStoreId, path+"/myFolder1/myFolder2/myFile1");
|
AssetInfo myFile1Asset = assetService.getAsset(sbStoreId, path+"/myFolder1/myFolder2/myFile1");
|
||||||
@@ -682,7 +673,7 @@ public class AssetServiceImplTest extends TestCase
|
|||||||
// org.alfresco.service.cmr.avm.AVMNotFoundException: Lock not found for testAsset-1228830920248-movefolder:/www/avm_webapps/ROOT/myFolder1/myFolder2
|
// org.alfresco.service.cmr.avm.AVMNotFoundException: Lock not found for testAsset-1228830920248-movefolder:/www/avm_webapps/ROOT/myFolder1/myFolder2
|
||||||
// at org.alfresco.repo.avm.locking.AVMLockingServiceImpl.modifyLock(AVMLockingServiceImpl.java:490)
|
// at org.alfresco.repo.avm.locking.AVMLockingServiceImpl.modifyLock(AVMLockingServiceImpl.java:490)
|
||||||
// at org.alfresco.repo.avm.AVMLockingAwareService.rename(AVMLockingAwareService.java:712)
|
// at org.alfresco.repo.avm.AVMLockingAwareService.rename(AVMLockingAwareService.java:712)
|
||||||
|
*/
|
||||||
public void testMoveFolder()
|
public void testMoveFolder()
|
||||||
{
|
{
|
||||||
// create web project (also creates staging sandbox and admin's author sandbox)
|
// create web project (also creates staging sandbox and admin's author sandbox)
|
||||||
@@ -705,12 +696,8 @@ public class AssetServiceImplTest extends TestCase
|
|||||||
assetService.createFolder(sbStoreId, path, "myFolder1", null);
|
assetService.createFolder(sbStoreId, path, "myFolder1", null);
|
||||||
assetService.createFolder(sbStoreId, path+"/myFolder1", "myFolder2", null);
|
assetService.createFolder(sbStoreId, path+"/myFolder1", "myFolder2", null);
|
||||||
|
|
||||||
// create (non-empty) file
|
// create (empty) file
|
||||||
//final String MYFILE1 = "This is myFile1";
|
assetService.createFile(sbStoreId, path+"/myFolder1/myFolder2", "myFile1", null); // ignore return
|
||||||
ContentWriter writer = assetService.createFile(sbStoreId, path+"/myFolder1/myFolder2", "myFile1", null);
|
|
||||||
//writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
|
||||||
//writer.setEncoding("UTF-8");
|
|
||||||
//writer.putContent(MYFILE1);
|
|
||||||
|
|
||||||
AssetInfo myFile1Asset = assetService.getAsset(sbStoreId, path+"/myFolder1/myFolder2/myFile1");
|
AssetInfo myFile1Asset = assetService.getAsset(sbStoreId, path+"/myFolder1/myFolder2/myFile1");
|
||||||
checkAssetInfo(myFile1Asset, "myFile1", path+"/myFolder1/myFolder2/myFile1", USER_ONE, true, false, false, true, USER_ONE);
|
checkAssetInfo(myFile1Asset, "myFile1", path+"/myFolder1/myFolder2/myFile1", USER_ONE, true, false, false, true, USER_ONE);
|
||||||
@@ -729,10 +716,9 @@ public class AssetServiceImplTest extends TestCase
|
|||||||
AssetInfo myMovedFile1Asset = assetService.getAsset(sbStoreId, path+"/myFolder2/myFile1");
|
AssetInfo myMovedFile1Asset = assetService.getAsset(sbStoreId, path+"/myFolder2/myFile1");
|
||||||
|
|
||||||
// TODO review - moved files are not locked ?
|
// TODO review - moved files are not locked ?
|
||||||
checkAssetInfo(myMovedFile1Asset, "myFile1", path+"/myFolder2/myFile1", USER_ONE, true, false, false, true, USER_ONE);
|
//checkAssetInfo(myMovedFile1Asset, "myFile1", path+"/myFolder2/myFile1", USER_ONE, true, false, false, true, USER_ONE);
|
||||||
//checkAssetInfo(myMovedFile1Asset, "myFile1", path+"/myFolder2/myFile1", USER_ONE, true, false, false, false, null);
|
checkAssetInfo(myMovedFile1Asset, "myFile1", path+"/myFolder2/myFile1", USER_ONE, true, false, false, false, null);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
public void testProperties()
|
public void testProperties()
|
||||||
{
|
{
|
||||||
@@ -817,6 +803,76 @@ public class AssetServiceImplTest extends TestCase
|
|||||||
assertEquals(USER_ONE, assetService.getLockOwner(myFile1Asset));
|
assertEquals(USER_ONE, assetService.getLockOwner(myFile1Asset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testAspects()
|
||||||
|
{
|
||||||
|
// create web project (also creates staging sandbox and admin's author sandbox)
|
||||||
|
WebProjectInfo wpInfo = wpService.createWebProject(TEST_WEBPROJ_DNS+"-aspects", TEST_WEBPROJ_NAME+"-aspects", TEST_WEBPROJ_TITLE, TEST_WEBPROJ_DESCRIPTION, TEST_WEBPROJ_DEFAULT_WEBAPP, TEST_WEBPROJ_DONT_USE_AS_TEMPLATE, null);
|
||||||
|
String defaultWebApp = wpInfo.getDefaultWebApp();
|
||||||
|
|
||||||
|
// invite web user and auto-create their (author) sandbox
|
||||||
|
wpService.inviteWebUser(wpInfo.getStoreId(), USER_ONE, WCMUtil.ROLE_CONTENT_CONTRIBUTOR, true);
|
||||||
|
|
||||||
|
// switch to user
|
||||||
|
AuthenticationUtil.setFullyAuthenticatedUser(USER_ONE);
|
||||||
|
|
||||||
|
// get user's author sandbox
|
||||||
|
SandboxInfo sbInfo = sbService.getAuthorSandbox(wpInfo.getStoreId());
|
||||||
|
String sbStoreId = sbInfo.getSandboxId();
|
||||||
|
|
||||||
|
String path = sbInfo.getSandboxRootPath() + "/" + defaultWebApp;
|
||||||
|
|
||||||
|
// create folder
|
||||||
|
assetService.createFolderWebApp(sbStoreId, defaultWebApp, "/", "myFolder1");
|
||||||
|
AssetInfo myFolder1Asset = assetService.getAssetWebApp(sbStoreId, defaultWebApp, "/myFolder1");
|
||||||
|
checkAssetInfo(myFolder1Asset, "myFolder1", path+"/myFolder1", USER_ONE, false, true, false, false, null);
|
||||||
|
|
||||||
|
int folderAspectCnt = assetService.getAspects(myFolder1Asset).size();
|
||||||
|
|
||||||
|
// create file
|
||||||
|
assetService.createFileWebApp(sbStoreId, defaultWebApp, "/myFolder1", "myFile1");
|
||||||
|
AssetInfo myFile1Asset = assetService.getAssetWebApp(sbStoreId, defaultWebApp, "/myFolder1/myFile1");
|
||||||
|
checkAssetInfo(myFile1Asset, "myFile1", path+"/myFolder1/myFile1", USER_ONE, true, false, false, true, USER_ONE);
|
||||||
|
|
||||||
|
int fileAspectCnt = assetService.getAspects(myFile1Asset).size();
|
||||||
|
|
||||||
|
// add/remove aspect to/from folder
|
||||||
|
|
||||||
|
assertFalse(assetService.hasAspect(myFolder1Asset, ContentModel.ASPECT_TITLED));
|
||||||
|
|
||||||
|
Map<QName, Serializable> newProps = new HashMap<QName, Serializable>(2);
|
||||||
|
newProps.put(ContentModel.PROP_TITLE, "folder title");
|
||||||
|
newProps.put(ContentModel.PROP_DESCRIPTION, "folder description");
|
||||||
|
|
||||||
|
assetService.addAspect(myFolder1Asset, ContentModel.ASPECT_TITLED, newProps);
|
||||||
|
|
||||||
|
assertEquals(folderAspectCnt+1, assetService.getAspects(myFolder1Asset).size());
|
||||||
|
assertTrue(assetService.hasAspect(myFolder1Asset, ContentModel.ASPECT_TITLED));
|
||||||
|
|
||||||
|
assetService.removeAspect(myFolder1Asset, ContentModel.ASPECT_TITLED);
|
||||||
|
|
||||||
|
assertEquals(folderAspectCnt, assetService.getAspects(myFolder1Asset).size());
|
||||||
|
assertFalse(assetService.hasAspect(myFolder1Asset, ContentModel.ASPECT_TITLED));
|
||||||
|
|
||||||
|
// add/remove aspect to/from file
|
||||||
|
|
||||||
|
assertFalse(assetService.hasAspect(myFile1Asset, ContentModel.ASPECT_TITLED));
|
||||||
|
|
||||||
|
newProps = new HashMap<QName, Serializable>(2);
|
||||||
|
newProps.put(ContentModel.PROP_TITLE, "file title");
|
||||||
|
newProps.put(ContentModel.PROP_DESCRIPTION, "file description");
|
||||||
|
|
||||||
|
assetService.addAspect(myFile1Asset, ContentModel.ASPECT_TITLED, newProps);
|
||||||
|
|
||||||
|
assertEquals(fileAspectCnt+1, assetService.getAspects(myFile1Asset).size());
|
||||||
|
assertTrue(assetService.hasAspect(myFile1Asset, ContentModel.ASPECT_TITLED));
|
||||||
|
|
||||||
|
assetService.removeAspect(myFile1Asset, ContentModel.ASPECT_TITLED);
|
||||||
|
|
||||||
|
assertEquals(fileAspectCnt, assetService.getAspects(myFile1Asset).size());
|
||||||
|
assertFalse(assetService.hasAspect(myFile1Asset, ContentModel.ASPECT_TITLED));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testSimpleLockFile()
|
public void testSimpleLockFile()
|
||||||
{
|
{
|
||||||
// create web project (also creates staging sandbox and admin's author sandbox)
|
// create web project (also creates staging sandbox and admin's author sandbox)
|
||||||
|
@@ -341,7 +341,7 @@ public class SandboxServiceImpl implements SandboxService
|
|||||||
|
|
||||||
if (sbStoreId.equals(wpStoreId))
|
if (sbStoreId.equals(wpStoreId))
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Cannot delete staging sandbox '"+sbStoreId+"' (web project id: "+wpStoreId+")");
|
throw new AccessDeniedException("Cannot delete staging sandbox '"+sbStoreId+"' (web project id: "+wpStoreId+")");
|
||||||
}
|
}
|
||||||
|
|
||||||
// content manager may delete sandboxes, except staging sandbox
|
// content manager may delete sandboxes, except staging sandbox
|
||||||
|
@@ -33,12 +33,10 @@ import java.util.Map;
|
|||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||||
import org.alfresco.service.cmr.avm.AVMNotFoundException;
|
|
||||||
import org.alfresco.service.cmr.avm.AVMService;
|
import org.alfresco.service.cmr.avm.AVMService;
|
||||||
import org.alfresco.service.cmr.avm.VersionDescriptor;
|
import org.alfresco.service.cmr.avm.VersionDescriptor;
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
@@ -419,7 +417,7 @@ public class SandboxServiceImplTest extends TestCase
|
|||||||
sbService.deleteSandbox(sbInfo.getSandboxId());
|
sbService.deleteSandbox(sbInfo.getSandboxId());
|
||||||
fail("Shouldn't be able to delete staging sandbox");
|
fail("Shouldn't be able to delete staging sandbox");
|
||||||
}
|
}
|
||||||
catch (AlfrescoRuntimeException exception)
|
catch (AccessDeniedException exception)
|
||||||
{
|
{
|
||||||
// Expected
|
// Expected
|
||||||
}
|
}
|
||||||
@@ -430,7 +428,7 @@ public class SandboxServiceImplTest extends TestCase
|
|||||||
sbService.deleteSandbox("some-random-staging-sandbox");
|
sbService.deleteSandbox("some-random-staging-sandbox");
|
||||||
fail("Shouldn't be able to delete non-existant sandbox");
|
fail("Shouldn't be able to delete non-existant sandbox");
|
||||||
}
|
}
|
||||||
catch (AVMNotFoundException exception)
|
catch (AccessDeniedException exception)
|
||||||
{
|
{
|
||||||
// Expected
|
// Expected
|
||||||
}
|
}
|
||||||
|
@@ -24,12 +24,20 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.wcm.sandbox.script;
|
package org.alfresco.wcm.sandbox.script;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
|
import org.alfresco.service.namespace.NamespaceException;
|
||||||
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.ISO8601DateFormat;
|
import org.alfresco.util.ISO8601DateFormat;
|
||||||
import org.alfresco.wcm.asset.AssetInfo;
|
import org.alfresco.wcm.asset.AssetInfo;
|
||||||
|
import org.alfresco.wcm.asset.AssetService;
|
||||||
import org.alfresco.wcm.sandbox.SandboxService;
|
import org.alfresco.wcm.sandbox.SandboxService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,10 +45,15 @@ import org.alfresco.wcm.sandbox.SandboxService;
|
|||||||
* @author mrogers
|
* @author mrogers
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Asset
|
public class Asset implements Serializable
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -5759260478423750966L;
|
||||||
private AssetInfo asset;
|
private AssetInfo asset;
|
||||||
private Sandbox sandbox;
|
private Sandbox sandbox;
|
||||||
|
private Map<String, String> props;
|
||||||
|
|
||||||
public Asset(Sandbox sandbox, AssetInfo asset)
|
public Asset(Sandbox sandbox, AssetInfo asset)
|
||||||
{
|
{
|
||||||
@@ -62,6 +75,11 @@ public class Asset
|
|||||||
return asset.getCreatedDate();
|
return asset.getCreatedDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getFileSize()
|
||||||
|
{
|
||||||
|
return asset.getFileSize();
|
||||||
|
}
|
||||||
|
|
||||||
public String getCreatedDateAsISO8601()
|
public String getCreatedDateAsISO8601()
|
||||||
{
|
{
|
||||||
return ISO8601DateFormat.format(getCreatedDate());
|
return ISO8601DateFormat.format(getCreatedDate());
|
||||||
@@ -82,12 +100,33 @@ public class Asset
|
|||||||
return ISO8601DateFormat.format(getModifiedDate());
|
return ISO8601DateFormat.format(getModifiedDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
public String getAssetRef()
|
* rename this asset
|
||||||
{
|
* @param newName
|
||||||
return asset.getGuid();
|
*/
|
||||||
}
|
public Asset rename(String newName)
|
||||||
*/
|
{
|
||||||
|
if(!newName.equals(asset.getName()))
|
||||||
|
{
|
||||||
|
AssetInfo newAsset = getAssetService().renameAsset(asset, newName);
|
||||||
|
this.asset = newAsset;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* move this asset
|
||||||
|
* @param newPath
|
||||||
|
*/
|
||||||
|
public Asset move(String newPath)
|
||||||
|
{
|
||||||
|
if(!newPath.equals(asset.getPath()))
|
||||||
|
{
|
||||||
|
AssetInfo newAsset = getAssetService().moveAsset(asset, newPath);
|
||||||
|
this.asset = newAsset;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
@@ -108,7 +147,7 @@ public class Asset
|
|||||||
return asset.isFile();
|
return asset.isFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDirectory()
|
public boolean isFolder()
|
||||||
{
|
{
|
||||||
return asset.isFolder();
|
return asset.isFolder();
|
||||||
}
|
}
|
||||||
@@ -123,14 +162,82 @@ public class Asset
|
|||||||
return asset.isLocked();
|
return asset.isLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO review
|
public String lockOwner()
|
||||||
|
{
|
||||||
|
return asset.getLockOwner();
|
||||||
|
}
|
||||||
|
|
||||||
public int getVersion()
|
public int getVersion()
|
||||||
{
|
{
|
||||||
return asset.getVersion();
|
return asset.getSandboxVersion();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get the properties as a key value pair. The key will be either a local qname e.g. "cm:content" or
|
||||||
|
* a global qname e.g. "{http://www.alfresco.com/content/1.0}content".
|
||||||
|
*
|
||||||
|
* Some properties will be updatable, protected properties are not.
|
||||||
|
*
|
||||||
|
* @return the properties in a key, value pair
|
||||||
|
*/
|
||||||
|
|
||||||
|
public Map<String, String> getProperties()
|
||||||
|
{
|
||||||
|
if(props == null) {
|
||||||
|
|
||||||
|
// Note there is something very strange going on with scope which is why there's this guff with propsX
|
||||||
|
Map<String, String> propsX = new HashMap<String, String>();
|
||||||
|
props = propsX;
|
||||||
|
NamespaceService ns = getNamespaceService();
|
||||||
|
|
||||||
|
if(!asset.isDeleted())
|
||||||
|
{
|
||||||
|
Map <QName, Serializable> intprops = getAssetService().getAssetProperties(asset);
|
||||||
|
|
||||||
|
for (QName qname : intprops.keySet())
|
||||||
|
{
|
||||||
|
QName prefixQname = qname.getPrefixedQName(ns);
|
||||||
|
Serializable propValue = intprops.get(qname);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
propsX.put(prefixQname.toPrefixString(), propValue.toString());
|
||||||
|
}
|
||||||
|
catch (NamespaceException ne)
|
||||||
|
{ // No local name, only thing I can do is use the full namke
|
||||||
|
propsX.put(qname.toString(), propValue.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return props;
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Save the properties please note some system properties are protected and cannot be updated. If you attempt to
|
||||||
|
// * update a protected property your request will be ignored.
|
||||||
|
// * @param properties
|
||||||
|
// */
|
||||||
|
// public void save()
|
||||||
|
// {
|
||||||
|
// if(props != null)
|
||||||
|
// {
|
||||||
|
// /**
|
||||||
|
// * Need to map the <String, String> to a <Qname, Serializable>
|
||||||
|
// */
|
||||||
|
// NamespaceService ns = getNamespaceService();
|
||||||
|
// Map<QName, Serializable> newProps = new HashMap<QName, Serializable>(props.size());
|
||||||
|
// for (String key : props.keySet())
|
||||||
|
// {
|
||||||
|
// String value = props.get(key);
|
||||||
|
// QName q = QName.resolveToQName(ns, key);
|
||||||
|
// newProps.put(q, value);
|
||||||
|
// }
|
||||||
|
// getAssetService().setAssetProperties(asset, newProps);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
* Submit this asset to staging
|
* Submit this asset to staging
|
||||||
* @param submitLabel
|
* @param submitLabel
|
||||||
* @param submitComment
|
* @param submitComment
|
||||||
@@ -143,6 +250,14 @@ public class Asset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Delete this asset, after it has been deleted do not use this asset.
|
||||||
|
*/
|
||||||
|
public void deleteAsset()
|
||||||
|
{
|
||||||
|
getAssetService().deleteAsset(this.asset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* revert this asset
|
* revert this asset
|
||||||
*/
|
*/
|
||||||
public void revert()
|
public void revert()
|
||||||
@@ -153,6 +268,49 @@ public class Asset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get children of this asset, returns an empty array if there are no children.
|
||||||
|
* Only folders have children.
|
||||||
|
*/
|
||||||
|
public Asset[] getChildren()
|
||||||
|
{
|
||||||
|
Asset[] ret = new Asset[0];
|
||||||
|
if(asset.isFolder())
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
List<AssetInfo> assets = getAssetService().listAssets(getSandbox().getSandboxRef(), asset.getPath(), true);
|
||||||
|
ret = new Asset[assets.size()];
|
||||||
|
for(AssetInfo asset : assets)
|
||||||
|
{
|
||||||
|
ret[i++]=new Asset(sandbox, asset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create a new file with the specified properties and content.
|
||||||
|
* @param name the name of the file
|
||||||
|
* @param stringContent the content of the file. Can be null.
|
||||||
|
*/
|
||||||
|
public void createFile(String name, String stringContent)
|
||||||
|
{
|
||||||
|
ContentWriter writer = getAssetService().createFile(getSandbox().getSandboxRef(), asset.getPath(), name, null);
|
||||||
|
if(stringContent != null)
|
||||||
|
{
|
||||||
|
writer.putContent(stringContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create a new folder
|
||||||
|
* @param name the name of the new folder
|
||||||
|
*/
|
||||||
|
public void createFolder(String name)
|
||||||
|
{
|
||||||
|
getAssetService().createFolder(getSandbox().getSandboxRef(), asset.getPath(), name, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* Get the parent sandbox which contains this asset
|
* Get the parent sandbox which contains this asset
|
||||||
* @return the parent sandbox which contains this asset
|
* @return the parent sandbox which contains this asset
|
||||||
*/
|
*/
|
||||||
@@ -161,8 +319,29 @@ public class Asset
|
|||||||
return this.sandbox;
|
return this.sandbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private SandboxService getSandboxService()
|
private SandboxService getSandboxService()
|
||||||
{
|
{
|
||||||
return getSandbox().getWebproject().getWebProjects().getSandboxService();
|
return getSandbox().getWebproject().getWebProjects().getSandboxService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the asset service
|
||||||
|
* @return the asset service
|
||||||
|
*/
|
||||||
|
private AssetService getAssetService()
|
||||||
|
{
|
||||||
|
return getSandbox().getWebproject().getWebProjects().getAssetService();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the asset service
|
||||||
|
* @return the asset service
|
||||||
|
*/
|
||||||
|
private NamespaceService getNamespaceService()
|
||||||
|
{
|
||||||
|
return getSandbox().getWebproject().getWebProjects().getNamespaceService();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -29,7 +29,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
|
||||||
import org.alfresco.util.ISO8601DateFormat;
|
import org.alfresco.util.ISO8601DateFormat;
|
||||||
import org.alfresco.wcm.asset.AssetInfo;
|
import org.alfresco.wcm.asset.AssetInfo;
|
||||||
import org.alfresco.wcm.asset.AssetService;
|
import org.alfresco.wcm.asset.AssetService;
|
||||||
@@ -277,28 +276,37 @@ public class Sandbox implements Serializable
|
|||||||
/**
|
/**
|
||||||
* Get the specified asset (Either folder or file)
|
* Get the specified asset (Either folder or file)
|
||||||
* @param path the full path e.g. /www/web_apps/ROOT/index.html
|
* @param path the full path e.g. /www/web_apps/ROOT/index.html
|
||||||
* @return the asset
|
* @return the asset or null if it does not exist
|
||||||
*/
|
*/
|
||||||
public Asset getAsset(String path)
|
public Asset getAsset(String path)
|
||||||
{
|
{
|
||||||
AssetService as = getAssetService();
|
AssetService as = getAssetService();
|
||||||
AssetInfo item = as.getAsset(getSandboxRef(), path);
|
AssetInfo item = as.getAsset(getSandboxRef(), path);
|
||||||
Asset newAsset = new Asset(this, item);
|
if (item != null)
|
||||||
return newAsset;
|
{
|
||||||
|
Asset newAsset = new Asset(this, item);
|
||||||
|
return newAsset;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the specified asset with a path relative to the specified web app.
|
* Get the specified asset with a path relative to the specified web app.
|
||||||
* @param path e.g. index.html
|
* @param path e.g. index.html
|
||||||
* @param webApp e.g. ROOT
|
* @param webApp e.g. ROOT
|
||||||
* @return the asset
|
* @return the asset or null if it does not exist
|
||||||
*/
|
*/
|
||||||
public Asset getAssetWebApp(String webApp, String path)
|
public Asset getAssetWebApp(String webApp, String path)
|
||||||
{
|
{
|
||||||
AssetService as = getAssetService();
|
AssetService as = getAssetService();
|
||||||
AssetInfo item = as.getAssetWebApp(getSandboxRef(), webApp, path);
|
AssetInfo item = as.getAssetWebApp(getSandboxRef(), webApp, path);
|
||||||
Asset newAsset = new Asset(this, item);
|
if (item != null)
|
||||||
return newAsset;
|
{
|
||||||
|
Asset newAsset = new Asset(this, item);
|
||||||
|
return newAsset;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -36,7 +36,9 @@ import org.alfresco.mbeans.VirtServerRegistry;
|
|||||||
import org.alfresco.model.WCMAppModel;
|
import org.alfresco.model.WCMAppModel;
|
||||||
import org.alfresco.repo.domain.PropertyValue;
|
import org.alfresco.repo.domain.PropertyValue;
|
||||||
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
|
import org.alfresco.service.cmr.avm.AVMBadArgumentException;
|
||||||
|
import org.alfresco.service.cmr.avm.AVMNotFoundException;
|
||||||
import org.alfresco.service.cmr.avm.AVMService;
|
import org.alfresco.service.cmr.avm.AVMService;
|
||||||
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
@@ -45,6 +47,8 @@ import org.alfresco.service.namespace.RegexQNamePattern;
|
|||||||
import org.alfresco.util.ParameterCheck;
|
import org.alfresco.util.ParameterCheck;
|
||||||
import org.alfresco.util.VirtServerUtils;
|
import org.alfresco.util.VirtServerUtils;
|
||||||
import org.alfresco.wcm.sandbox.SandboxConstants;
|
import org.alfresco.wcm.sandbox.SandboxConstants;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,6 +61,8 @@ import org.alfresco.wcm.sandbox.SandboxConstants;
|
|||||||
*/
|
*/
|
||||||
public class WCMUtil
|
public class WCMUtil
|
||||||
{
|
{
|
||||||
|
private static Log logger = LogFactory.getLog(WCMUtil.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts the sandbox store id from the avm path
|
* Extracts the sandbox store id from the avm path
|
||||||
*
|
*
|
||||||
@@ -478,6 +484,29 @@ public class WCMUtil
|
|||||||
: null);
|
: null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static NodeRef getWebProjectNodeFromWebProjectStore(AVMService avmService, String wpStoreId)
|
||||||
|
{
|
||||||
|
NodeRef wpNodeRef = null;
|
||||||
|
|
||||||
|
String stagingStoreId = wpStoreId; // note: equivalent to WCMUtil.buildStagingStoreName(wpStoreId)
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PropertyValue pValue = avmService.getStoreProperty(stagingStoreId, SandboxConstants.PROP_WEB_PROJECT_NODE_REF);
|
||||||
|
|
||||||
|
if (pValue != null)
|
||||||
|
{
|
||||||
|
wpNodeRef = (NodeRef)pValue.getValue(DataTypeDefinition.NODE_REF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (AVMNotFoundException nfe)
|
||||||
|
{
|
||||||
|
logger.warn(wpStoreId + " is not a web project: " + nfe);
|
||||||
|
}
|
||||||
|
|
||||||
|
return wpNodeRef;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the provided path to an absolute path within the avm.
|
* Converts the provided path to an absolute path within the avm.
|
||||||
*
|
*
|
||||||
|
@@ -75,7 +75,7 @@ public interface WebProjectService
|
|||||||
* @param absoluteAVMPath the AVM path from which to determine the Web Project
|
* @param absoluteAVMPath the AVM path from which to determine the Web Project
|
||||||
* @return NodeRef the web project node ref for the path or null if it could not be determined
|
* @return NodeRef the web project node ref for the path or null if it could not be determined
|
||||||
*/
|
*/
|
||||||
public NodeRef findWebProjectNodeFromPath(String absoluteAVMPath);
|
public NodeRef getWebProjectNodeFromPath(String absoluteAVMPath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Web Project for the given AVM store name (sandbox store id)
|
* Returns the Web Project for the given AVM store name (sandbox store id)
|
||||||
@@ -83,7 +83,7 @@ public interface WebProjectService
|
|||||||
* @param storeName the AVM store name (sandbox store id) from which to determine the Web Project
|
* @param storeName the AVM store name (sandbox store id) from which to determine the Web Project
|
||||||
* @return NodeRef the web project node ref for the path or null if it could not be determined
|
* @return NodeRef the web project node ref for the path or null if it could not be determined
|
||||||
*/
|
*/
|
||||||
public NodeRef findWebProjectNodeFromStore(String storeName);
|
public NodeRef getWebProjectNodeFromStore(String storeName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List the available web projects for the current user
|
* List the available web projects for the current user
|
||||||
|
@@ -66,7 +66,6 @@ import org.alfresco.service.namespace.QName;
|
|||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
import org.alfresco.util.DNSNameMangler;
|
import org.alfresco.util.DNSNameMangler;
|
||||||
import org.alfresco.util.ParameterCheck;
|
import org.alfresco.util.ParameterCheck;
|
||||||
import org.alfresco.wcm.sandbox.SandboxConstants;
|
|
||||||
import org.alfresco.wcm.sandbox.SandboxFactory;
|
import org.alfresco.wcm.sandbox.SandboxFactory;
|
||||||
import org.alfresco.wcm.sandbox.SandboxInfo;
|
import org.alfresco.wcm.sandbox.SandboxInfo;
|
||||||
import org.alfresco.wcm.util.WCMUtil;
|
import org.alfresco.wcm.util.WCMUtil;
|
||||||
@@ -269,7 +268,7 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
*/
|
*/
|
||||||
public void createWebApp(String wpStoreId, String webAppName, String webAppDescription)
|
public void createWebApp(String wpStoreId, String webAppName, String webAppDescription)
|
||||||
{
|
{
|
||||||
createWebApp(findWebProjectNodeFromStore(wpStoreId), webAppName, webAppDescription);
|
createWebApp(getWebProjectNodeFromStore(wpStoreId), webAppName, webAppDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -326,7 +325,7 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
*/
|
*/
|
||||||
public List<String> listWebApps(String wpStoreId)
|
public List<String> listWebApps(String wpStoreId)
|
||||||
{
|
{
|
||||||
return listWebApps(findWebProjectNodeFromStore(wpStoreId));
|
return listWebApps(getWebProjectNodeFromStore(wpStoreId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -349,7 +348,7 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
*/
|
*/
|
||||||
public void deleteWebApp(String wpStoreId, String webAppName)
|
public void deleteWebApp(String wpStoreId, String webAppName)
|
||||||
{
|
{
|
||||||
deleteWebApp(findWebProjectNodeFromStore(wpStoreId), webAppName);
|
deleteWebApp(getWebProjectNodeFromStore(wpStoreId), webAppName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -477,7 +476,7 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
*/
|
*/
|
||||||
public boolean isWebProject(String wpStoreId)
|
public boolean isWebProject(String wpStoreId)
|
||||||
{
|
{
|
||||||
NodeRef wpNodeRef = findWebProjectNodeFromStore(wpStoreId);
|
NodeRef wpNodeRef = getWebProjectNodeFromStore(wpStoreId);
|
||||||
if (wpNodeRef == null)
|
if (wpNodeRef == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -513,7 +512,7 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
WebProjectInfo result = null;
|
WebProjectInfo result = null;
|
||||||
|
|
||||||
// Get the web project node
|
// Get the web project node
|
||||||
NodeRef wpNodeRef = findWebProjectNodeFromStore(wpStoreId);
|
NodeRef wpNodeRef = getWebProjectNodeFromStore(wpStoreId);
|
||||||
if (wpNodeRef != null)
|
if (wpNodeRef != null)
|
||||||
{
|
{
|
||||||
// Create the web project info
|
// Create the web project info
|
||||||
@@ -554,7 +553,7 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
*/
|
*/
|
||||||
public void updateWebProject(WebProjectInfo wpInfo)
|
public void updateWebProject(WebProjectInfo wpInfo)
|
||||||
{
|
{
|
||||||
NodeRef wpNodeRef = findWebProjectNodeFromStore(wpInfo.getStoreId());
|
NodeRef wpNodeRef = getWebProjectNodeFromStore(wpInfo.getStoreId());
|
||||||
if (wpNodeRef == null)
|
if (wpNodeRef == null)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Cannot update web project '" + wpInfo.getStoreId() + "' because it does not exist.");
|
throw new AlfrescoRuntimeException("Cannot update web project '" + wpInfo.getStoreId() + "' because it does not exist.");
|
||||||
@@ -584,7 +583,7 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
*/
|
*/
|
||||||
public void deleteWebProject(String wpStoreId)
|
public void deleteWebProject(String wpStoreId)
|
||||||
{
|
{
|
||||||
NodeRef wpNodeRef = findWebProjectNodeFromStore(wpStoreId);
|
NodeRef wpNodeRef = getWebProjectNodeFromStore(wpStoreId);
|
||||||
if (wpNodeRef != null)
|
if (wpNodeRef != null)
|
||||||
{
|
{
|
||||||
deleteWebProject(wpNodeRef);
|
deleteWebProject(wpNodeRef);
|
||||||
@@ -676,20 +675,9 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.wcm.WebProjectService#isContentManager(java.lang.String, java.lang.String)
|
* @see org.alfresco.wcm.WebProjectService#isContentManager(java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public boolean isContentManager(String storeName, String userName)
|
public boolean isContentManager(String wpStoreId, String userName)
|
||||||
{
|
{
|
||||||
String wpStoreId = WCMUtil.getWebProjectStoreId(storeName);
|
return isContentManager(getWebProjectNodeFromStore(wpStoreId), userName);
|
||||||
PropertyValue pValue = avmService.getStoreProperty(wpStoreId, SandboxConstants.PROP_WEB_PROJECT_NODE_REF);
|
|
||||||
|
|
||||||
if (pValue != null)
|
|
||||||
{
|
|
||||||
NodeRef wpNodeRef = (NodeRef) pValue.getValue(DataTypeDefinition.NODE_REF);
|
|
||||||
return isContentManager(wpNodeRef, userName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -712,20 +700,11 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.wcm.webproject.WebProjectService#isWebUser(java.lang.String, java.lang.String)
|
* @see org.alfresco.wcm.webproject.WebProjectService#isWebUser(java.lang.String, java.lang.String)
|
||||||
*/
|
*/
|
||||||
public boolean isWebUser(String storeName, String username)
|
public boolean isWebUser(String wpStoreId, String username)
|
||||||
{
|
{
|
||||||
String wpStoreId = WCMUtil.getWebProjectStoreId(storeName);
|
ParameterCheck.mandatoryString("username", username);
|
||||||
PropertyValue pValue = avmService.getStoreProperty(wpStoreId, SandboxConstants.PROP_WEB_PROJECT_NODE_REF);
|
|
||||||
|
|
||||||
if (pValue != null)
|
return isWebUser(getWebProjectNodeFromStore(wpStoreId), username);
|
||||||
{
|
|
||||||
NodeRef wpNodeRef = (NodeRef) pValue.getValue(DataTypeDefinition.NODE_REF);
|
|
||||||
return isWebUser(wpNodeRef, username);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -733,8 +712,9 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
*/
|
*/
|
||||||
public boolean isWebUser(NodeRef wpNodeRef, String userName)
|
public boolean isWebUser(NodeRef wpNodeRef, String userName)
|
||||||
{
|
{
|
||||||
String userRole = getWebUserRoleImpl(wpNodeRef, userName);
|
ParameterCheck.mandatoryString("userName", userName);
|
||||||
return (userRole != null);
|
|
||||||
|
return (getWebUserRoleImpl(wpNodeRef, userName) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -750,7 +730,7 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
*/
|
*/
|
||||||
public Map<String, String> listWebUsers(String wpStoreId)
|
public Map<String, String> listWebUsers(String wpStoreId)
|
||||||
{
|
{
|
||||||
return listWebUsers(findWebProjectNodeFromStore(wpStoreId));
|
return listWebUsers(getWebProjectNodeFromStore(wpStoreId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -774,7 +754,7 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
*/
|
*/
|
||||||
public String getWebUserRole(String wpStoreId, String userName)
|
public String getWebUserRole(String wpStoreId, String userName)
|
||||||
{
|
{
|
||||||
return getWebUserRole(findWebProjectNodeFromStore(wpStoreId), userName);
|
return getWebUserRole(getWebProjectNodeFromStore(wpStoreId), userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -782,6 +762,8 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
*/
|
*/
|
||||||
public String getWebUserRole(NodeRef wpNodeRef, String userName)
|
public String getWebUserRole(NodeRef wpNodeRef, String userName)
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatoryString("userName", userName);
|
||||||
|
|
||||||
String userRole = null;
|
String userRole = null;
|
||||||
|
|
||||||
if (! isWebProject(wpNodeRef))
|
if (! isWebProject(wpNodeRef))
|
||||||
@@ -860,72 +842,19 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.wcm.webproject.WebProjectService#findWebProjectNodeFromPath(java.lang.String)
|
* @see org.alfresco.wcm.webproject.WebProjectService#findWebProjectNodeFromPath(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public NodeRef findWebProjectNodeFromPath(String absoluteAVMPath)
|
public NodeRef getWebProjectNodeFromPath(String absoluteAVMPath)
|
||||||
{
|
{
|
||||||
return findWebProjectNodeFromStore(WCMUtil.getWebProjectStoreIdFromPath(absoluteAVMPath));
|
return getWebProjectNodeFromStore(WCMUtil.getWebProjectStoreIdFromPath(absoluteAVMPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*(non-Javadoc)
|
/*(non-Javadoc)
|
||||||
* @see org.alfresco.wcm.webproject.WebProjectService#findWebProjectNodeFromStore(java.lang.String)
|
* @see org.alfresco.wcm.webproject.WebProjectService#getWebProjectNodeFromStore(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public NodeRef findWebProjectNodeFromStore(String wpStoreId)
|
public NodeRef getWebProjectNodeFromStore(String wpStoreId)
|
||||||
{
|
{
|
||||||
ParameterCheck.mandatoryString("wpStoreId", wpStoreId);
|
ParameterCheck.mandatoryString("wpStoreId", wpStoreId);
|
||||||
|
|
||||||
if (wpStoreId.indexOf(WCMUtil.STORE_SEPARATOR) != -1)
|
return WCMUtil.getWebProjectNodeFromWebProjectStore(avmService, wpStoreId);
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Unexpected web project store id '"+wpStoreId+"' - should not contain '"+WCMUtil.STORE_SEPARATOR+"'");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wpStoreId.indexOf(":") != -1)
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Unexpected web project store id '"+wpStoreId+"' - should not contain ':'");
|
|
||||||
}
|
|
||||||
|
|
||||||
// construct the query
|
|
||||||
String path = getWebProjectsPath() + "/*";
|
|
||||||
String query = "PATH:\"/" + path + "\" AND @wca\\:avmstore:\"" + wpStoreId + "\"";
|
|
||||||
|
|
||||||
NodeRef webProjectNode = null;
|
|
||||||
ResultSet results = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// execute the query
|
|
||||||
results = searchService.query(WEBPROJECT_STORE, SearchService.LANGUAGE_LUCENE, query);
|
|
||||||
|
|
||||||
// WCM-810:
|
|
||||||
// the 'avmstore' property was not defined as an identifier in the model (before 2.2)
|
|
||||||
// which means it may get tokenised which in turn means that 'test' and 'test-site'
|
|
||||||
// would get returned by the query above even though it's an exact match query,
|
|
||||||
// we therefore need to go through the results and check names if there is more
|
|
||||||
// than one result although this shouldn't happen anymore as the
|
|
||||||
// AVMStorePropertyTokenisationPatch will have reindexed the wca:avmstore property
|
|
||||||
if (results.length() == 1)
|
|
||||||
{
|
|
||||||
webProjectNode = results.getNodeRef(0);
|
|
||||||
}
|
|
||||||
else if (results.length() > 1)
|
|
||||||
{
|
|
||||||
for (NodeRef node : results.getNodeRefs())
|
|
||||||
{
|
|
||||||
String nodeStoreName = (String)nodeService.getProperty(node, WCMAppModel.PROP_AVMSTORE);
|
|
||||||
if (nodeStoreName.equals(wpStoreId))
|
|
||||||
{
|
|
||||||
webProjectNode = node;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (results != null)
|
|
||||||
{
|
|
||||||
results.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return webProjectNode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -933,7 +862,7 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
*/
|
*/
|
||||||
public void inviteWebUsersGroups(String wpStoreId, Map<String, String> userGroupRoles)
|
public void inviteWebUsersGroups(String wpStoreId, Map<String, String> userGroupRoles)
|
||||||
{
|
{
|
||||||
inviteWebUsersGroups(findWebProjectNodeFromStore(wpStoreId), userGroupRoles, false);
|
inviteWebUsersGroups(getWebProjectNodeFromStore(wpStoreId), userGroupRoles, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -941,7 +870,7 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
*/
|
*/
|
||||||
public void inviteWebUsersGroups(String wpStoreId, Map<String, String> userGroupRoles, boolean autoCreateAuthorSandbox)
|
public void inviteWebUsersGroups(String wpStoreId, Map<String, String> userGroupRoles, boolean autoCreateAuthorSandbox)
|
||||||
{
|
{
|
||||||
inviteWebUsersGroups(findWebProjectNodeFromStore(wpStoreId), userGroupRoles, autoCreateAuthorSandbox);
|
inviteWebUsersGroups(getWebProjectNodeFromStore(wpStoreId), userGroupRoles, autoCreateAuthorSandbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void inviteWebUsersGroups(NodeRef wpNodeRef, Map<String, String> userGroupRoles, boolean autoCreateAuthorSandbox)
|
public void inviteWebUsersGroups(NodeRef wpNodeRef, Map<String, String> userGroupRoles, boolean autoCreateAuthorSandbox)
|
||||||
@@ -1069,7 +998,7 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
*/
|
*/
|
||||||
public void inviteWebUser(String wpStoreId, String userAuth, String role)
|
public void inviteWebUser(String wpStoreId, String userAuth, String role)
|
||||||
{
|
{
|
||||||
inviteWebUser(findWebProjectNodeFromStore(wpStoreId), userAuth, role, false);
|
inviteWebUser(getWebProjectNodeFromStore(wpStoreId), userAuth, role, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -1077,7 +1006,7 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
*/
|
*/
|
||||||
public void inviteWebUser(String wpStoreId, String userAuth, String role, boolean autoCreateAuthorSandbox)
|
public void inviteWebUser(String wpStoreId, String userAuth, String role, boolean autoCreateAuthorSandbox)
|
||||||
{
|
{
|
||||||
inviteWebUser(findWebProjectNodeFromStore(wpStoreId), userAuth, role, autoCreateAuthorSandbox);
|
inviteWebUser(getWebProjectNodeFromStore(wpStoreId), userAuth, role, autoCreateAuthorSandbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -1183,7 +1112,7 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
*/
|
*/
|
||||||
public void uninviteWebUser(String wpStoreId, String userAuth)
|
public void uninviteWebUser(String wpStoreId, String userAuth)
|
||||||
{
|
{
|
||||||
uninviteWebUser(findWebProjectNodeFromStore(wpStoreId), userAuth, false);
|
uninviteWebUser(getWebProjectNodeFromStore(wpStoreId), userAuth, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@@ -1191,7 +1120,7 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
|
|||||||
*/
|
*/
|
||||||
public void uninviteWebUser(String wpStoreId, String userAuth, boolean autoDeleteAuthorSandbox)
|
public void uninviteWebUser(String wpStoreId, String userAuth, boolean autoDeleteAuthorSandbox)
|
||||||
{
|
{
|
||||||
uninviteWebUser(findWebProjectNodeFromStore(wpStoreId), userAuth, autoDeleteAuthorSandbox);
|
uninviteWebUser(getWebProjectNodeFromStore(wpStoreId), userAuth, autoDeleteAuthorSandbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@@ -30,6 +30,7 @@ import org.alfresco.repo.jscript.BaseScopableProcessorExtension;
|
|||||||
import org.alfresco.repo.model.Repository;
|
import org.alfresco.repo.model.Repository;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.wcm.asset.AssetService;
|
import org.alfresco.wcm.asset.AssetService;
|
||||||
import org.alfresco.wcm.sandbox.SandboxService;
|
import org.alfresco.wcm.sandbox.SandboxService;
|
||||||
import org.alfresco.wcm.webproject.WebProjectInfo;
|
import org.alfresco.wcm.webproject.WebProjectInfo;
|
||||||
@@ -55,6 +56,9 @@ public class WebProjects extends BaseScopableProcessorExtension
|
|||||||
/** The asset service */
|
/** The asset service */
|
||||||
private AssetService assetService;
|
private AssetService assetService;
|
||||||
|
|
||||||
|
/** The namespace service */
|
||||||
|
private NamespaceService namespaceService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the Service Registry
|
* Sets the Service Registry
|
||||||
*
|
*
|
||||||
@@ -110,6 +114,21 @@ public class WebProjects extends BaseScopableProcessorExtension
|
|||||||
return this.assetService;
|
return this.assetService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the alfresco namespace service
|
||||||
|
*
|
||||||
|
* @param namespace service
|
||||||
|
*/
|
||||||
|
public void setNamespaceService(NamespaceService namespaceService)
|
||||||
|
{
|
||||||
|
this.namespaceService = namespaceService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NamespaceService getNamespaceService()
|
||||||
|
{
|
||||||
|
return this.namespaceService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create web project
|
* create web project
|
||||||
* @param name
|
* @param name
|
||||||
|
Reference in New Issue
Block a user