mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -22,6 +22,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
@@ -36,6 +37,7 @@ import org.alfresco.model.WCMAppModel;
|
|||||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||||
import org.alfresco.repo.avm.actions.AVMRevertStoreAction;
|
import org.alfresco.repo.avm.actions.AVMRevertStoreAction;
|
||||||
import org.alfresco.repo.avm.actions.AVMUndoSandboxListAction;
|
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.Action;
|
||||||
import org.alfresco.service.cmr.action.ActionService;
|
import org.alfresco.service.cmr.action.ActionService;
|
||||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||||
@@ -79,7 +81,7 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
*/
|
*/
|
||||||
public class AVMBrowseBean implements IContextListener
|
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_SUCCESS = "revert_success";
|
||||||
private static final String MSG_REVERT_SANDBOX = "revert_sandbox_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);
|
UIContextService.getInstance(FacesContext.getCurrentInstance()).registerBean(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Bean property getters and setters
|
// Bean property getters and setters
|
||||||
|
|
||||||
@@ -230,25 +231,24 @@ public class AVMBrowseBean implements IContextListener
|
|||||||
*/
|
*/
|
||||||
public String getStagingSummary()
|
public String getStagingSummary()
|
||||||
{
|
{
|
||||||
StringBuilder summary = new StringBuilder(128);
|
final StringBuilder summary = new StringBuilder(128);
|
||||||
|
final FacesContext fc = FacesContext.getCurrentInstance();
|
||||||
FacesContext fc = FacesContext.getCurrentInstance();
|
final ResourceBundle msg = Application.getBundle(fc);
|
||||||
ResourceBundle msg = Application.getBundle(fc);
|
final String stagingStore = this.getStagingStore();
|
||||||
String storeRoot = (String)getWebsite().getProperties().get(WCMAppModel.PROP_AVMSTORE);
|
final AVMStoreDescriptor store = this.avmService.getStore(stagingStore);
|
||||||
String stagingStore = getStagingStore();
|
final String storeId = (String)getWebsite().getProperties().get(WCMAppModel.PROP_AVMSTORE);
|
||||||
AVMStoreDescriptor store = this.avmService.getStore(stagingStore);
|
|
||||||
if (store != null)
|
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(": ")
|
summary.append(msg.getString(MSG_CREATED_ON)).append(": ")
|
||||||
.append(Utils.getDateFormat(fc).format(new Date(store.getCreateDate())))
|
.append(Utils.getDateFormat(fc).format(new Date(store.getCreateDate())))
|
||||||
.append("<p>");
|
.append("<p>");
|
||||||
summary.append(msg.getString(MSG_CREATED_BY)).append(": ")
|
summary.append(msg.getString(MSG_CREATED_BY)).append(": ")
|
||||||
.append(store.getCreator())
|
.append(store.getCreator())
|
||||||
.append("<p>");
|
.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
|
// reset the current path so the context for the Modified File list actions is cleared
|
||||||
@@ -257,6 +257,32 @@ public class AVMBrowseBean implements IContextListener
|
|||||||
return summary.toString();
|
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
|
* @return the current staging store name
|
||||||
*/
|
*/
|
||||||
@@ -779,8 +805,8 @@ public class AVMBrowseBean implements IContextListener
|
|||||||
|
|
||||||
/*package*/ void setupContentAction(final String path, final boolean refresh)
|
/*package*/ void setupContentAction(final String path, final boolean refresh)
|
||||||
{
|
{
|
||||||
if (logger.isDebugEnabled())
|
if (LOGGER.isDebugEnabled())
|
||||||
logger.debug("Setup content action for path: " + path);
|
LOGGER.debug("Setup content action for path: " + path);
|
||||||
|
|
||||||
if (path == null && path.length() == 0)
|
if (path == null && path.length() == 0)
|
||||||
{
|
{
|
||||||
|
@@ -600,14 +600,21 @@ public final class AVMConstants
|
|||||||
|
|
||||||
// system property keys for sandbox identification and DNS virtualisation mapping
|
// system property keys for sandbox identification and DNS virtualisation mapping
|
||||||
public final static String PROP_SANDBOXID = ".sandbox-id.";
|
public final static String PROP_SANDBOXID = ".sandbox-id.";
|
||||||
public final static String PROP_SANDBOX_STAGING_MAIN = ".sandbox.staging.main";
|
public final static QName PROP_SANDBOX_STAGING_MAIN =
|
||||||
public final static String PROP_SANDBOX_STAGING_PREVIEW = ".sandbox.staging.preview";
|
QName.createQName(null, ".sandbox.staging.main");
|
||||||
public final static String PROP_SANDBOX_AUTHOR_MAIN = ".sandbox.author.main";
|
public final static QName PROP_SANDBOX_STAGING_PREVIEW =
|
||||||
public final static String PROP_SANDBOX_AUTHOR_PREVIEW = ".sandbox.author.preview";
|
QName.createQName(null, ".sandbox.staging.preview");
|
||||||
public final static String PROP_SANDBOX_WORKFLOW_MAIN = ".sandbox.workflow.main";
|
public final static QName PROP_SANDBOX_AUTHOR_MAIN =
|
||||||
public final static String PROP_SANDBOX_WORKFLOW_PREVIEW = ".sandbox.workflow.preview";
|
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_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 PROP_SANDBOX_STORE_PREFIX = ".sandbox.store.";
|
||||||
public final static String SPACE_ICON_WEBSITE = "space-icon-website";
|
public final static String SPACE_ICON_WEBSITE = "space-icon-website";
|
||||||
|
|
||||||
|
@@ -91,7 +91,7 @@ public final class SandboxFactory
|
|||||||
|
|
||||||
// tag the store with the store type
|
// tag the store with the store type
|
||||||
avmService.setStoreProperty(stagingStoreName,
|
avmService.setStoreProperty(stagingStoreName,
|
||||||
QName.createQName(null, AVMConstants.PROP_SANDBOX_STAGING_MAIN),
|
AVMConstants.PROP_SANDBOX_STAGING_MAIN,
|
||||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||||
|
|
||||||
// tag the store with the DNS name property
|
// tag the store with the DNS name property
|
||||||
@@ -121,7 +121,7 @@ public final class SandboxFactory
|
|||||||
|
|
||||||
// tag the store with the store type
|
// tag the store with the store type
|
||||||
avmService.setStoreProperty(previewStoreName,
|
avmService.setStoreProperty(previewStoreName,
|
||||||
QName.createQName(null, AVMConstants.PROP_SANDBOX_STAGING_PREVIEW),
|
AVMConstants.PROP_SANDBOX_STAGING_PREVIEW,
|
||||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||||
|
|
||||||
// tag the store with the DNS name property
|
// 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
|
// 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,
|
avmService.setStoreProperty(stagingStoreName,
|
||||||
QName.createQName(null, sandboxIdProp),
|
sandboxIdProp,
|
||||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||||
avmService.setStoreProperty(previewStoreName,
|
avmService.setStoreProperty(previewStoreName,
|
||||||
QName.createQName(null, sandboxIdProp),
|
sandboxIdProp,
|
||||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
@@ -204,13 +204,13 @@ public final class SandboxFactory
|
|||||||
|
|
||||||
// tag the store with the store type
|
// tag the store with the store type
|
||||||
avmService.setStoreProperty(userStoreName,
|
avmService.setStoreProperty(userStoreName,
|
||||||
QName.createQName(null, AVMConstants.PROP_SANDBOX_AUTHOR_MAIN),
|
AVMConstants.PROP_SANDBOX_AUTHOR_MAIN,
|
||||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||||
|
|
||||||
// tag the store with the base name of the website so that corresponding
|
// tag the store with the base name of the website so that corresponding
|
||||||
// staging areas can be found.
|
// staging areas can be found.
|
||||||
avmService.setStoreProperty(userStoreName,
|
avmService.setStoreProperty(userStoreName,
|
||||||
QName.createQName(null, AVMConstants.PROP_WEBSITE_NAME),
|
AVMConstants.PROP_WEBSITE_NAME,
|
||||||
new PropertyValue(DataTypeDefinition.TEXT, storeId));
|
new PropertyValue(DataTypeDefinition.TEXT, storeId));
|
||||||
|
|
||||||
// tag the store, oddly enough, with its own store name for querying.
|
// 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
|
// tag the store with the store type
|
||||||
avmService.setStoreProperty(previewStoreName,
|
avmService.setStoreProperty(previewStoreName,
|
||||||
QName.createQName(null, AVMConstants.PROP_SANDBOX_AUTHOR_PREVIEW),
|
AVMConstants.PROP_SANDBOX_AUTHOR_PREVIEW,
|
||||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||||
|
|
||||||
// tag the store with its own store name for querying.
|
// 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
|
// tag all related stores to indicate that they are part of a single sandbox
|
||||||
String sandboxIdProp = AVMConstants.PROP_SANDBOXID + GUID.generate();
|
QName sandboxIdProp = QName.createQName(null, AVMConstants.PROP_SANDBOXID + GUID.generate());
|
||||||
avmService.setStoreProperty(userStoreName, QName.createQName(null, sandboxIdProp),
|
avmService.setStoreProperty(userStoreName,
|
||||||
|
sandboxIdProp,
|
||||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||||
avmService.setStoreProperty(previewStoreName, QName.createQName(null, sandboxIdProp),
|
avmService.setStoreProperty(previewStoreName,
|
||||||
|
sandboxIdProp,
|
||||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
@@ -314,22 +316,16 @@ public final class SandboxFactory
|
|||||||
avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(stagingStoreName),
|
avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(stagingStoreName),
|
||||||
workflowMainStoreName + ":/",
|
workflowMainStoreName + ":/",
|
||||||
AVMConstants.DIR_APPBASE);
|
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
|
// tag the store with the store type
|
||||||
avmService.setStoreProperty(workflowMainStoreName,
|
avmService.setStoreProperty(workflowMainStoreName,
|
||||||
QName.createQName(null, AVMConstants.PROP_SANDBOX_WORKFLOW_MAIN),
|
AVMConstants.PROP_SANDBOX_WORKFLOW_MAIN,
|
||||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||||
|
|
||||||
// tag the store with the base name of the website so that corresponding
|
// tag the store with the base name of the website so that corresponding
|
||||||
// staging areas can be found.
|
// staging areas can be found.
|
||||||
avmService.setStoreProperty(workflowMainStoreName,
|
avmService.setStoreProperty(workflowMainStoreName,
|
||||||
QName.createQName(null, AVMConstants.PROP_WEBSITE_NAME),
|
AVMConstants.PROP_WEBSITE_NAME,
|
||||||
new PropertyValue(DataTypeDefinition.TEXT, storeId));
|
new PropertyValue(DataTypeDefinition.TEXT, storeId));
|
||||||
|
|
||||||
// tag the store, oddly enough, with its own store name for querying.
|
// 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),
|
avmService.createLayeredDirectory(AVMConstants.buildStoreRootPath(workflowMainStoreName),
|
||||||
workflowPreviewStoreName + ":/",
|
workflowPreviewStoreName + ":/",
|
||||||
AVMConstants.DIR_APPBASE);
|
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
|
// tag the store with the store type
|
||||||
avmService.setStoreProperty(workflowPreviewStoreName,
|
avmService.setStoreProperty(workflowPreviewStoreName,
|
||||||
QName.createQName(null, AVMConstants.PROP_SANDBOX_WORKFLOW_PREVIEW),
|
AVMConstants.PROP_SANDBOX_WORKFLOW_PREVIEW,
|
||||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||||
|
|
||||||
// tag the store with its own store name for querying.
|
// 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
|
// 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(workflowMainStoreName, QName.createQName(null, sandboxIdProp),
|
avmService.setStoreProperty(workflowMainStoreName,
|
||||||
|
sandboxIdProp,
|
||||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||||
avmService.setStoreProperty(workflowPreviewStoreName, QName.createQName(null, sandboxIdProp),
|
avmService.setStoreProperty(workflowPreviewStoreName,
|
||||||
|
sandboxIdProp,
|
||||||
new PropertyValue(DataTypeDefinition.TEXT, null));
|
new PropertyValue(DataTypeDefinition.TEXT, null));
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
|
Reference in New Issue
Block a user