Merge WCM_SERVICES into HEAD 11697, 11698, 11702, 11751, 11801, 11924, 12023, 12073

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12076 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2008-11-21 13:59:09 +00:00
parent 71471108fa
commit 4981f27b3e
13 changed files with 159 additions and 555 deletions

View File

@@ -29,7 +29,6 @@ import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -51,16 +50,12 @@ import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.avm.AVMNodeType;
import org.alfresco.repo.avm.actions.AVMRevertStoreAction;
import org.alfresco.repo.avm.actions.AVMUndoSandboxListAction;
import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService;
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.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.repository.FileTypeImageSize;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
@@ -77,6 +72,8 @@ import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.util.Pair;
import org.alfresco.util.VirtServerUtils;
import org.alfresco.wcm.sandbox.SandboxInfo;
import org.alfresco.wcm.sandbox.SandboxService;
import org.alfresco.wcm.webproject.WebProjectInfo;
import org.alfresco.wcm.webproject.WebProjectService;
import org.alfresco.web.app.Application;
@@ -223,12 +220,12 @@ public class AVMBrowseBean implements IContextListener
/** WebProjectService bean reference */
transient protected WebProjectService wpService;
/** SandboxService bean reference */
transient protected SandboxService sbService;
/** AVM service bean reference */
transient protected AVMService avmService;
/** AVM sync service bean reference */
transient protected AVMSyncService avmSyncService;
/** Action service bean reference */
transient protected ActionService actionService;
@@ -275,6 +272,23 @@ public class AVMBrowseBean implements IContextListener
return wpService;
}
/**
* @param sbService The SandboxService to set.
*/
public void setSandboxService(SandboxService sbService)
{
this.sbService = sbService;
}
protected SandboxService getSandboxService()
{
if (sbService == null)
{
sbService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getSandboxService();
}
return sbService;
}
/**
* @param avmService The AVMService to set.
*/
@@ -292,23 +306,6 @@ public class AVMBrowseBean implements IContextListener
return avmService;
}
/**
* @param avmSyncService The AVMSyncService to set.
*/
public void setAvmSyncService(AVMSyncService avmSyncService)
{
this.avmSyncService = avmSyncService;
}
protected AVMSyncService getAvmSyncService()
{
if (avmSyncService == null)
{
avmSyncService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAVMSyncService();
}
return avmSyncService;
}
/**
* @param nodeService The NodeService to set.
*/
@@ -498,22 +495,23 @@ public class AVMBrowseBean implements IContextListener
*/
public String getStagingSummary()
{
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 = getAvmService().getStore(stagingStore);
WebProject webProject = this.getWebProject();
final String storeId = (String)webProject.getStoreId();
if (store != null)
StringBuilder summary = new StringBuilder(128);
FacesContext fc = FacesContext.getCurrentInstance();
ResourceBundle msg = Application.getBundle(fc);
NodeRef wpNodeRef = getWebsite().getNodeRef();
WebProjectInfo wpInfo = getWebProjectService().getWebProject(wpNodeRef);
SandboxInfo sbInfo = getSandboxService().getStagingSandbox(wpInfo.getStoreId());
if (sbInfo != null)
{
summary.append(msg.getString(MSG_CREATED_ON)).append(": ")
.append(Utils.getDateFormat(fc).format(new Date(store.getCreateDate())))
.append(Utils.getDateFormat(fc).format(sbInfo.getCreatedDate()))
.append("<p>");
summary.append(msg.getString(MSG_CREATED_BY)).append(": ")
.append(store.getCreator())
.append(sbInfo.getCreator())
.append("<p>");
final int numUsers = getWebProjectService().getWebUserCount(webProject.getNodeRef());
final int numUsers = getWebProjectService().getWebUserCount(wpNodeRef);
summary.append(MessageFormat.format(msg.getString(MSG_WORKING_USERS), numUsers));
}
@@ -729,14 +727,13 @@ public class AVMBrowseBean implements IContextListener
{
if (this.webapps == null)
{
String path = AVMUtil.buildSandboxRootPath(getStagingStore());
Map<String, AVMNodeDescriptor> folders = getAvmService().getDirectoryListing(-1, path);
List<SelectItem> webapps = new ArrayList<SelectItem>(folders.size());
for (AVMNodeDescriptor node : folders.values())
List<String> webAppNames = getWebProjectService().listWebApps(getWebsite().getNodeRef());
List<SelectItem> webAppItems = new ArrayList<SelectItem>(webAppNames.size());
for (String webAppName : webAppNames)
{
webapps.add(new SelectItem(node.getName(), node.getName()));
webAppItems.add(new SelectItem(webAppName, webAppName));
}
this.webapps = webapps;
this.webapps = webAppItems;
}
return this.webapps;
}
@@ -1341,7 +1338,7 @@ public class AVMBrowseBean implements IContextListener
*/
public boolean getIsStagingStore()
{
return (this.sandbox != null && this.sandbox.indexOf(AVMUtil.STORE_SEPARATOR) == -1);
return AVMUtil.isMainStore(this.sandbox);
}
@@ -1686,38 +1683,10 @@ public class AVMBrowseBean implements IContextListener
String strVersion = params.get("version");
if (sandbox != null && strVersion != null && strVersion.length() != 0)
{
UserTransaction tx = null;
try
{
getSandboxService().revertSnapshot(sandbox, Integer.valueOf(strVersion));
FacesContext context = FacesContext.getCurrentInstance();
tx = Repository.getUserTransaction(context, false);
tx.begin();
String sandboxPath = AVMUtil.buildSandboxRootPath( sandbox );
List<AVMDifference> diffs =
this.getAvmSyncService().compare(
-1,sandboxPath,Integer.valueOf(strVersion),sandboxPath,null);
Map<String, Serializable> args = new HashMap<String, Serializable>(1, 1.0f);
args.put(AVMRevertStoreAction.PARAM_VERSION, Integer.valueOf(strVersion));
Action action = this.getActionService().createAction(AVMRevertStoreAction.NAME, args);
this.getActionService().executeAction(action, AVMNodeConverter.ToNodeRef(-1, sandbox + ":/"));
// commit the transaction
tx.commit();
// See if any of the files being reverted require
// notification of the virt server.
for (AVMDifference diff : diffs)
{
if ( VirtServerUtils.requiresUpdateNotification( diff.getSourcePath()) )
{
AVMUtil.updateVServerWebapp(diff.getSourcePath() , true);
break;
}
}
// if we get here, all was well - output friendly status message to the user
this.displayStatusMessage(context,
@@ -1730,7 +1699,6 @@ public class AVMBrowseBean implements IContextListener
err.printStackTrace(System.err);
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
}
}

View File

@@ -24,7 +24,6 @@
*/
package org.alfresco.web.bean.wcm;
import java.text.MessageFormat;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -39,9 +38,7 @@ import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMNotFoundException;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.wcm.util.WCMUtil;
import org.alfresco.wcm.webproject.WebProjectService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wcm.preview.PreviewURIService;
@@ -88,7 +85,7 @@ public final class AVMUtil extends WCMUtil
public static String getStoreName(final String avmPath)
{
return WCMUtil.getStoreName(avmPath);
return WCMUtil.getSandboxStoreId(avmPath);
}
public static boolean isPreviewStore(final String storeName)
@@ -108,7 +105,7 @@ public final class AVMUtil extends WCMUtil
public static boolean isMainStore(String storeName)
{
return WCMUtil.isMainStore(storeName);
return WCMUtil.isStagingStore(storeName);
}
public static String getUserName(String storeName)
@@ -118,7 +115,7 @@ public final class AVMUtil extends WCMUtil
public static String getStoreId(final String storeName)
{
return WCMUtil.getStoreId(storeName);
return WCMUtil.getWebProjectStoreId(storeName);
}
public static String getCorrespondingMainStoreName(final String storeName)
@@ -275,19 +272,10 @@ public final class AVMUtil extends WCMUtil
public static String buildStoreUrl(String store)
{
if (store == null || store.length() == 0)
{
throw new IllegalArgumentException("Store name is mandatory.");
}
if (store.indexOf(':') != -1)
{
store = store.substring(0, store.indexOf(':'));
}
ServiceRegistry serviceRegistry = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
AVMService avmService = serviceRegistry.getAVMService();
ClientConfigElement config = Application.getClientConfig(FacesContext.getCurrentInstance());
return MessageFormat.format(JNDIConstants.PREVIEW_SANDBOX_URL,
lookupStoreDNS(store),
config.getWCMDomain(),
config.getWCMPort());
return WCMUtil.buildStoreUrl(avmService, store, config.getWCMDomain(), config.getWCMPort());
}
public static String buildWebappUrl(final String avmPath)
@@ -531,12 +519,6 @@ public final class AVMUtil extends WCMUtil
return linksManagementConfig;
}
// Component Separator.
public static final String STORE_SEPARATOR = WCMUtil.STORE_SEPARATOR;
public static final String STORE_WORKFLOW = WCMUtil.STORE_WORKFLOW;
public static final String STORE_PREVIEW = WCMUtil.STORE_PREVIEW;
// pattern for absolute AVM Path
//private final static Pattern STORE_RELATIVE_PATH_PATTERN =
// Pattern.compile("[^:]+:(.+)");

View File

@@ -32,9 +32,7 @@ import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;
@@ -43,15 +41,12 @@ import javax.faces.context.FacesContext;
import org.alfresco.config.ConfigElement;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.WCMAppModel;
import org.alfresco.model.WCMWorkflowModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMNotFoundException;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.LayeringDescriptor;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
@@ -63,9 +58,8 @@ import org.alfresco.service.cmr.workflow.WorkflowDefinition;
import org.alfresco.service.cmr.workflow.WorkflowPath;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.service.cmr.workflow.WorkflowTask;
import org.alfresco.service.cmr.workflow.WorkflowTaskQuery;
import org.alfresco.service.namespace.QName;
import org.alfresco.wcm.sandbox.SandboxInfo;
import org.alfresco.wcm.util.WCMWorkflowUtil;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.workflow.WorkflowUtil;
@@ -257,59 +251,21 @@ public class AVMWorkflowUtil extends WorkflowUtil
public static List<WorkflowTask> getAssociatedTasksForSandbox(final String storeName)
{
final String fromPath = AVMUtil.buildStoreRootPath(storeName);
final FacesContext fc = FacesContext.getCurrentInstance();
final WorkflowService workflowService = Repository.getServiceRegistry(fc).getWorkflowService();
final WorkflowTaskQuery query = new WorkflowTaskQuery();
final HashMap<QName, Object> props = new HashMap<QName, Object>(1, 1.0f);
props.put(WCMWorkflowModel.PROP_FROM_PATH, fromPath);
query.setProcessCustomProps(props);
query.setActive(true);
final List<WorkflowTask> tasks = workflowService.queryTasks(query);
if (logger.isDebugEnabled())
logger.debug("found " + tasks.size() + " tasks originating user sandbox " + fromPath);
return tasks;
FacesContext fc = FacesContext.getCurrentInstance();
WorkflowService workflowService = Repository.getServiceRegistry(fc).getWorkflowService();
return WCMWorkflowUtil.getAssociatedTasksForSandbox(workflowService, storeName);
}
public static List<WorkflowTask> getAssociatedTasksForNode(AVMNodeDescriptor node, List<WorkflowTask> tasks)
{
final List<WorkflowTask> result = new LinkedList<WorkflowTask>();
final FacesContext fc = FacesContext.getCurrentInstance();
final AVMService avmService = Repository.getServiceRegistry(fc).getAVMService();
for (final WorkflowTask task : tasks)
{
final NodeRef ref = task.path.instance.workflowPackage;
final String path = AVMUtil.getCorrespondingPath(node.getPath(), ref.getStoreRef().getIdentifier());
if (logger.isDebugEnabled())
logger.debug("checking store " + ref.getStoreRef().getIdentifier() +
" for " + node.getPath() + " (" + path + ")");
try
{
final LayeringDescriptor ld = avmService.getLayeringInfo(-1, path);
if (!ld.isBackground())
{
if (logger.isDebugEnabled())
logger.debug(path + " is in the foreground. workflow active");
result.add(task);
}
}
catch (final AVMNotFoundException avmnfe)
{
if (logger.isDebugEnabled())
logger.debug(path + " not found");
}
}
return result;
FacesContext fc = FacesContext.getCurrentInstance();
AVMService avmService = Repository.getServiceRegistry(fc).getAVMService();
return WCMWorkflowUtil.getAssociatedTasksForNode(avmService, node, tasks);
}
public static List<WorkflowTask> getAssociatedTasksForNode(AVMNodeDescriptor node)
{
final List<WorkflowTask> tasks = AVMWorkflowUtil.getAssociatedTasksForSandbox(AVMUtil.getStoreName(node.getPath()));
return getAssociatedTasksForNode(node, tasks);
return AVMWorkflowUtil.getAssociatedTasksForNode(node, tasks);
}
}

View File

@@ -90,7 +90,7 @@ public class DeleteSandboxDialog extends BaseDialogBean
if (username != null)
{
Node website = this.avmBrowseBean.getWebsite();
getWebProjectService().uninviteWebUser(website.getNodeRef(), username);
getWebProjectService().uninviteWebUser(website.getNodeRef(), username, true);
String wpStoreId = getWebProjectService().getWebProject(website.getNodeRef()).getStoreId();
String mainStore = AVMUtil.buildUserMainStoreName(wpStoreId, username);

View File

@@ -114,7 +114,7 @@ public class InviteWebsiteUsersWizard extends BaseInviteUsersWizard
selectedInvitees.put(userRole.getAuthority(), userRole.getRole());
}
getWebProjectService().inviteWebUsersGroups(this.getNode().getNodeRef(), selectedInvitees);
getWebProjectService().inviteWebUsersGroups(this.getNode().getNodeRef(), selectedInvitees, true);
return outcome;
}

View File

@@ -38,7 +38,7 @@ import org.alfresco.linkvalidation.LinkValidationAction;
import org.alfresco.linkvalidation.LinkValidationReport;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.sandbox.SandboxConstants;
import org.alfresco.wcm.sandbox.SandboxConstants;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.avm.AVMService;
@@ -129,8 +129,7 @@ public class LinkValidationDialog extends BaseDialogBean
SandboxConstants.PROP_SANDBOX_AUTHOR_MAIN) != null)
{
String pattern = Application.getMessage(context, "link_validaton_dialog_title_user");
String user = this.store.substring(
this.store.indexOf(AVMUtil.STORE_SEPARATOR)+AVMUtil.STORE_SEPARATOR.length());
String user = AVMUtil.getUserName(this.store);
this.title = MessageFormat.format(pattern,
new Object[] {user});
}

View File

@@ -24,29 +24,13 @@
*/
package org.alfresco.web.bean.wcm;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import org.alfresco.repo.avm.actions.AVMUndoSandboxListAction;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.workflow.WorkflowTask;
import org.alfresco.util.NameMatcher;
import org.alfresco.util.Pair;
import org.alfresco.util.VirtServerUtils;
import org.alfresco.wcm.sandbox.SandboxService;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Repository;
@@ -62,39 +46,22 @@ public class RevertAllDialog extends BaseDialogBean
private static final String MSG_REVERTALL_SUCCESS = "revertall_success";
protected AVMBrowseBean avmBrowseBean;
transient private SandboxService sbService;
transient private AVMService avmService;
transient private AVMSyncService avmSyncService;
transient private ActionService actionService;
transient private NameMatcher nameMatcher;
// The virtualization server might need to be notified
// because one or more of the files reverted could alter
// the behavior the virtual webapp in the target of the submit.
private String virtUpdatePath;
/**
* @param avmService the avmService to set
*/
public void setAvmService(AVMService avmService)
public void setSandboxService(SandboxService sbService)
{
this.avmService = avmService;
this.sbService = sbService;
}
protected AVMService getAvmService()
protected SandboxService getSandboxService()
{
if (this.avmService == null)
if (this.sbService == null)
{
this.avmService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAVMService();
this.sbService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getSandboxService();
}
return this.avmService;
return this.sbService;
}
/**
* @param avmBrowseBean The AVM BrowseBean to set
*/
@@ -103,103 +70,16 @@ public class RevertAllDialog extends BaseDialogBean
this.avmBrowseBean = avmBrowseBean;
}
/**
* @param avmSyncService The AVMSyncService to set.
*/
public void setAvmSyncService(AVMSyncService avmSyncService)
{
this.avmSyncService = avmSyncService;
}
protected AVMSyncService getAvmSyncService()
{
if (this.avmSyncService == null)
{
this.avmSyncService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAVMSyncService();
}
return this.avmSyncService;
}
/**
* @param actionService The actionService to set.
*/
public void setActionService(ActionService actionService)
{
this.actionService = actionService;
}
protected ActionService getActionService()
{
if (this.actionService == null)
{
this.actionService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getActionService();
}
return this.actionService;
}
/**
* @param nameMatcher The nameMatcher to set.
*/
public void setNameMatcher(NameMatcher nameMatcher)
{
this.nameMatcher = nameMatcher;
}
/**
* @return nameMatcher
*/
protected NameMatcher getNameMatcher()
{
//check for null for cluster environment
if (nameMatcher == null)
{
nameMatcher = (NameMatcher) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "globalPathExcluder");
}
return nameMatcher;
}
/**
* @see org.alfresco.web.bean.dialog.BaseDialogBean#finishImpl(javax.faces.context.FacesContext, java.lang.String)
*/
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
String webapp = this.avmBrowseBean.getWebapp();
String userStore = AVMUtil.buildStoreWebappPath(this.avmBrowseBean.getSandbox(), webapp);
String stagingStore = AVMUtil.buildStoreWebappPath(this.avmBrowseBean.getStagingStore(), webapp);
String webApp = this.avmBrowseBean.getWebapp();
String userSandboxId = this.avmBrowseBean.getSandbox();
// calcluate the list of differences between the user store and the staging area
List<AVMDifference> diffs = this.getAvmSyncService().compare(
-1, userStore, -1, stagingStore, getNameMatcher());
List<Pair<Integer, String>> versionPaths = new ArrayList<Pair<Integer, String>>();
List<WorkflowTask> tasks = null;
for (AVMDifference diff : diffs)
{
AVMNodeDescriptor node = getAvmService().lookup(-1, diff.getSourcePath(), true);
if (tasks == null)
{
tasks = AVMWorkflowUtil.getAssociatedTasksForSandbox(AVMUtil.getStoreName(diff.getSourcePath()));
}
if (AVMWorkflowUtil.getAssociatedTasksForNode(node, tasks).size() == 0)
{
String revertPath = diff.getSourcePath();
versionPaths.add(new Pair<Integer, String>(-1, revertPath) );
if ( (this.virtUpdatePath == null) &&
VirtServerUtils.requiresUpdateNotification(revertPath) )
{
this.virtUpdatePath = revertPath;
}
}
}
Map<String, Serializable> args = new HashMap<String, Serializable>(1, 1.0f);
args.put(AVMUndoSandboxListAction.PARAM_NODE_LIST, (Serializable)versionPaths);
Action action = this.getActionService().createAction(AVMUndoSandboxListAction.NAME, args);
this.getActionService().executeAction(action, null); // dummy action ref, list passed as action arg
getSandboxService().revertAllWebApp(userSandboxId, webApp);
String msg = MessageFormat.format(Application.getMessage(
context, MSG_REVERTALL_SUCCESS), this.avmBrowseBean.getUsername());
@@ -209,22 +89,6 @@ public class RevertAllDialog extends BaseDialogBean
return outcome;
}
/**
* Handle notification to the virtualization server
* (this needs to occur after the sandbox is updated).
*/
@Override
protected String doPostCommitProcessing(FacesContext context, String outcome)
{
// Force the update because we've already determined
// that update_path requires virt server notification.
if (this.virtUpdatePath != null)
{
AVMUtil.updateVServerWebapp(this.virtUpdatePath, true);
}
return outcome;
}
/**
* @return the confirmation to display to the user
*/

View File

@@ -24,28 +24,15 @@
*/
package org.alfresco.web.bean.wcm;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.avm.actions.AVMUndoSandboxListAction;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.workflow.WorkflowTask;
import org.alfresco.util.Pair;
import org.alfresco.wcm.sandbox.SandboxService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.util.VirtServerUtils;
/**
* Revert (undo) the selected files in the current user sandbox.
@@ -59,15 +46,7 @@ public class RevertSelectedDialog extends BaseDialogBean
private static final String MSG_REVERTSELECTED_SUCCESS = "revertselected_success";
protected AVMBrowseBean avmBrowseBean;
transient private ActionService actionService;
// The virtualization server might need to be notified
// because one or more of the files reverted could alter
// the behavior the virtual webapp in the target of the submit.
private String virtUpdatePath;
transient private SandboxService sbService;
/**
* @param avmBrowseBean The AVM BrowseBean to set
@@ -77,21 +56,18 @@ public class RevertSelectedDialog extends BaseDialogBean
this.avmBrowseBean = avmBrowseBean;
}
/**
* @param actionService The actionService to set.
*/
public void setActionService(ActionService actionService)
public void setSandboxService(SandboxService sbService)
{
this.actionService = actionService;
this.sbService = sbService;
}
protected ActionService getActionService()
protected SandboxService getSandboxService()
{
if (this.actionService == null)
if (this.sbService == null)
{
this.actionService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getActionService();
this.sbService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getSandboxService();
}
return actionService;
return this.sbService;
}
/**
@@ -100,33 +76,10 @@ public class RevertSelectedDialog extends BaseDialogBean
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
List<AVMNodeDescriptor> selected = this.avmBrowseBean.getSelectedSandboxItems();
List<Pair<Integer, String>> versionPaths = new ArrayList<Pair<Integer, String>>();
String webApp = this.avmBrowseBean.getWebapp();
String userSandboxId = this.avmBrowseBean.getSandbox();
List<WorkflowTask> tasks = null;
for (AVMNodeDescriptor node : selected)
{
if (tasks == null)
{
tasks = AVMWorkflowUtil.getAssociatedTasksForSandbox(AVMUtil.getStoreName(node.getPath()));
}
if (AVMWorkflowUtil.getAssociatedTasksForNode(node, tasks).size() == 0)
{
String revertPath = node.getPath();
versionPaths.add(new Pair<Integer, String>(-1, revertPath));
if ( (this.virtUpdatePath == null) &&
VirtServerUtils.requiresUpdateNotification(revertPath) )
{
this.virtUpdatePath = revertPath;
}
}
}
Map<String, Serializable> args = new HashMap<String, Serializable>(1, 1.0f);
args.put(AVMUndoSandboxListAction.PARAM_NODE_LIST, (Serializable)versionPaths);
Action action = this.getActionService().createAction(AVMUndoSandboxListAction.NAME, args);
this.getActionService().executeAction(action, null); // dummy action ref, list passed as action arg
getSandboxService().revertAllWebApp(userSandboxId, webApp);
String msg = MessageFormat.format(Application.getMessage(
context, MSG_REVERTSELECTED_SUCCESS), this.avmBrowseBean.getUsername());
@@ -136,24 +89,6 @@ public class RevertSelectedDialog extends BaseDialogBean
return outcome;
}
/**
* Handle notification to the virtualization server
* (this needs to occur after the sandbox is updated).
*/
@Override
protected String doPostCommitProcessing(FacesContext context, String outcome)
{
// Force the update because we've already determined
// that update_path requires virt server notification.
if (this.virtUpdatePath != null)
{
AVMUtil.updateVServerWebapp(this.virtUpdatePath, true);
}
return outcome;
}
/**
* @return the confirmation to display to the user
*/

View File

@@ -43,10 +43,8 @@ import org.alfresco.config.JNDIConstants;
import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel;
import org.alfresco.model.WCMWorkflowModel;
import org.alfresco.repo.avm.AVMDAOs;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.web.scripts.FileTypeImageUtils;
@@ -68,9 +66,9 @@ import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.util.ISO8601DateFormat;
import org.alfresco.util.NameMatcher;
import org.alfresco.util.VirtServerUtils;
import org.alfresco.wcm.sandbox.SandboxFactory;
import org.alfresco.wcm.sandbox.SandboxInfo;
import org.alfresco.wcm.sandbox.SandboxService;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.DownloadContentServlet;
import org.alfresco.web.app.servlet.FacesHelper;
@@ -138,6 +136,7 @@ public class SubmitDialog extends BaseDialogBean
transient private AVMLockingService avmLockingService;
transient private FormsService formsService;
transient private SandboxFactory sandboxFactory;
transient private SandboxService sandboxService;
transient private NameMatcher nameMatcher;
@@ -261,6 +260,20 @@ public class SubmitDialog extends BaseDialogBean
return formsService;
}
public void setSandboxService(final SandboxService sandboxService)
{
this.sandboxService = sandboxService;
}
protected SandboxService getSandboxService()
{
if (sandboxService == null)
{
sandboxService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getSandboxService();
}
return sandboxService;
}
// TODO - refactor ... push down into sandbox service (submit to workflow)
public void setSandboxFactory(final SandboxFactory sandboxFactory)
{
@@ -351,12 +364,6 @@ public class SubmitDialog extends BaseDialogBean
{
// if there's no workflow submit changes directly to staging
outcome = submitDirectToStaging(context);
// force an update of the virt server if necessary
if (this.virtUpdatePath != null)
{
AVMUtil.updateVServerWebapp(this.virtUpdatePath, true);
}
}
}
finally
@@ -490,53 +497,19 @@ public class SubmitDialog extends BaseDialogBean
// direct submit to the staging area without workflow
List<ItemWrapper> items = getSubmitItems();
// construct diffs for selected items for submission
final String sandboxPath = AVMUtil.buildSandboxRootPath(this.avmBrowseBean.getSandbox());
final String stagingPath = AVMUtil.buildSandboxRootPath(this.avmBrowseBean.getStagingStore());
final List<AVMDifference> diffs = new ArrayList<AVMDifference>(items.size());
final String submitLabel = this.label;
final String submitComment = this.comment;
List<AVMNodeDescriptor> nodes = new ArrayList<AVMNodeDescriptor>(items.size());
String storeId = this.avmBrowseBean.getWebProject().getStoreId();
for (ItemWrapper wrapper : items)
{
String srcPath = sandboxPath + wrapper.getPath();
String destPath = stagingPath + wrapper.getPath();
AVMDifference diff = new AVMDifference(-1, srcPath, -1, destPath, AVMDifference.NEWER);
diffs.add(diff);
// process the expiration date (if any)
processExpirationDate(srcPath);
// recursively remove locks from this item
recursivelyRemoveLocks(storeId, -1, getAvmService().lookup(-1, srcPath, true), srcPath);
// If nothing has required notifying the virtualization server
// so far, check to see if destPath forces a notification
// (e.g.: it might be a path to a jar file within WEB-INF/lib).
if ( (this.virtUpdatePath == null) &&
VirtServerUtils.requiresUpdateNotification( destPath ) )
{
this.virtUpdatePath = destPath;
nodes.add(wrapper.getDescriptor());
}
}
// write changes to layer so files are marked as modified
String sbStoreId = this.avmBrowseBean.getSandbox();
// Submit is done as system as the staging store is read only
// We could add support to runIgnoringStoreACls
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
{
public Object doWork() throws Exception
{
getAvmSyncService().update(diffs, null, true, true, false, false, submitLabel, submitComment);
AVMDAOs.Instance().fAVMNodeDAO.flush();
getAvmSyncService().flatten(sandboxPath, stagingPath);
return null;
}
}, AuthenticationUtil.getSystemUserName());
String submitLabel = this.label;
String submitComment = this.comment;
getSandboxService().submitList(sbStoreId, nodes, this.expirationDates, submitLabel, submitComment);
// if we get this far return the default outcome
return this.getDefaultFinishOutcome();
@@ -735,39 +708,6 @@ public class SubmitDialog extends BaseDialogBean
}
}
/**
* Recursively remove locks from a path. Walking child folders looking for files
* to remove locks from.
*/
private void recursivelyRemoveLocks(String webProject, int version, AVMNodeDescriptor desc, String path)
{
if (desc.isFile() || desc.isDeletedFile())
{
this.getAvmLockingService().removeLock(webProject, path.substring(path.indexOf(":") + 1));
}
else
{
if (desc.isDeletedDirectory())
{
// lookup the previous child and get its contents
final List<AVMNodeDescriptor> history = getAvmService().getHistory(desc, 2);
if (history.size() <= 1)
{
return;
}
desc = history.get(1);
}
Map<String, AVMNodeDescriptor> list = getAvmService().getDirectoryListingDirect(desc, true);
for (Map.Entry<String, AVMNodeDescriptor> child : list.entrySet())
{
String name = child.getKey();
AVMNodeDescriptor childDesc = child.getValue();
recursivelyRemoveLocks(webProject, version, childDesc, path + "/" + name);
}
}
}
/**
* @see org.alfresco.web.bean.dialog.BaseDialogBean#getFinishButtonDisabled()
*/

View File

@@ -539,16 +539,13 @@ public class UIDeploymentServers extends UIInput
out.write("'><nobr>");
out.write(bundle.getString("yes"));
out.write("&nbsp;(");
if (allocatedToTip.indexOf(
AVMUtil.STORE_SEPARATOR + AVMUtil.STORE_WORKFLOW + "-") != -1)
if (AVMUtil.isWorkflowStore(allocatedToTip))
{
out.write(bundle.getString("review_sandbox"));
}
else
{
String username = allocatedToTip.substring(
allocatedToTip.indexOf(AVMUtil.STORE_SEPARATOR) +
AVMUtil.STORE_SEPARATOR.length());
String username = AVMUtil.getUserName(allocatedToTip);
out.write(username);
}
out.write(")</nobr></span>");

View File

@@ -42,13 +42,14 @@ import javax.transaction.UserTransaction;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.sandbox.SandboxConstants;
import org.alfresco.wcm.sandbox.SandboxConstants;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.VersionDescriptor;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.wcm.sandbox.SandboxService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wcm.AVMCompareUtils;
@@ -164,6 +165,7 @@ public class UISandboxSnapshots extends SelfRenderingComponent
ResourceBundle bundle = Application.getBundle(context);
DateFormat df = Utils.getDateTimeFormat(context);
AVMService avmService = getAVMService(context);
SandboxService sbService = getSandboxService(context);
UserTransaction tx = null;
try
{
@@ -200,7 +202,7 @@ public class UISandboxSnapshots extends SelfRenderingComponent
String dateFilter = getDateFilter();
if (dateFilter == null || dateFilter.equals(FILTER_DATE_ALL))
{
versions = avmService.getStoreVersions(sandbox);
versions = sbService.listSnapshots(sandbox, false);
}
else
{
@@ -227,7 +229,7 @@ public class UISandboxSnapshots extends SelfRenderingComponent
{
throw new IllegalArgumentException("Unknown date filter mode: " + dateFilter);
}
versions = avmService.getStoreVersions(sandbox, fromDate, toDate);
versions = sbService.listSnapshots(sandbox, fromDate, toDate, false);
}
// determine whether the deploy action should be shown
@@ -622,7 +624,12 @@ public class UISandboxSnapshots extends SelfRenderingComponent
private AVMService getAVMService(FacesContext fc)
{
return (AVMService) FacesContextUtils.getRequiredWebApplicationContext(fc).getBean("AVMLockingAwareService");
return (AVMService)FacesContextUtils.getRequiredWebApplicationContext(fc).getBean("AVMLockingAwareService");
}
private SandboxService getSandboxService(FacesContext fc)
{
return (SandboxService)FacesContextUtils.getRequiredWebApplicationContext(fc).getBean("SandboxService");
}
// ------------------------------------------------------------------------------

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2008 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -49,15 +49,15 @@ import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.util.NameMatcher;
import org.alfresco.wcm.sandbox.SandboxConstants;
import org.alfresco.wcm.sandbox.SandboxInfo;
import org.alfresco.wcm.sandbox.SandboxService;
import org.alfresco.wcm.util.WCMUtil;
import org.alfresco.wcm.webproject.WebProjectInfo;
import org.alfresco.wcm.webproject.WebProjectService;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.DownloadContentServlet;
@@ -70,7 +70,6 @@ import org.alfresco.web.bean.wcm.AVMNode;
import org.alfresco.web.bean.wcm.AVMUtil;
import org.alfresco.web.bean.wcm.DeploymentUtil;
import org.alfresco.web.bean.wcm.WebProject;
import org.alfresco.web.config.ClientConfigElement;
import org.alfresco.web.data.IDataContainer;
import org.alfresco.web.data.QuickSort;
import org.alfresco.web.forms.Form;
@@ -86,7 +85,6 @@ import org.alfresco.web.ui.repo.component.UIActions;
import org.alfresco.web.ui.wcm.WebResources;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.jsf.FacesContextUtils;
/**
* Component responsible for rendering the list of user sandboxes for a web project.
@@ -300,7 +298,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
this.forms = null;
ResourceBundle bundle = Application.getBundle(context);
AVMService avmService = getAVMService(context);
SandboxService sbService = getSandboxService(context);
WebProjectService wpService = getWebProjectService(context);
NodeService nodeService = getNodeService(context);
PermissionService permissionService = getPermissionService(context);
@@ -328,11 +326,24 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
List<UserRoleWrapper> userRoleWrappers;
if (showAllSandboxes)
{
// TODO refactor with new SandboxService
Map<String, String> userRoles = null;
if (currentUserRole.equals(WCMUtil.ROLE_CONTENT_MANAGER))
{
userRoles = wpService.listWebUsers(websiteRef);
Map<String, String> allUserRoles = wpService.listWebUsers(websiteRef);
WebProjectInfo wpInfo = wpService.getWebProject(websiteRef);
List<SandboxInfo> sbInfos = sbService.listSandboxes(wpInfo.getStoreId());
userRoles = new HashMap<String, String>(sbInfos.size());
// Note: currently displays author sandboxes only
for (SandboxInfo sbInfo : sbInfos)
{
if (sbInfo.getSandboxType().equals(SandboxConstants.PROP_SANDBOX_AUTHOR_MAIN))
{
userRoles.put(sbInfo.getName(), allUserRoles.get(sbInfo.getName()));
}
}
}
else
{
@@ -376,11 +387,11 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
this.userToRowLookup.put(index, username);
this.rowToUserLookup.put(username, index);
// build the name of the main store for this user
// build the name of the main store for this user (user sandbox id)
String mainStore = AVMUtil.buildUserMainStoreName(storeRoot, username);
// check it exists before we render the view
if (avmService.getStore(mainStore) != null)
if (sbService.getSandbox(mainStore) != null)
{
// check the permissions on this store for the current user
if (logger.isDebugEnabled())
@@ -701,29 +712,20 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
FacesContext fc, ResponseWriter out, String username, String storeRoot, int index)
throws IOException
{
AVMSyncService avmSyncService = getAVMSyncService(fc);
AVMService avmService = getAVMService(fc);
PermissionService permissionService = getPermissionService(fc);
SandboxService sandboxService = getSandboxService(fc);
DateFormat df = Utils.getDateTimeFormat(fc);
ResourceBundle bundle = Application.getBundle(fc);
// build the paths to the stores to compare - filter by current webapp
// compare user sandbox to staging sandbox - filter by current webapp, include deleted items
String userStore = AVMUtil.buildUserMainStoreName(storeRoot, username);
String userStorePath = AVMUtil.buildStoreWebappPath(userStore, getWebapp());
String stagingStore = AVMUtil.buildStagingStoreName(storeRoot);
String stagingStorePath = AVMUtil.buildStoreWebappPath(stagingStore, getWebapp());
List<AVMNodeDescriptor> nodes = sandboxService.listChangedItemsWebApp(userStore, getWebapp(), true);
// use the sync service to get the list of diffs between the stores
NameMatcher matcher = (NameMatcher)FacesContextUtils.getRequiredWebApplicationContext(fc).getBean(
"globalPathExcluder");
List<AVMDifference> diffs = avmSyncService.compare(-1, userStorePath, -1, stagingStorePath, matcher);
if (diffs.size() != 0)
if (nodes.size() != 0)
{
// info we need to calculate preview paths for assets
String dns = AVMUtil.lookupStoreDNS(userStore);
int rootPathIndex = AVMUtil.buildSandboxRootPath(userStore).length();
ClientConfigElement config = Application.getClientConfig(fc);
// get the UIActions component responsible for rendering context related user actions
// TODO: we may need a component per user instance? (or use evaluators for roles...)
@@ -734,7 +736,6 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
String id = getClientId(fc);
// store lookup of username to list of modified nodes
List<AVMNodeDescriptor> nodes = new ArrayList<AVMNodeDescriptor>(diffs.size());
this.userNodes.put(username, nodes);
// output the table of modified items
@@ -780,27 +781,11 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
// output each of the modified files as a row in the table
int rowIndex = 0;
for (AVMDifference diff : diffs)
for (AVMNodeDescriptor node : nodes)
{
// TODO: different display cases for diff.getDifferenceCode()?
boolean isGhost = false;
String sourcePath = diff.getSourcePath();
AVMNodeDescriptor node = avmService.lookup(-1, sourcePath);
if (node == null)
{
// may have been deleted from this sandbox - which is a ghost node
node = avmService.lookup(-1, diff.getSourcePath(), true);
isGhost = true;
}
// handle missing node case by skipping the row rendering
if (node == null)
{
continue;
}
// save reference to this node for multi-select action lookup later
nodes.add(node);
boolean isGhost = node.isDeleted();
String sourcePath = node.getPath();
// output multi-select checkbox
out.write("<tr><td><input type='checkbox' name='");
@@ -1328,12 +1313,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
private WebProjectService getWebProjectService(FacesContext fc)
{
return (WebProjectService)FacesContextUtils.getRequiredWebApplicationContext(fc).getBean("WebProjectService");
}
private AVMService getAVMService(FacesContext fc)
{
return (AVMService)FacesContextUtils.getRequiredWebApplicationContext(fc).getBean("AVMLockingAwareService");
return Repository.getServiceRegistry(fc).getWebProjectService();
}
private NodeService getNodeService(FacesContext fc)
@@ -1341,16 +1321,16 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
return Repository.getServiceRegistry(fc).getNodeService();
}
private AVMSyncService getAVMSyncService(FacesContext fc)
{
return (AVMSyncService)FacesContextUtils.getRequiredWebApplicationContext(fc).getBean("AVMSyncService");
}
private PermissionService getPermissionService(FacesContext fc)
{
return Repository.getServiceRegistry(fc).getPermissionService();
}
private SandboxService getSandboxService(FacesContext fc)
{
return Repository.getServiceRegistry(fc).getSandboxService();
}
// ------------------------------------------------------------------------------
// Strongly typed component property accessors

View File

@@ -3462,10 +3462,6 @@
<property-name>avmService</property-name>
<value>#{AVMLockingAwareService}</value>
</managed-property>
<managed-property>
<property-name>avmSyncService</property-name>
<value>#{AVMSyncService}</value>
</managed-property>
<managed-property>
<property-name>navigationBean</property-name>
<value>#{NavigationBean}</value>
@@ -4152,10 +4148,6 @@
<property-name>avmBrowseBean</property-name>
<value>#{AVMBrowseBean}</value>
</managed-property>
<managed-property>
<property-name>actionService</property-name>
<value>#{ActionService}</value>
</managed-property>
</managed-bean>
<managed-bean>
@@ -4165,26 +4157,10 @@
<managed-bean-name>RevertAllDialog</managed-bean-name>
<managed-bean-class>org.alfresco.web.bean.wcm.RevertAllDialog</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>avmService</property-name>
<value>#{AVMLockingAwareService}</value>
</managed-property>
<managed-property>
<property-name>avmBrowseBean</property-name>
<value>#{AVMBrowseBean}</value>
</managed-property>
<managed-property>
<property-name>actionService</property-name>
<value>#{ActionService}</value>
</managed-property>
<managed-property>
<property-name>avmSyncService</property-name>
<value>#{AVMSyncService}</value>
</managed-property>
<managed-property>
<property-name>nameMatcher</property-name>
<value>#{globalPathExcluder}</value>
</managed-property>
</managed-bean>
<managed-bean>