As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
import org.alfresco.web.evaluator.BaseEvaluator; import org.json.simple.JSONObject; import org.springframework.extensions.surf.ServletUtil; import org.springframework.extensions.surf.exception.ConnectorServiceException; import org.springframework.extensions.surf.support.ThreadLocalRequestContext; import org.springframework.extensions.webscripts.connector.Connector; public class CustomEvaluator extends BaseEvaluator { @Override public boolean evaluate(JSONObject node) { try { Connector conn = ThreadLocalRequestContext.getRequestContext().getServiceRegistry().getConnectorService().getConnector("alfresco"); return conn.call("/some/webscript/run?nodeRef=" + (String) node.get("nodeRef")).getResponse().equals("YES"); } catch (ConnectorServiceException ex) { return false; } } }
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'> <beans> <!– No problems with this one –> <bean id="evaluator.doclib.action.isPdf" parent="evaluator.doclib.action.isMimetype"> <property name="mimetypes"> <list> <value>application/pdf</value> </list> </property> </bean> <!– This is the problematic one –> <bean id="evaluator.doclib.action.isItReady" class="some.internal.package.CustomEvaluator" /> </beans>
<alfresco-config> … <config evaluator="string-compare" condition="DocumentLibrary" replace="true"> … <indicators> <indicator id="indicator.doclib.action.isItReady" icon="myicon-16.png" index="100" label="Yea!"> <evaluator>evaluator.doclib.action.isItReady</evaluator> </indicator> </indicators> </config> </alfresco-config>
<webscript> <shortname>Some name</shortname> <description>Some description</description> <url>/some/folder/isItReady</url> <authentication>user</authentication> <format default="json">argument</format> <family>Custom</family> </webscript>
GET /alfresco/s/some/folder/isItReady?nodeRef=workspace://SpacesStore/2d4e61ab-8508-4f7f-834c-1f49170d096c HTTP/1.1 User-Agent: Jakarta Commons-HttpClient/3.1 Host: localhost:8080
HTTP/1.1 401 Unauthorized Server: Apache-Coyote/1.1 WWW-Authenticate: Basic realm="Alfresco" Content-Type: text/html;charset=utf-8 Content-Length: 951 Date: Thu, 14 Nov 2013 22:23:54 GMT (Some HTML…) This request requires HTTP authentication. (Some more HTML…)