Skip to content

Instantly share code, notes, and snippets.

@edgars
Created April 6, 2018 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edgars/ab48fe7a34e1f75bdbe563b19c17b846 to your computer and use it in GitHub Desktop.
Save edgars/ab48fe7a34e1f75bdbe563b19c17b846 to your computer and use it in GitHub Desktop.
package org.wso2.governance.sample.executor;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.governance.registry.extensions.interfaces.Execution;
import org.wso2.carbon.registry.core.exceptions.RegistryException;
import org.wso2.carbon.registry.core.jdbc.handlers.RequestContext;
public class CustomExecutor implements Execution {
private static final Log log = LogFactory.getLog(CustomExecutor.class);
private String[] attributes = new String[0];
public void init(Map parameterMap) {
System.out.println("Custom Executor :::: INIT");
if (parameterMap != null) {
String temp = (String) parameterMap.get("attributes");
if (temp != null) {
attributes = temp.split(",");
}
for (int i = 0; i < attributes.length; i++) {
log.info("atributo: " + attributes[i]);
}
}
}
public boolean execute(RequestContext context, String currentState, String targetState) {
if(attributes.length == 0){
return false;
}
log.info("ID: " + context.getRegistryContext().getNodeIdentifier());
String resourcePath = context.getResourcePath().getPath();
log.info(resourcePath);
log.info(resourcePath + "Ciclo de vida de : "+currentState + " para :" + targetState);
log.info("Vars: " + context.getResource().getProperties());
log.info("Desc: " + context.getResource().getDescription());
log.info("Comentário: " + context.getComment());
for (int i = 0; i < attributes.length; i++) {
log.info("valor do atributo: " + attributes[i] + " : "+ context.getProperty(attributes[i]));
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment