fixing the query for number of main user stores for display in the staging summary (number of users in the project). this got broken in yesterday's checkin.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4694 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ariel Backenroth
2006-12-23 22:55:53 +00:00
parent 15733b9771
commit df84dcde28
3 changed files with 76 additions and 51 deletions

View File

@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
@@ -36,6 +37,7 @@ import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.avm.actions.AVMRevertStoreAction;
import org.alfresco.repo.avm.actions.AVMUndoSandboxListAction;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
@@ -79,7 +81,7 @@ import org.apache.commons.logging.LogFactory;
*/
public class AVMBrowseBean implements IContextListener
{
private static Log logger = LogFactory.getLog(AVMBrowseBean.class);
private static final Log LOGGER = LogFactory.getLog(AVMBrowseBean.class);
private static final String MSG_REVERT_SUCCESS = "revert_success";
private static final String MSG_REVERT_SANDBOX = "revert_sandbox_success";
@@ -165,7 +167,6 @@ public class AVMBrowseBean implements IContextListener
UIContextService.getInstance(FacesContext.getCurrentInstance()).registerBean(this);
}
// ------------------------------------------------------------------------------
// Bean property getters and setters
@@ -230,25 +231,24 @@ public class AVMBrowseBean implements IContextListener
*/
public String getStagingSummary()
{
StringBuilder summary = new StringBuilder(128);
FacesContext fc = FacesContext.getCurrentInstance();
ResourceBundle msg = Application.getBundle(fc);
String storeRoot = (String)getWebsite().getProperties().get(WCMAppModel.PROP_AVMSTORE);
String stagingStore = getStagingStore();
AVMStoreDescriptor store = this.avmService.getStore(stagingStore);
final StringBuilder summary = new StringBuilder(128);
final FacesContext fc = FacesContext.getCurrentInstance();
final ResourceBundle msg = Application.getBundle(fc);
final String stagingStore = this.getStagingStore();
final AVMStoreDescriptor store = this.avmService.getStore(stagingStore);
final String storeId = (String)getWebsite().getProperties().get(WCMAppModel.PROP_AVMSTORE);
if (store != null)
{
// count user stores
int users = avmService.queryStoresPropertyKeys(QName.createQName(null,
AVMConstants.PROP_SANDBOX_STORE_PREFIX + storeRoot + "-%")).size() / 2;
summary.append(msg.getString(MSG_CREATED_ON)).append(": ")
.append(Utils.getDateFormat(fc).format(new Date(store.getCreateDate())))
.append("<p>");
summary.append(msg.getString(MSG_CREATED_BY)).append(": ")
.append(store.getCreator())
.append("<p>");
summary.append(MessageFormat.format(msg.getString(MSG_WORKING_USERS), users));
final int numUsers = this.getRelatedStoreNames(storeId,
AVMConstants.PROP_SANDBOX_AUTHOR_MAIN).size();
summary.append(MessageFormat.format(msg.getString(MSG_WORKING_USERS), numUsers));
}
// reset the current path so the context for the Modified File list actions is cleared
@@ -256,6 +256,32 @@ public class AVMBrowseBean implements IContextListener
return summary.toString();
}
/**
* Returns the list of store names related to the storeId provided that have
* any of the provided types as store properties.
*
* @return a list of related store names.
*/
private List<String> getRelatedStoreNames(final String storeId, final QName... types)
{
QName qn = QName.createQName(null, AVMConstants.PROP_SANDBOX_STORE_PREFIX + storeId + "%");
final Map<String, Map<QName, PropertyValue>> relatedSandboxes =
avmService.queryStoresPropertyKeys(qn);
final List<String> result = new LinkedList<String>();
for (String storeName : relatedSandboxes.keySet())
{
for (final QName type : types)
{
if (this.avmService.getStoreProperty(storeName, type) != null)
{
result.add(storeName);
break;
}
}
}
return result;
}
/**
* @return the current staging store name
@@ -779,8 +805,8 @@ public class AVMBrowseBean implements IContextListener
/*package*/ void setupContentAction(final String path, final boolean refresh)
{
if (logger.isDebugEnabled())
logger.debug("Setup content action for path: " + path);
if (LOGGER.isDebugEnabled())
LOGGER.debug("Setup content action for path: " + path);
if (path == null && path.length() == 0)
{

View File

@@ -600,14 +600,21 @@ public final class AVMConstants
// system property keys for sandbox identification and DNS virtualisation mapping
public final static String PROP_SANDBOXID = ".sandbox-id.";
public final static String PROP_SANDBOX_STAGING_MAIN = ".sandbox.staging.main";
public final static String PROP_SANDBOX_STAGING_PREVIEW = ".sandbox.staging.preview";
public final static String PROP_SANDBOX_AUTHOR_MAIN = ".sandbox.author.main";
public final static String PROP_SANDBOX_AUTHOR_PREVIEW = ".sandbox.author.preview";
public final static String PROP_SANDBOX_WORKFLOW_MAIN = ".sandbox.workflow.main";
public final static String PROP_SANDBOX_WORKFLOW_PREVIEW = ".sandbox.workflow.preview";
public final static QName PROP_SANDBOX_STAGING_MAIN =
QName.createQName(null, ".sandbox.staging.main");
public final static QName PROP_SANDBOX_STAGING_PREVIEW =
QName.createQName(null, ".sandbox.staging.preview");
public final static QName PROP_SANDBOX_AUTHOR_MAIN =
QName.createQName(null, ".sandbox.author.main");
public final static QName PROP_SANDBOX_AUTHOR_PREVIEW =
QName.createQName(null, ".sandbox.author.preview");
public final static QName PROP_SANDBOX_WORKFLOW_MAIN =
QName.createQName(null, ".sandbox.workflow.main");
public final static QName PROP_SANDBOX_WORKFLOW_PREVIEW =
QName.createQName(null, ".sandbox.workflow.preview");
public final static String PROP_DNS = ".dns.";
public final static String PROP_WEBSITE_NAME = ".website.name";
public final static QName PROP_WEBSITE_NAME =
QName.createQName(null, ".website.name");
public final static String PROP_SANDBOX_STORE_PREFIX = ".sandbox.store.";
public final static String SPACE_ICON_WEBSITE = "space-icon-website";

View File

@@ -91,7 +91,7 @@ public final class SandboxFactory
// tag the store with the store type
avmService.setStoreProperty(stagingStoreName,
QName.createQName(null, AVMConstants.PROP_SANDBOX_STAGING_MAIN),
AVMConstants.PROP_SANDBOX_STAGING_MAIN,
new PropertyValue(DataTypeDefinition.TEXT, null));
// tag the store with the DNS name property
@@ -121,7 +121,7 @@ public final class SandboxFactory
// tag the store with the store type
avmService.setStoreProperty(previewStoreName,
QName.createQName(null, AVMConstants.PROP_SANDBOX_STAGING_PREVIEW),
AVMConstants.PROP_SANDBOX_STAGING_PREVIEW,
new PropertyValue(DataTypeDefinition.TEXT, null));
// tag the store with the DNS name property
@@ -132,12 +132,12 @@ public final class SandboxFactory
// tag all related stores to indicate that they are part of a single sandbox
String sandboxIdProp = AVMConstants.PROP_SANDBOXID + GUID.generate();
final QName sandboxIdProp = QName.createQName(AVMConstants.PROP_SANDBOXID + GUID.generate());
avmService.setStoreProperty(stagingStoreName,
QName.createQName(null, sandboxIdProp),
sandboxIdProp,
new PropertyValue(DataTypeDefinition.TEXT, null));
avmService.setStoreProperty(previewStoreName,
QName.createQName(null, sandboxIdProp),
sandboxIdProp,
new PropertyValue(DataTypeDefinition.TEXT, null));
if (logger.isDebugEnabled())
@@ -204,13 +204,13 @@ public final class SandboxFactory
// tag the store with the store type
avmService.setStoreProperty(userStoreName,
QName.createQName(null, AVMConstants.PROP_SANDBOX_AUTHOR_MAIN),
AVMConstants.PROP_SANDBOX_AUTHOR_MAIN,
new PropertyValue(DataTypeDefinition.TEXT, null));
// tag the store with the base name of the website so that corresponding
// staging areas can be found.
avmService.setStoreProperty(userStoreName,
QName.createQName(null, AVMConstants.PROP_WEBSITE_NAME),
AVMConstants.PROP_WEBSITE_NAME,
new PropertyValue(DataTypeDefinition.TEXT, storeId));
// tag the store, oddly enough, with its own store name for querying.
@@ -246,7 +246,7 @@ public final class SandboxFactory
// tag the store with the store type
avmService.setStoreProperty(previewStoreName,
QName.createQName(null, AVMConstants.PROP_SANDBOX_AUTHOR_PREVIEW),
AVMConstants.PROP_SANDBOX_AUTHOR_PREVIEW,
new PropertyValue(DataTypeDefinition.TEXT, null));
// tag the store with its own store name for querying.
@@ -262,10 +262,12 @@ public final class SandboxFactory
// tag all related stores to indicate that they are part of a single sandbox
String sandboxIdProp = AVMConstants.PROP_SANDBOXID + GUID.generate();
avmService.setStoreProperty(userStoreName, QName.createQName(null, sandboxIdProp),
QName sandboxIdProp = QName.createQName(null, AVMConstants.PROP_SANDBOXID + GUID.generate());
avmService.setStoreProperty(userStoreName,
sandboxIdProp,
new PropertyValue(DataTypeDefinition.TEXT, null));
avmService.setStoreProperty(previewStoreName, QName.createQName(null, sandboxIdProp),
avmService.setStoreProperty(previewStoreName,
sandboxIdProp,
new PropertyValue(DataTypeDefinition.TEXT, null));
if (logger.isDebugEnabled())
@@ -314,22 +316,16 @@ public final class SandboxFactory
avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(stagingStoreName),
workflowMainStoreName + ":/",
AVMConstants.DIR_APPBASE);
// NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, path + '/' + AVMConstants.DIR_APPBASE);
// permissionService.setPermission(dirRef, username, role, true);
// for (String manager : managers)
// {
// permissionService.setPermission(dirRef, manager, ROLE_CONTENT_MANAGER, true);
// }
// tag the store with the store type
avmService.setStoreProperty(workflowMainStoreName,
QName.createQName(null, AVMConstants.PROP_SANDBOX_WORKFLOW_MAIN),
AVMConstants.PROP_SANDBOX_WORKFLOW_MAIN,
new PropertyValue(DataTypeDefinition.TEXT, null));
// tag the store with the base name of the website so that corresponding
// staging areas can be found.
avmService.setStoreProperty(workflowMainStoreName,
QName.createQName(null, AVMConstants.PROP_WEBSITE_NAME),
AVMConstants.PROP_WEBSITE_NAME,
new PropertyValue(DataTypeDefinition.TEXT, storeId));
// tag the store, oddly enough, with its own store name for querying.
@@ -355,16 +351,10 @@ public final class SandboxFactory
avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(workflowMainStoreName),
workflowPreviewStoreName + ":/",
AVMConstants.DIR_APPBASE);
// dirRef = AVMNodeConverter.ToNodeRef(-1, path + '/' + AVMConstants.DIR_APPBASE);
// permissionService.setPermission(dirRef, username, role, true);
// for (String manager : managers)
// {
// permissionService.setPermission(dirRef, manager, ROLE_CONTENT_MANAGER, true);
// }
// tag the store with the store type
avmService.setStoreProperty(workflowPreviewStoreName,
QName.createQName(null, AVMConstants.PROP_SANDBOX_WORKFLOW_PREVIEW),
AVMConstants.PROP_SANDBOX_WORKFLOW_PREVIEW,
new PropertyValue(DataTypeDefinition.TEXT, null));
// tag the store with its own store name for querying.
@@ -381,10 +371,12 @@ public final class SandboxFactory
// tag all related stores to indicate that they are part of a single sandbox
String sandboxIdProp = AVMConstants.PROP_SANDBOXID + GUID.generate();
avmService.setStoreProperty(workflowMainStoreName, QName.createQName(null, sandboxIdProp),
final QName sandboxIdProp = QName.createQName(AVMConstants.PROP_SANDBOXID + GUID.generate());
avmService.setStoreProperty(workflowMainStoreName,
sandboxIdProp,
new PropertyValue(DataTypeDefinition.TEXT, null));
avmService.setStoreProperty(workflowPreviewStoreName, QName.createQName(null, sandboxIdProp),
avmService.setStoreProperty(workflowPreviewStoreName,
sandboxIdProp,
new PropertyValue(DataTypeDefinition.TEXT, null));
if (logger.isDebugEnabled())