11-06-2008 03:50 PM
package org.hhmi.alfresco.webscript.wcm;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.NameMatcher;
import org.alfresco.web.bean.wcm.AVMUtil;
import org.alfresco.web.scripts.Cache;
import org.alfresco.web.scripts.DeclarativeWebScript;
import org.alfresco.web.scripts.Status;
import org.alfresco.web.scripts.WebScriptRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hhmi.alfresco.javascript.Impersonation;
import org.hhmi.alfresco.utils.WcmUtils;
/**
* Content Retrieval Service
*
* Stream content from the Repository.
*
* @author rdifrango
*/
public class WcmUndoWorkflow extends DeclarativeWebScript {
// Logger
private static final Log logger = LogFactory
.getLog("org.alfresco.repo.web.scripts");
transient private ServiceRegistry services;
public void setServices(ServiceRegistry services) {
this.services = services;
}
transient private NameMatcher nameMatcher;
public void setNameMatcher(NameMatcher nameMatcher) {
this.nameMatcher = nameMatcher;
}
transient private WcmUtils wcmUtils;
public void setWcmUtils(WcmUtils wcmUtils) {
this.wcmUtils = wcmUtils;
}
/**
* @see org.alfresco.web.scripts.WebScript#execute(org.alfresco.web.scripts.WebScriptRequest,
* org.alfresco.web.scripts.WebScriptResponse)
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req,
Status status, Cache cache) {
Impersonation impersonation = new Impersonation();
String impersonateUser = req.getParameter("impersonate");
logger.info("RRD: impersonate = " + impersonateUser);
if (impersonateUser != null) {
impersonation.impersonate(impersonateUser);
}
String webapp = wcmUtils.getWebapp(impersonateUser);
logger.info("RRD: webapp = " + webapp);
String userStore = AVMUtil.buildStoreWebappPath(wcmUtils
.getSandbox(impersonateUser), webapp);
logger.info("RRD: userStore = " + userStore);
String stagingStore = AVMUtil.buildStoreWebappPath(wcmUtils
.getStagingStore(null), webapp);
logger.info("RRD: stagingStore = " + stagingStore);
//
final List<String> srcPaths = new ArrayList<String>();
if (req.getParameterValues("noderef") != null) {
for (String path : req.getParameterValues("noderef")) {
if (path.trim().length() > 1) {
srcPaths.add(path);
}
}
}
if (srcPaths.size() == 0) {
List<AVMDifference> diffs = services.getAVMSyncService().compare(
-1, userStore, -1, stagingStore, nameMatcher);
logger.info("RRD: diffs = " + diffs);
for (AVMDifference diff : diffs) {
unlockNode(diff.getSourcePath());
}
}
else
{
for (String srcPath : srcPaths) {
if (srcPath.startsWith("avm://"))
{
srcPath = srcPath.replace("avm://", "").replace("/-1;", ":/").replace(";", "/");
}
unlockNode(srcPath);
}
}
Map<String, Object> model = new HashMap<String, Object>();
model.put("result", "success");
return model;
}
private void unlockNode(String srcPath) {
AVMNodeDescriptor desc = services.getAVMService().lookup(-1, srcPath,
true);
if (desc != null) {
String[] parentChild = AVMNodeConverter.SplitBase(srcPath);
if (parentChild.length == 2) {
AVMNodeDescriptor parent = services.getAVMService().lookup(-1,
parentChild[0], true);
if (parent.isLayeredDirectory()) {
if (logger.isDebugEnabled())
logger.debug("reverting " + parentChild[1] + " in "
+ parentChild[0]);
services.getAVMService().makeTransparent(parentChild[0],
parentChild[1]);
}
final Map<QName, PropertyValue> dnsProperties = services
.getAVMService().queryStorePropertyKey(
srcPath.split(":")[0],
QName.createQName(null, ".dns%"));
if (dnsProperties.size() == 1) {
String webProject = dnsProperties.keySet().iterator()
.next().getLocalName();
webProject = webProject.substring(webProject
.lastIndexOf('.') + 1, webProject.length());
String path = srcPath.substring(srcPath.indexOf(":") + 1);
if (logger.isDebugEnabled())
logger.debug("unlocking file " + path
+ " in web project " + webProject);
if (services.getAVMLockingService().getLock(webProject,
path) != null) {
services.getAVMLockingService().removeLock(webProject,
path);
} else {
logger.warn("expected file " + path + " in "
+ webProject + " to be locked");
}
}
}
}
}
}
500 Internal Error An error inside the HTTP server which prevented it from fulfilling the request. Wrapped Exception (with status template): Not allowed to write in: portal–user:/www/avm_webapps/ROOT org.alfresco.web.scripts.WebScriptException - Wrapped Exception (with status template): Not allowed to write in: portal–user:/www/avm_webapps/ROOT org.alfresco.repo.security.permissions.AccessDeniedException: Not allowed to write in: portal–user:/www/avm_webapps/ROOT org.alfresco.repo.avm.AVMRepository.flatten(AVMRepository.java:2877) org.alfresco.repo.avm.AVMServiceImpl.makeTransparent(AVMServiceImpl.java:568) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:585) org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296) org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144) org.alfresco.repo.transaction.SingleEntryTransactionResourceInterceptor.invokeInternal(SingleEntryTransactionResourceInterceptor.java:163) org.alfresco.repo.transaction.SingleEntryTransactionResourceInterceptor.invoke(SingleEntryTransactionResourceInterceptor.java:138) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) $Proxy3.makeTransparent(Unknown Source) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:585) org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296) org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144) org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor.invoke(AVMSnapShotTriggeredIndexingMethodInterceptor.java:153) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166) org.alfresco.repo.transaction.CheckTransactionAdvice.invoke(CheckTransactionAdvice.java:52) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166) org.alfresco.repo.transaction.RetryingTransactionAdvice$1.execute(RetryingTransactionAdvice.java:70) org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:320) org.alfresco.repo.transaction.RetryingTransactionAdvice.invoke(RetryingTransactionAdvice.java:73) org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) $Proxy3.makeTransparent(Unknown Source) org.hhmi.alfresco.webscript.wcm.WcmUndoWorkflow.unlockNode(WcmUndoWorkflow.java:129) org.hhmi.alfresco.webscript.wcm.WcmUndoWorkflow.executeImpl(WcmUndoWorkflow.java:98) org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:70) org.alfresco.repo.web.scripts.RepositoryContainer$1.execute(RepositoryContainer.java:311) org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:320) org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:227) org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:360) org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:382) org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:264) org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:260) org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:139) org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:116) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.alfresco.web.app.servlet.MTWebScriptAuthenticationFilter.doFilter(MTWebScriptAuthenticationFilter.java:102) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) java.lang.Thread.run(Thread.java:613) org.alfresco.web.scripts.WebScriptException: Wrapped Exception (with status template): Not allowed to write in: portal–user:/www/avm_webapps/ROOT org.alfresco.web.scripts.AbstractWebScript.createStatusException(AbstractWebScript.java:594) Alfresco Enterprise v3.0.0 (r11498) schema 501 Nov 6, 2008 3:49:23 PM
11-07-2008 02:40 PM
04-10-2009 06:43 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.