REST API command support for launching the XForms edit content dialog. AVM Templating API addition to retrieve the list of modified items for a sandbox user.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5858 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2007-06-05 20:21:57 +00:00
parent 494859be2d
commit 74b2ac0c79
2 changed files with 98 additions and 29 deletions

View File

@@ -46,6 +46,9 @@
<property name="serviceRegistry"> <property name="serviceRegistry">
<ref bean="ServiceRegistry"/> <ref bean="ServiceRegistry"/>
</property> </property>
<property name="nameMatcher">
<ref bean="globalPathExcluder"/>
</property>
</bean> </bean>
<bean id="sessionTemplateExtension" parent="baseTemplateImplementation" class="org.alfresco.repo.template.Session"> <bean id="sessionTemplateExtension" parent="baseTemplateImplementation" class="org.alfresco.repo.template.Session">

View File

@@ -25,14 +25,19 @@
package org.alfresco.repo.template; package org.alfresco.repo.template;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.alfresco.config.JNDIConstants; import org.alfresco.config.JNDIConstants;
import org.alfresco.repo.domain.PropertyValue; import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor; import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor; import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.util.NameMatcher;
import org.alfresco.util.ParameterCheck; import org.alfresco.util.ParameterCheck;
/** /**
@@ -43,6 +48,7 @@ import org.alfresco.util.ParameterCheck;
public class AVM extends BaseTemplateProcessorExtension public class AVM extends BaseTemplateProcessorExtension
{ {
private ServiceRegistry services; private ServiceRegistry services;
private NameMatcher matcher;
/** /**
* Sets the service registry * Sets the service registry
@@ -54,6 +60,11 @@ public class AVM extends BaseTemplateProcessorExtension
this.services = services; this.services = services;
} }
public void setNameMatcher(NameMatcher matcher)
{
this.matcher = matcher;
}
/** /**
* Return an AVM store object for the specified store name * Return an AVM store object for the specified store name
* *
@@ -63,6 +74,7 @@ public class AVM extends BaseTemplateProcessorExtension
*/ */
public AVMTemplateStore lookupStore(String store) public AVMTemplateStore lookupStore(String store)
{ {
ParameterCheck.mandatoryString("Store", store);
AVMTemplateStore avmStore = null; AVMTemplateStore avmStore = null;
AVMStoreDescriptor descriptor = this.services.getAVMService().getStore(store); AVMStoreDescriptor descriptor = this.services.getAVMService().getStore(store);
if (descriptor != null) if (descriptor != null)
@@ -81,14 +93,12 @@ public class AVM extends BaseTemplateProcessorExtension
*/ */
public AVMTemplateNode lookupStoreRoot(String store) public AVMTemplateNode lookupStoreRoot(String store)
{ {
ParameterCheck.mandatoryString("Store", store);
AVMTemplateNode root = null; AVMTemplateNode root = null;
if (store != null && store.length() != 0) AVMTemplateStore avmStore = lookupStore(store);
if (avmStore != null)
{ {
AVMTemplateStore avmStore = lookupStore(store); root = avmStore.getLookupRoot();
if (avmStore != null)
{
root = avmStore.getLookupRoot();
}
} }
return root; return root;
} }
@@ -102,25 +112,67 @@ public class AVM extends BaseTemplateProcessorExtension
*/ */
public AVMTemplateNode lookupNode(String path) public AVMTemplateNode lookupNode(String path)
{ {
ParameterCheck.mandatoryString("AVM Path", path);
AVMTemplateNode node = null; AVMTemplateNode node = null;
if (path != null && path.length() != 0) AVMNodeDescriptor nodeDesc = this.services.getAVMService().lookup(-1, path);
if (nodeDesc != null)
{ {
AVMNodeDescriptor nodeDesc = this.services.getAVMService().lookup(-1, path); node = new AVMTemplateNode(path, -1, this.services, getTemplateImageResolver());
if (nodeDesc != null)
{
node = new AVMTemplateNode(path, -1, this.services, getTemplateImageResolver());
}
} }
return node; return node;
} }
/**
* Return the list of modified items for the specified user sandbox against staging store id
* for a specific webapp.
*
* @param storeId Root Store ID
* @param username Username to get modified items for
* @param webapp Webapp name to filter by
*
* @return List of AVMTemplateNode objects representing the modified items
*/
public List<AVMTemplateNode> getModifiedItems(String storeId, String username, String webapp)
{
ParameterCheck.mandatoryString("Store ID", storeId);
ParameterCheck.mandatoryString("Username", username);
ParameterCheck.mandatoryString("Webapp", webapp);
List<AVMTemplateNode> items;
AVMService avmService = this.services.getAVMService();
// build the paths to the stores to compare - filter by current webapp
String userStore = userSandboxStore(storeId, username);
String userStorePath = getStoreRootWebappPath(userStore, webapp);
String stagingStore = stagingStore(storeId);
String stagingStorePath = getStoreRootWebappPath(stagingStore, webapp);
List<AVMDifference> diffs = this.services.getAVMSyncService().compare(
-1, userStorePath, -1, stagingStorePath, this.matcher);
items = new ArrayList<AVMTemplateNode>(diffs.size());
for (AVMDifference diff : diffs)
{
// convert each diff record into an AVM Node template wrapper
String sourcePath = diff.getSourcePath();
AVMNodeDescriptor node = avmService.lookup(-1, sourcePath);
if (node != null)
{
items.add(new AVMTemplateNode(node, this.services, getTemplateImageResolver()));
}
}
return items;
}
/** /**
* @param storeId Store ID to build staging store name for * @param storeId Store ID to build staging store name for
* *
* @return the Staging Store name for the given store ID * @return the Staging Store name for the given store ID
*/ */
public String stagingStore(String storeId) public static String stagingStore(String storeId)
{ {
ParameterCheck.mandatoryString("Store ID", storeId);
return storeId; return storeId;
} }
@@ -130,7 +182,7 @@ public class AVM extends BaseTemplateProcessorExtension
* *
* @return the Sandbox Store name for the given store ID and username * @return the Sandbox Store name for the given store ID and username
*/ */
public String userSandboxStore(String storeId, String username) public static String userSandboxStore(String storeId, String username)
{ {
ParameterCheck.mandatoryString("Store ID", storeId); ParameterCheck.mandatoryString("Store ID", storeId);
ParameterCheck.mandatoryString("Username", username); ParameterCheck.mandatoryString("Username", username);
@@ -144,6 +196,7 @@ public class AVM extends BaseTemplateProcessorExtension
*/ */
public String websiteStagingUrl(String storeId) public String websiteStagingUrl(String storeId)
{ {
ParameterCheck.mandatoryString("Store ID", storeId);
return MessageFormat.format(JNDIConstants.PREVIEW_SANDBOX_URL, return MessageFormat.format(JNDIConstants.PREVIEW_SANDBOX_URL,
lookupStoreDNS(storeId), getVServerDomain(), getVServerPort()); lookupStoreDNS(storeId), getVServerDomain(), getVServerPort());
} }
@@ -156,6 +209,8 @@ public class AVM extends BaseTemplateProcessorExtension
*/ */
public String websiteUserSandboxUrl(String storeId, String username) public String websiteUserSandboxUrl(String storeId, String username)
{ {
ParameterCheck.mandatoryString("Store ID", storeId);
ParameterCheck.mandatoryString("Username", username);
return websiteStagingUrl(userSandboxStore(storeId, username)); return websiteStagingUrl(userSandboxStore(storeId, username));
} }
@@ -169,11 +224,12 @@ public class AVM extends BaseTemplateProcessorExtension
{ {
ParameterCheck.mandatoryString("Store", store); ParameterCheck.mandatoryString("Store", store);
ParameterCheck.mandatoryString("Asset Path", assetPath); ParameterCheck.mandatoryString("Asset Path", assetPath);
if (assetPath.startsWith('/' + JNDIConstants.DIR_DEFAULT_WWW + if (assetPath.startsWith('/' + JNDIConstants.DIR_DEFAULT_WWW +
'/' + JNDIConstants.DIR_DEFAULT_APPBASE)) '/' + JNDIConstants.DIR_DEFAULT_APPBASE))
{ {
assetPath = assetPath.substring(('/' + JNDIConstants.DIR_DEFAULT_WWW + assetPath = assetPath.substring(('/' + JNDIConstants.DIR_DEFAULT_WWW +
'/' + JNDIConstants.DIR_DEFAULT_APPBASE).length()); '/' + JNDIConstants.DIR_DEFAULT_APPBASE).length());
} }
if (assetPath.startsWith("/ROOT")) if (assetPath.startsWith("/ROOT"))
{ {
@@ -235,7 +291,17 @@ public class AVM extends BaseTemplateProcessorExtension
public static String getWebappsFolderPath() public static String getWebappsFolderPath()
{ {
return '/' + JNDIConstants.DIR_DEFAULT_WWW + return '/' + JNDIConstants.DIR_DEFAULT_WWW +
'/' + JNDIConstants.DIR_DEFAULT_APPBASE; '/' + JNDIConstants.DIR_DEFAULT_APPBASE;
}
private static String getStoreRootPath(String store)
{
return store + ":" + getWebappsFolderPath();
}
private static String getStoreRootWebappPath(String store, String webapp)
{
return getStoreRootPath(store) + '/' + webapp;
} }
private String lookupStoreDNS(String store) private String lookupStoreDNS(String store)