02-07-2014 03:26 PM
public class NodeReleaseLockWebscript extends DeclarativeWebScript {
private NodeService nodeService;
private LockService lockService;
@Override
protected Map<String, Object> executeImpl(WebScriptRequest request,
Status status) {
Map<String, Object> model = new HashMap<String, Object>();
NodeRef nodeRef = getNodeRef(request);
String name = (String) nodeService.getProperty(nodeRef,ContentModel.PROP_NAME);
lockService.unlock(nodeRef);
lockService.getLockStatus(nodeRef);
LockStatus lockStatus = lockService.getLockStatus(nodeRef);
model.put("nbTotalDocument", 1);
model.put("nameDocument", name);
model.put("status", lockStatus.name());
return model;
}
private NodeRef getNodeRef(WebScriptRequest request) {
String node = request.getParameter("noderef");
NodeRef nodeRef = new NodeRef(node);
if (!nodeService.exists(nodeRef)) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST,
"nodeRef provided does not exist");
}
return nodeRef;
}
public NodeService getNodeService() {
return nodeService;
}
public void setNodeService(NodeService nodeService) {
this.nodeService = nodeService;
}
public LockService getLockService() {
return lockService;
}
public void setLockService(LockService lockService) {
this.lockService = lockService;
}
}
<webscript>
<shortname>node lock</shortname>
<description>node lock</description>
<url>/nodereleaselock/initiate</url>
<authentication>user</authentication>
<transaction>none</transaction>
<family>Node release lock</family>
<cache>
<never>true</never>
</cache>
</webscript>
<!DOCTYPE html>
<html>
<head>
</head>
<body class="yui-skin-sam">
file unlock </br></br>
nombreTotalDocument : ${nbTotalDocument} </br>
nomDocument : ${nameDocument} </br>
</body>
</html>
<webscript>
<shortname>Node release lock</shortname>
<description>Web Script that provides a simple UI for node release lock.</description>
<url>/nodereleaselock</url>
<format default="html"/>
<authentication>user</authentication>
<family>Node release lock</family>
<cache>
<never>true</never>
</cache>
</webscript>
[#ftl]
<!DOCTYPE HTML>
<html>
<head>
<title>Node release lock</title>
<link rel="stylesheet" href="${url.context}/css/main.css" TYPE="text/css">
<!– YUI 3.x –>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?3.3.0/build/widget/assets/skins/sam/widget.css&3.3.0/build/widget/ass...">
<script type="text/javascript" src="http://yui.yahooapis.com/combo?3.3.0/build/yui/yui-min.js&3.3.0/build/intl/intl-min.js&3.3.0/build/a..."></script>
<style type="text/css">
.yui3-aclist-content {
background-color : white;
border : 1px solid darkgrey;
box-shadow : 3px 3px 4px lightgrey;
-webkit-box-shadow : 3px 3px 4px lightgrey; /* Safari and Chrome */
}
</style>
<!– Validation functions –>
<script type="text/javascript">
function validateRequired(field, errorMessageElement, errorMessage)
{
var result = true;
if (field.value == null || field.value == "")
{
errorMessageElement.textContent = errorMessage;
result = false;
}
else
{
errorMessageElement.textContent = "";
}
return result;
}
function validateForm(form)
{
var result = true;
result = validateRequired(form.sourceDirectory, document.getElementById("noderefMessage"), "NodeRef is mandatory.");
return result;
}
</script>
</head>
<body class="yui-skin-sam">
<p>
<img align="left" src="${url.context}/images/logo/AlfrescoLogo32.png" alt="Alfresco" />
<strong>Node release lock</strong><br/>
Alfresco ${server.edition} v${server.version}
</p>
<form action="${url.service}/initiate" method="post" enctype="multipart/form-data" charset="utf-8" onsubmit="return validateForm(this);">
<table>
<tr>
<td>NodeRef:</td><td><input type="text" size="128" name="noderef" /></td><td id="noderefMessage" style="color:red"></td>
</tr>
<tr>
<td colspan="3"><input type="submit" name="submit" value="Initiate release lock"></td>
</tr>
</table>
<br/>
</form>
</body>
</html>
Exception: net.sf.acegisecurity.AccessDeniedException - Access is denied.
net.sf.acegisecurity.vote.AffirmativeBased.decide(AffirmativeBased.java:86)
net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:398)
net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:77)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:46)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:159)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
$Proxy49.unlock(Unknown Source)
com.lacapitale.caap.alfresco.model.webscripts.NodeReleaseLockWebscript.executeImpl(NodeReleaseLockWebscript.java:46)
org.springframework.extensions.webscripts.DeclarativeWebScript.executeImpl(DeclarativeWebScript.java:235)
org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:64)
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:365)
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:517)
org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:333)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:377)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)
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.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)
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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
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:293)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
java.lang.Thread.run(Unknown Source)
02-10-2014 08:22 PM
RunAsWork<Object> work = new RunAsWork<Object>()
{
public Object doWork() throws Exception
{
lockService.unlock(nodeRef);
lockService.getLockStatus(nodeRef);
LockStatus lockStatus = lockService.getLockStatus(nodeRef);
return lockStatus;
}
};
AuthenticationUtil.runAs(work, AuthenticationUtil.getSystemUserName());
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.