<import resource="classpath:org/argeo/slc/server/client/spring.xml" />
+ <bean id="serverHttpClient" parent="slcTemplate.serverHttpClient">
+ </bean>
+
</beans>
\ No newline at end of file
.0.16,7.0.0)"\r
Bundle-Version: 0.11.4.SNAPSHOT\r
Bundle-SymbolicName: org.argeo.slc.server.catalina\r
-Import-Package: org.springframework.security.providers,\r
- org.springframework.security,\r
- org.springframework.security.ui\r
+Import-Package: org.springframework.security,\r
+ org.springframework.security.providers,\r
+ org.springframework.security.ui,\r
+ org.springframework.security.userdetails,\r
+ org.springframework.security.ui.savedrequest\r
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">
<http realm="User Interface" >
- <intercept-url pattern="/**" access="ROLE_USER,ROLE_ANONYMOUS,ROLE_ADMIN" />
+ <intercept-url pattern="/**" access="ROLE_USER,ROLE_ADMIN" />
<http-basic />
<anonymous />
</http>
<constructor-arg ref="slcExecutionDao" />
</bean>
+ <bean name="/getSlcExecution.service" class="org.argeo.slc.web.mvc.process.GetSlcExecution">
+ <property name="slcExecutionDao" ref="slcExecutionDao" />
+ <property name="unmarshaller" ref="unmarshaller" />
+ </bean>
+
<bean name="/newSlcExecution.service"
class="org.argeo.slc.web.mvc.process.NewSlcExecutionController">
<property name="agentFactory" ref="agentFactory" />
<property name="unmarshaller" ref="unmarshaller" />
+ <property name="marshaller" ref="marshaller" />
<property name="slcExecutionService" ref="slcExecutionService" />
</bean>
ExecutionFlowDescriptor executionFlowDescriptor) {
Map<String, Object> values = executionFlowDescriptor.getValues();
Map<String, Object> convertedValues = new HashMap<String, Object>();
+ ExecutionSpec executionSpec = executionFlowDescriptor
+ .getExecutionSpec();
- if (values != null) {
+ if (executionSpec == null)
+ log.warn("Execution spec is null for " + executionFlowDescriptor);
+
+ if (values != null && executionSpec != null) {
values: for (String key : values.keySet()) {
- ExecutionSpecAttribute attribute = executionFlowDescriptor
- .getExecutionSpec().getAttributes().get(key);
+ ExecutionSpecAttribute attribute = executionSpec
+ .getAttributes().get(key);
if (attribute.getIsFrozen())
continue values;
import org.apache.commons.cli.ParseException;
import org.apache.commons.io.IOUtils;
import org.argeo.slc.SlcException;
-import org.argeo.slc.server.client.SlcServerHttpClient;
import org.argeo.slc.server.client.impl.SlcServerHttpClientImpl;
+@SuppressWarnings("static-access")
public class SlcMain {
public enum Type {
standalone, agent, server
private static Boolean debug = true;
- private final static String BOOTSTRAP_LOG4J_CONFIG = "org/argeo/slc/cli/bootstrapLog4j.properties";
- private final static String DEFAULT_AGENT_CONTEXT = "classpath:org/argeo/slc/cli/spring-agent-default.xml";
+ // private final static String BOOTSTRAP_LOG4J_CONFIG =
+ // "org/argeo/slc/cli/bootstrapLog4j.properties";
+ // private final static String DEFAULT_AGENT_CONTEXT =
+ // "classpath:org/argeo/slc/cli/spring-agent-default.xml";
private final static Option typeOpt = OptionBuilder.withLongOpt("mode")
.withArgName("mode").hasArg().withDescription(
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
+import java.net.Authenticator;
import java.net.HttpURLConnection;
+import java.net.PasswordAuthentication;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Map;
public abstract class AbstractHttpServicesClient implements HttpServicesClient {
private final static Log log = LogFactory
.getLog(AbstractHttpServicesClient.class);
+
+ private String user;
+ private String password;
+
private Unmarshaller unmarshaller;
private Marshaller marshaller;
private String baseUrl;
private Long retryPeriod = 1000l;
private Long defaultTimeout = 30 * 1000l;
+ public void init() {
+ if (user != null && password != null)
+ Authenticator.setDefault(new Authenticator() {
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(user, password
+ .toCharArray());
+ }
+ });
+ }
+
@SuppressWarnings(value = { "unchecked" })
public <T> T callService(String path, Map<String, String> parameters) {
- return (T)callService(path, parameters, null);
+ return (T) callService(path, parameters, null);
}
@SuppressWarnings(value = { "unchecked" })
protected Object callServiceLowLevel(String path,
Map<String, String> parameters, Object body) throws IOException {
+
Assert.notNull(baseUrl, "base url");
HttpURLConnection connection = null;
Writer writer = null;
return defaultTimeout;
}
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:aop="http://www.springframework.org/schema/aop"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
<import resource="classpath:org/argeo/slc/castor/spring.xml" />
<!-- Http client -->
- <bean id="slcDefault.serverHttpClient" class="org.argeo.slc.server.client.impl.SlcServerHttpClientImpl"
- lazy-init="true">
+ <bean id="slcTemplate.serverHttpClient"
+ class="org.argeo.slc.server.client.impl.SlcServerHttpClientImpl"
+ init-method="init" abstract="true">
+ <property name="user" value="demo" />
+ <property name="password" value="demo" />
<property name="unmarshaller" ref="slcDefault.castor.marshaller" />
<property name="marshaller" ref="slcDefault.castor.marshaller" />
<property name="baseUrl" value="http://localhost:7070/org.argeo.slc.webapp/" />
--- /dev/null
+package org.argeo.slc.web.mvc.process;\r
+\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+\r
+import org.argeo.slc.dao.process.SlcExecutionDao;\r
+import org.argeo.slc.msg.ObjectList;\r
+import org.argeo.slc.process.SlcExecution;\r
+import org.argeo.slc.web.mvc.AbstractServiceController;\r
+import org.springframework.oxm.Unmarshaller;\r
+import org.springframework.web.servlet.ModelAndView;\r
+import org.springframework.xml.transform.StringSource;\r
+\r
+/** Lists SLC executions possibly filtering them. */\r
+public class GetSlcExecution extends AbstractServiceController {\r
+ private SlcExecutionDao slcExecutionDao;\r
+ private Unmarshaller unmarshaller;\r
+\r
+ @Override\r
+ protected void handleServiceRequest(HttpServletRequest request,\r
+ HttpServletResponse response, ModelAndView modelAndView)\r
+ throws Exception {\r
+ String uuid = request.getParameter("uuid");\r
+ SlcExecution slcExecution = slcExecutionDao.getSlcExecution(uuid);\r
+\r
+ StringSource source = new StringSource(slcExecution\r
+ .getRealizedFlowsXml());\r
+ ObjectList ol2 = (ObjectList) unmarshaller.unmarshal(source);\r
+ ol2.fill(slcExecution.getRealizedFlows());\r
+\r
+ modelAndView.addObject(slcExecution);\r
+ }\r
+\r
+ public void setSlcExecutionDao(SlcExecutionDao slcExecutionDao) {\r
+ this.slcExecutionDao = slcExecutionDao;\r
+ }\r
+\r
+ public void setUnmarshaller(Unmarshaller unmarshaller) {\r
+ this.unmarshaller = unmarshaller;\r
+ }\r
+\r
+}\r
import org.apache.commons.logging.Log;\r
import org.apache.commons.logging.LogFactory;\r
import org.argeo.slc.msg.MsgConstants;\r
+import org.argeo.slc.msg.ObjectList;\r
import org.argeo.slc.process.SlcExecution;\r
import org.argeo.slc.process.SlcExecutionStep;\r
import org.argeo.slc.runtime.SlcAgent;\r
import org.argeo.slc.runtime.SlcAgentFactory;\r
import org.argeo.slc.services.SlcExecutionService;\r
import org.argeo.slc.web.mvc.AbstractServiceController;\r
+import org.springframework.oxm.Marshaller;\r
import org.springframework.oxm.Unmarshaller;\r
import org.springframework.util.Assert;\r
import org.springframework.web.servlet.ModelAndView;\r
+import org.springframework.xml.transform.StringResult;\r
import org.springframework.xml.transform.StringSource;\r
\r
/** Send a new SlcExecution. */\r
\r
private SlcAgentFactory agentFactory;\r
private Unmarshaller unmarshaller;\r
+ private Marshaller marshaller;\r
private SlcExecutionService slcExecutionService;\r
\r
@Override\r
slcExecution.getSteps().add(\r
new SlcExecutionStep(SlcExecutionStep.TYPE_START,\r
"Process started from the Web UI"));\r
+\r
+ ObjectList ol = new ObjectList(slcExecution.getRealizedFlows());\r
+ StringResult result = new StringResult();\r
+ marshaller.marshal(ol, result);\r
+ slcExecution.setRealizedFlowsXml(result.toString());\r
+\r
slcExecutionService.newExecution(slcExecution);\r
\r
SlcAgent agent = agentFactory.getAgent(agentId);\r
this.slcExecutionService = slcExecutionService;\r
}\r
\r
+ public void setMarshaller(Marshaller marshaller) {\r
+ this.marshaller = marshaller;\r
+ }\r
+\r
}\r
package org.argeo.slc.process;
+import java.io.Serializable;
+
import org.argeo.slc.execution.ExecutionFlowDescriptor;
import org.argeo.slc.execution.ExecutionSpec;
-public class RealizedFlow {
+public class RealizedFlow implements Serializable {
+ private static final long serialVersionUID = 1L;
+
private String moduleName;
private String moduleVersion;
private ExecutionFlowDescriptor flowDescriptor;
/** TODO: Synchronize */\r
private List<SlcExecutionStep> steps = new ArrayList<SlcExecutionStep>();\r
private List<RealizedFlow> realizedFlows = new ArrayList<RealizedFlow>();\r
+ private String realizedFlowsXml = null;\r
\r
public List<RealizedFlow> getRealizedFlows() {\r
return realizedFlows;\r
return steps.get(steps.size() - 1).getBegin();\r
}\r
}\r
+\r
+ public String getRealizedFlowsXml() {\r
+ return realizedFlowsXml;\r
+ }\r
+\r
+ public void setRealizedFlowsXml(String realizedFlowsXml) {\r
+ this.realizedFlowsXml = realizedFlowsXml;\r
+ }\r
+\r
}\r
package org.argeo.slc.castor;\r
\r
import java.text.SimpleDateFormat;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
import java.util.UUID;\r
\r
-import org.argeo.slc.execution.ExecutionFlowDescriptor;\r
import org.argeo.slc.msg.process.SlcExecutionRequest;\r
import org.argeo.slc.msg.process.SlcExecutionStepsRequest;\r
-import org.argeo.slc.process.RealizedFlow;\r
import org.argeo.slc.process.SlcExecution;\r
import org.argeo.slc.process.SlcExecutionStep;\r
-import org.argeo.slc.unit.execution.ExecutionFlowDescriptorTestUtils;\r
import org.argeo.slc.unit.process.SlcExecutionTestUtils;\r
import org.springframework.xml.transform.StringResult;\r
\r
}\r
\r
public void testMarshUnmarsh() throws Exception {\r
- SlcExecution slcExec = SlcExecutionTestUtils.createSimpleSlcExecution();\r
- List<RealizedFlow> realizedFlows = new ArrayList<RealizedFlow>();\r
- RealizedFlow realizedFlow = new RealizedFlow();\r
- ExecutionFlowDescriptor flowDescriptor = ExecutionFlowDescriptorTestUtils\r
- .createSimpleExecutionFlowDescriptor();\r
- realizedFlow.setModuleName("test.module");\r
- realizedFlow.setModuleVersion("1.0.0");\r
- realizedFlow.setFlowDescriptor(flowDescriptor);\r
- realizedFlow.setExecutionSpec(flowDescriptor.getExecutionSpec());\r
- realizedFlows.add(realizedFlow);\r
- slcExec.setRealizedFlows(realizedFlows);\r
-\r
+ SlcExecution slcExec = SlcExecutionTestUtils\r
+ .createSlcExecutionWithRealizedFlows();\r
marshUnmarsh(slcExec, false);\r
}\r
}\r
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.argeo.slc</groupId>
<property name="host" column="HOST" />\r
<property name="user" column="USER" />\r
<property name="type" column="TYPE" />\r
- <property name="status" column="STATUS" />\r
-\r
+ <property name="status" column="STATUS" />
+ <property name="realizedFlowsXml" column="REALIZED_FLOWS_XML"
+ type="text" />\r
<list name="steps" cascade="all" table="SLC_EXECUTIONS_STEPS"\r
lazy="false">\r
<cache usage="read-write" />\r
--- /dev/null
+package org.argeo.slc.hibernate.process;\r
+\r
+import java.sql.SQLException;\r
+\r
+import org.argeo.slc.dao.process.SlcExecutionDao;\r
+import org.argeo.slc.hibernate.unit.HibernateTestCase;\r
+import org.argeo.slc.msg.ObjectList;\r
+import org.argeo.slc.process.SlcExecution;\r
+import org.argeo.slc.unit.process.SlcExecutionTestUtils;\r
+import org.hibernate.HibernateException;\r
+import org.hibernate.Session;\r
+import org.springframework.orm.hibernate3.HibernateCallback;\r
+import org.springframework.oxm.Marshaller;\r
+import org.springframework.oxm.Unmarshaller;\r
+import org.springframework.xml.transform.StringResult;\r
+import org.springframework.xml.transform.StringSource;\r
+\r
+public class CastorSlcExecutionHibernateTest extends HibernateTestCase {\r
+\r
+ public void testSaveWithRealizedFlowsXml() throws Exception {\r
+ SlcExecutionDao dao = getBean(SlcExecutionDao.class);\r
+\r
+ SlcExecution slcExec = SlcExecutionTestUtils\r
+ .createSlcExecutionWithRealizedFlows();\r
+\r
+ ObjectList ol = new ObjectList(slcExec.getRealizedFlows());\r
+ StringResult result = new StringResult();\r
+ getBean(Marshaller.class).marshal(ol, result);\r
+ slcExec.setRealizedFlowsXml(result.toString());\r
+\r
+ dao.create(slcExec);\r
+\r
+ SlcExecution slcExecPersisted = dao.getSlcExecution(slcExec.getUuid());\r
+ assertSlcExecution(slcExec, slcExecPersisted);\r
+\r
+ StringSource source = new StringSource(slcExecPersisted\r
+ .getRealizedFlowsXml());\r
+ ObjectList ol2 = (ObjectList) getBean(Unmarshaller.class).unmarshal(\r
+ source);\r
+ ol2.fill(slcExec.getRealizedFlows());\r
+\r
+ }\r
+\r
+ public void assertSlcExecution(final SlcExecution expected,\r
+ final SlcExecution persisted) {\r
+ getHibernateTemplate().execute(new HibernateCallback() {\r
+\r
+ public Object doInHibernate(Session session)\r
+ throws HibernateException, SQLException {\r
+ session.refresh(persisted);\r
+ SlcExecutionTestUtils.assertSlcExecution(expected, persisted);\r
+ return null;\r
+ }\r
+ });\r
+ }\r
+\r
+ @Override\r
+ protected String getApplicationContextLocation() {\r
+ return "org/argeo/slc/hibernate/withCastor.xml";\r
+ }\r
+}\r
import static junit.framework.Assert.assertNotNull;\r
import static org.argeo.slc.unit.UnitUtils.assertDateSec;\r
\r
+import java.util.ArrayList;\r
+import java.util.List;\r
import java.util.UUID;\r
\r
+import org.argeo.slc.execution.ExecutionFlowDescriptor;\r
+import org.argeo.slc.process.RealizedFlow;\r
import org.argeo.slc.process.SlcExecution;\r
import org.argeo.slc.process.SlcExecutionStep;\r
+import org.argeo.slc.unit.execution.ExecutionFlowDescriptorTestUtils;\r
\r
public abstract class SlcExecutionTestUtils {\r
\r
return slcExec;\r
}\r
\r
+ public static SlcExecution createSlcExecutionWithRealizedFlows() {\r
+ SlcExecution slcExec = SlcExecutionTestUtils.createSimpleSlcExecution();\r
+ List<RealizedFlow> realizedFlows = new ArrayList<RealizedFlow>();\r
+ RealizedFlow realizedFlow = new RealizedFlow();\r
+ ExecutionFlowDescriptor flowDescriptor = ExecutionFlowDescriptorTestUtils\r
+ .createSimpleExecutionFlowDescriptor();\r
+ realizedFlow.setModuleName("test.module");\r
+ realizedFlow.setModuleVersion("1.0.0");\r
+ realizedFlow.setFlowDescriptor(flowDescriptor);\r
+ realizedFlow.setExecutionSpec(flowDescriptor.getExecutionSpec());\r
+ realizedFlows.add(realizedFlow);\r
+ slcExec.setRealizedFlows(realizedFlows);\r
+ return slcExec;\r
+ }\r
+\r
public static void assertSlcExecution(SlcExecution expected,\r
SlcExecution reached) {\r
assertNotNull(reached);\r