diff --git a/Felix/bundle-dev/OfficeBase-0.0.3-SNAPSHOT.jar b/Felix/bundle-dev/OfficeBase-0.0.3-SNAPSHOT.jar new file mode 120000 index 0000000000000000000000000000000000000000..11ad15040b1351425d970a3e0dd83d1656a1de4d --- /dev/null +++ b/Felix/bundle-dev/OfficeBase-0.0.3-SNAPSHOT.jar @@ -0,0 +1 @@ +/home/costea/workspace_sally4/sally4.git/OfficeBase/target/OfficeBase-0.0.3-SNAPSHOT.jar \ No newline at end of file diff --git a/OfficeBase/.classpath b/OfficeBase/.classpath new file mode 100644 index 0000000000000000000000000000000000000000..6a3cba6d9d80b9bf7925fc37cd7955fe4eae13d0 --- /dev/null +++ b/OfficeBase/.classpath @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" output="target/classes" path="src/main/java"> + <attributes> + <attribute name="optional" value="true"/> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="src" output="target/test-classes" path="src/test/java"> + <attributes> + <attribute name="optional" value="true"/> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry including="**/*.java" kind="src" path="src/main/resources"/> + <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> + <attributes> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"> + <attributes> + <attribute name="maven.pomderived" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="output" path="target/classes"/> +</classpath> diff --git a/OfficeBase/.project b/OfficeBase/.project new file mode 100644 index 0000000000000000000000000000000000000000..f01d1fb785e32d4d787643945b04901429da3e2e --- /dev/null +++ b/OfficeBase/.project @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>OfficeBase</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.m2e.core.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.eclipse.m2e.core.maven2Nature</nature> + </natures> +</projectDescription> diff --git a/OfficeBase/.settings/org.eclipse.jdt.core.prefs b/OfficeBase/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..60105c1b9516ec7dc540970605e57f7ffe09e368 --- /dev/null +++ b/OfficeBase/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/OfficeBase/.settings/org.eclipse.m2e.core.prefs b/OfficeBase/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..f897a7f1cb2389f85fe6381425d29f0a9866fb65 --- /dev/null +++ b/OfficeBase/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/OfficeBase/pom.xml b/OfficeBase/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..c1d7c66327be09e6005cc836db5680103ea485e3 --- /dev/null +++ b/OfficeBase/pom.xml @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="UTF-8"?> +<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/xsd/maven-4.0.0.xsd"> + + <!-- Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with this + work for additional information regarding copyright ownership. The ASF licenses + this file to You under the Apache License, Version 2.0 (the "License"); you + may not use this file except in compliance with the License. You may obtain + a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless + required by applicable law or agreed to in writing, software distributed + under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES + OR CONDITIONS OF ANY KIND, either express or implied. See the License for + the specific language governing permissions and limitations under the License. --> + + <modelVersion>4.0.0</modelVersion> + + <packaging>bundle</packaging> + + <groupId>info.kwarc.sally4</groupId> + <artifactId>OfficeBase</artifactId> + <version>${sally4.version}</version> + + <parent> + <groupId>info.kwarc.sally</groupId> + <artifactId>sally</artifactId> + <version>1.0</version> + <relativePath>..</relativePath> + </parent> + + + <dependencies> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <version>4.3.1</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.ipojo.annotations</artifactId> + <version>1.11.2</version> + </dependency> + + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-core</artifactId> + <version>${camel.version}</version> + </dependency> + + <dependency> + <groupId>info.kwarc.sally4</groupId> + <artifactId>core</artifactId> + <version>${sally4.version}</version> + </dependency> + + <dependency> + <groupId>info.kwarc.sally4</groupId> + <artifactId>utils</artifactId> + <version>${sally4.version}</version> + </dependency> + + <dependency> + <groupId>info.kwarc.sally4</groupId> + <artifactId>docmanager</artifactId> + <version>${sally4.version}</version> + </dependency> + + <dependency> + <groupId>info.kwarc.sally4</groupId> + <artifactId>servlet</artifactId> + <version>${sally4.version}</version> + </dependency> + + </dependencies> + + <build> + <plugins> + <!-- BND Maven Plugin Configuration --> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> + <Private-Package>info.kwarc.sally4.officebase.impl*</Private-Package> + <Export-Package>info.kwarc.sally4.officebase*;libs*</Export-Package> + </instructions> + </configuration> + </plugin> + <!-- iPOJO Maven Plugin Configuration : nothing to do --> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-ipojo-plugin</artifactId> + <version>1.11.2</version> + <executions> + <execution> + <goals> + <goal>ipojo-bundle</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/OfficeBase/src/main/java/info/kwarc/sally4/officebase/SelectClient.java b/OfficeBase/src/main/java/info/kwarc/sally4/officebase/SelectClient.java new file mode 100644 index 0000000000000000000000000000000000000000..3a01499d38f5590c4cea3592fc800270b078922a --- /dev/null +++ b/OfficeBase/src/main/java/info/kwarc/sally4/officebase/SelectClient.java @@ -0,0 +1,7 @@ +package info.kwarc.sally4.officebase; + +import info.kwarc.sally4.docmanager.SallyDoc; + +public interface SelectClient { + SallyDoc getDoc(); +} diff --git a/OfficeBase/src/main/java/info/kwarc/sally4/officebase/factories/OfficeBaseFactory.java b/OfficeBase/src/main/java/info/kwarc/sally4/officebase/factories/OfficeBaseFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..03f6307075374995a61f63406583364bf3c23e43 --- /dev/null +++ b/OfficeBase/src/main/java/info/kwarc/sally4/officebase/factories/OfficeBaseFactory.java @@ -0,0 +1,56 @@ +package info.kwarc.sally4.officebase.factories; + +import info.kwarc.sally4.docmanager.SallyDoc; + +import java.util.Dictionary; +import java.util.Hashtable; + +import org.apache.felix.ipojo.ComponentInstance; +import org.apache.felix.ipojo.ConfigurationException; +import org.apache.felix.ipojo.Factory; +import org.apache.felix.ipojo.InstanceStateListener; +import org.apache.felix.ipojo.MissingHandlerException; +import org.apache.felix.ipojo.UnacceptableConfiguration; +import org.apache.felix.ipojo.annotations.Bind; +import org.apache.felix.ipojo.annotations.Component; +import org.apache.felix.ipojo.annotations.Instantiate; +import org.apache.felix.ipojo.annotations.Requires; + +@Component +@Instantiate +public class OfficeBaseFactory { + @Requires(filter="(factory.name=SelectInstance)") + Factory selectWorkflows; + + void createInstance(Factory factory, String name, String docQueue) throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException { + Dictionary<String, Object> configuration = new Hashtable<String, Object>(); + Dictionary<String, Object> filters = new Hashtable<String, Object>(); + + filters.put("docQueue", "(docQueue="+docQueue+")"); + + configuration.put("requires.filters", filters); + + configuration.put("instance.name", name+" for doc:"+docQueue); + + ComponentInstance inst = factory.createComponentInstance(configuration); + inst.addInstanceStateListener(new InstanceStateListener() { + + @Override + public void stateChanged(ComponentInstance arg0, int arg1) { + if (arg1 == ComponentInstance.INVALID) { + arg0.dispose(); + } + } + }); + } + + @Bind(aggregate=true) + void newSallyDoc(SallyDoc newDoc) throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException { + for (String iface : newDoc.getInterfaces()) { + if ("select".equals(iface)) { + createInstance(selectWorkflows, "SelectClient", newDoc.getDocQueue()); + return; + } + } + } +} diff --git a/OfficeBase/src/main/java/info/kwarc/sally4/officebase/impl/OfficeBaseInstance.java b/OfficeBase/src/main/java/info/kwarc/sally4/officebase/impl/OfficeBaseInstance.java new file mode 100644 index 0000000000000000000000000000000000000000..8f97bc72e391428b71d98601a16a3e69806eb6ee --- /dev/null +++ b/OfficeBase/src/main/java/info/kwarc/sally4/officebase/impl/OfficeBaseInstance.java @@ -0,0 +1,55 @@ +package info.kwarc.sally4.officebase.impl; + +import info.kwarc.sally4.core.CamelContextProvider; +import info.kwarc.sally4.core.SallyInteraction; +import info.kwarc.sally4.docmanager.SallyDoc; +import info.kwarc.sally4.marshalling.CommUtils; +import info.kwarc.sally4.officebase.SelectClient; +import info.kwarc.sally4.servlet.SallyServlet; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.spi.DataFormat; +import org.apache.felix.ipojo.annotations.Component; +import org.apache.felix.ipojo.annotations.Provides; +import org.apache.felix.ipojo.annotations.Requires; +import org.apache.felix.ipojo.annotations.Validate; + +@Component(name="SelectInstance") +@Provides(specifications=SelectClient.class) +public class OfficeBaseInstance extends RouteBuilder implements SelectClient{ + String planetaryClientNamespace = "http://kwarc.info/sally/comm/planetaryclient"; + + @Requires + SallyServlet t; + + @Requires(id="docQueue", filter="(filterThatWillNeverSucceed=1)") + SallyDoc route; + + @Requires + SallyInteraction interact; + + @Requires + CamelContextProvider camelContextProvider; + + @Validate + void doStart() { + } + + public OfficeBaseInstance() { + } + + @Override + public void configure() throws Exception { + DataFormat worker = CommUtils.getDataFormat("mathhubworker", getClass().getClassLoader()); + getContext().addComponent("alex", route.getAlexComponent()); + + from("direct:start") + .to("direct:requestAuthKey"); + } + + @Override + public SallyDoc getDoc() { + return route; + } + +} diff --git a/OfficeBase/src/main/resources/libs/mhwsettings.png b/OfficeBase/src/main/resources/libs/mhwsettings.png new file mode 100644 index 0000000000000000000000000000000000000000..310f39a0af2dbeb5a91ce4617eca569a06d290dd Binary files /dev/null and b/OfficeBase/src/main/resources/libs/mhwsettings.png differ diff --git a/OfficeBase/src/main/resources/mathhubworker.xsd b/OfficeBase/src/main/resources/mathhubworker.xsd new file mode 100644 index 0000000000000000000000000000000000000000..2f6b4d57192a4e1a89fff732351e92775240c91c --- /dev/null +++ b/OfficeBase/src/main/resources/mathhubworker.xsd @@ -0,0 +1,5 @@ +<?xml version="1.0"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://kwarc.info/sally/comm/mathhubworker" elementFormDefault="qualified"> + +</xs:schema> \ No newline at end of file diff --git a/OfficeBase/src/main/resources/templates/mhwsettings.html b/OfficeBase/src/main/resources/templates/mhwsettings.html new file mode 100644 index 0000000000000000000000000000000000000000..46ef9f3a84168268beb72b95b3d7d195b83125c5 --- /dev/null +++ b/OfficeBase/src/main/resources/templates/mhwsettings.html @@ -0,0 +1,30 @@ +<html> +<script type="text/javascript" src=""></script> +<script src='/sally/jobad/libs/js/libs.js'></script> +<link rel='stylesheet' type='text/css' href='/sally/jobad/libs/css/libs.css'> +<script src='/sally/jobad/JOBAD.min.js'></script> +<link rel='stylesheet' type='text/css' href='/sally/jobad/JOBAD.min.css'> + +<body class="bootstrap"> + +<div class="navbar navbar-inverse"> + <div class="navbar-inner"> + <a class="brand" href="#">MathHub Workers</a> + </div> +</div> + + <#list body.env?keys as e> + <form action="setmhw"> + <div class="row-fluid"> + <div class="span1">${e_index+1}.</div> + <button class="span11 btn"> + ${body.env[e].getDescription()} + </button> + <input type="hidden" name="envid" value="${e}" /> + <input type="hidden" name="id" value="${body.doc_queue_id}" /> + </div> + </form> + </#list> + +</body> +</html> \ No newline at end of file diff --git a/OfficeBase/src/test/java/info/kwarc/sally4/mathhubworker/impl/MathHubWorkerManagerImplTest.java b/OfficeBase/src/test/java/info/kwarc/sally4/mathhubworker/impl/MathHubWorkerManagerImplTest.java new file mode 100644 index 0000000000000000000000000000000000000000..947cfcaaa63f0fdfbaca12d815168385dcefb3c8 --- /dev/null +++ b/OfficeBase/src/test/java/info/kwarc/sally4/mathhubworker/impl/MathHubWorkerManagerImplTest.java @@ -0,0 +1,63 @@ +package info.kwarc.sally4.mathhubworker.impl; +/* + +import info.kwarc.sally4.docmanager.SallyDoc; +import info.kwarc.sally4.docmanager.impl.SallyDocImpl; +import info.kwarc.sally4.docmanager.mocks.MockDocumentManager; +import info.kwarc.sally4.docmanager.mocks.MockGlobalContextProvider; +import info.kwarc.sally4.mathhubworker.routes.LMHWorkflowInstance; + +import org.apache.camel.CamelContext; +import org.apache.camel.EndpointInject; +import org.apache.camel.Exchange; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; +public class MathHubWorkerManagerImplTest extends CamelTestSupport{ + MockDocumentManager man; + MathHubWorkerManagerImpl workerManager; + + @EndpointInject(uri="sallyservlet:///planetary/mhwsettings") + ProducerTemplate starter; + + @EndpointInject(uri="mock:result") + MockEndpoint result; + + public MathHubWorkerManagerImplTest() { + } + + @Test + public void test() throws Exception { + LMHWorkflow lmhWorkflow = new LMHWorkflow(); + + SallyDoc alexRoute = new SallyDocImpl("lmhqueue", "e1", "u1", "", new String[]{"lmhworker"}); + LMHWorkflowInstance lmhInstance = new LMHWorkflowInstance(alexRoute, lmhWorkflow); + man.addWorkflowInstances(lmhInstance); + + starter.sendBody(""); + for (Exchange e: result.getExchanges()) { + System.out.println(e.getIn().getBody(String.class)); + } + } + + @Test + public void test2() throws Exception { + LMHWorkflow lmhWorkflow = new LMHWorkflow(); + SallyDoc alexRoute = new SallyDocImpl("q1", "e1", "u1", "", new String[]{"lmhworker"}); + LMHWorkflowInstance lmhInstance = new LMHWorkflowInstance(alexRoute, lmhWorkflow); + man.addWorkflowInstances(lmhInstance); + starter.sendBody(""); + } + + @Override + protected CamelContext createCamelContext() throws Exception { + man = new MockDocumentManager(); + workerManager = new MathHubWorkerManagerImpl(); + workerManager.docManager = man; + workerManager.camelContextProvider = new MockGlobalContextProvider(); + workerManager.start(); + return workerManager.getContext(); + } +} +*/ \ No newline at end of file diff --git a/core/src/main/java/info/kwarc/sally/comm/core/Heartbeatrequest.java b/core/src/main/java/info/kwarc/sally/comm/core/Heartbeatrequest.java index 8b226e056a980a36649a7a87cb8e14f35375656e..7d0edcb1971d5c6a10b7c799bb37106ed5275a59 100644 --- a/core/src/main/java/info/kwarc/sally/comm/core/Heartbeatrequest.java +++ b/core/src/main/java/info/kwarc/sally/comm/core/Heartbeatrequest.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2014.04.17 at 03:49:09 PM CEST +// Generated on: 2014.04.23 at 02:05:16 PM CEST // diff --git a/core/src/main/java/info/kwarc/sally/comm/core/Heartbeatresponse.java b/core/src/main/java/info/kwarc/sally/comm/core/Heartbeatresponse.java index eac507c9b883d5e4d1093949fc77b14bf29ada6d..1abd0a2d7bd0d8f0f7953dc6f7b1219f89d30c04 100644 --- a/core/src/main/java/info/kwarc/sally/comm/core/Heartbeatresponse.java +++ b/core/src/main/java/info/kwarc/sally/comm/core/Heartbeatresponse.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2014.04.17 at 03:49:09 PM CEST +// Generated on: 2014.04.23 at 02:05:16 PM CEST // diff --git a/core/src/main/java/info/kwarc/sally/comm/core/ObjectFactory.java b/core/src/main/java/info/kwarc/sally/comm/core/ObjectFactory.java index 1469041bb77e14ae4adf6ec41e034e0890b1be50..cb668ad5336a2693f9973d5c1ae951eb49756d87 100644 --- a/core/src/main/java/info/kwarc/sally/comm/core/ObjectFactory.java +++ b/core/src/main/java/info/kwarc/sally/comm/core/ObjectFactory.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2014.04.17 at 03:49:09 PM CEST +// Generated on: 2014.04.23 at 02:05:16 PM CEST // @@ -52,14 +52,6 @@ public class ObjectFactory { return new Registerdocumentresponse(); } - /** - * Create an instance of {@link Onsallyframe } - * - */ - public Onsallyframe createOnsallyframe() { - return new Onsallyframe(); - } - /** * Create an instance of {@link Heartbeatrequest } * diff --git a/core/src/main/java/info/kwarc/sally/comm/core/Registerdocument.java b/core/src/main/java/info/kwarc/sally/comm/core/Registerdocument.java index bf4a06f5ee3b378ee1f9de0f586111672cfe75f1..49fcd6821fb86520a2cc3478295eebf65b514937 100644 --- a/core/src/main/java/info/kwarc/sally/comm/core/Registerdocument.java +++ b/core/src/main/java/info/kwarc/sally/comm/core/Registerdocument.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2014.04.17 at 03:49:09 PM CEST +// Generated on: 2014.04.23 at 02:05:16 PM CEST // diff --git a/core/src/main/java/info/kwarc/sally/comm/core/Registerdocumentresponse.java b/core/src/main/java/info/kwarc/sally/comm/core/Registerdocumentresponse.java index 34e07e52d38889b2dedcd96331e5761e561a0a21..6d75813cbb8df59b70a5bfa0e43cdf6e03b58700 100644 --- a/core/src/main/java/info/kwarc/sally/comm/core/Registerdocumentresponse.java +++ b/core/src/main/java/info/kwarc/sally/comm/core/Registerdocumentresponse.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2014.04.17 at 03:49:09 PM CEST +// Generated on: 2014.04.23 at 02:05:16 PM CEST // diff --git a/core/src/main/java/info/kwarc/sally/comm/core/package-info.java b/core/src/main/java/info/kwarc/sally/comm/core/package-info.java index 266de15f4d00aefe675e229b806ecdd802f476f2..475a5c5bf1f90c96623aabf4d830c85e563b42ef 100644 --- a/core/src/main/java/info/kwarc/sally/comm/core/package-info.java +++ b/core/src/main/java/info/kwarc/sally/comm/core/package-info.java @@ -2,7 +2,7 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2014.04.17 at 03:49:09 PM CEST +// Generated on: 2014.04.23 at 02:05:16 PM CEST // @javax.xml.bind.annotation.XmlSchema(namespace = "http://kwarc.info/sally/comm/core", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) diff --git a/core/src/main/java/info/kwarc/sally/comm/select/ObjectFactory.java b/core/src/main/java/info/kwarc/sally/comm/select/ObjectFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..e7900c5501000dd9c07ce550351e29b5ab4279b2 --- /dev/null +++ b/core/src/main/java/info/kwarc/sally/comm/select/ObjectFactory.java @@ -0,0 +1,47 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2014.04.23 at 01:50:46 PM CEST +// + + +package info.kwarc.sally.comm.select; + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the info.kwarc.sally.comm.select package. + * <p>An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: info.kwarc.sally.comm.select + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link Onsallyframe } + * + */ + public Onsallyframe createOnsallyframe() { + return new Onsallyframe(); + } + +} diff --git a/core/src/main/java/info/kwarc/sally/comm/core/Onsallyframe.java b/core/src/main/java/info/kwarc/sally/comm/select/Onsallyframe.java similarity index 95% rename from core/src/main/java/info/kwarc/sally/comm/core/Onsallyframe.java rename to core/src/main/java/info/kwarc/sally/comm/select/Onsallyframe.java index 1a288bb1f548e3271ec4c1920b106cfd412b9512..a2f1b22d930dc6a2d8256d7ce44296e2ae782809 100644 --- a/core/src/main/java/info/kwarc/sally/comm/core/Onsallyframe.java +++ b/core/src/main/java/info/kwarc/sally/comm/select/Onsallyframe.java @@ -2,11 +2,11 @@ // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2014.04.17 at 03:49:09 PM CEST +// Generated on: 2014.04.23 at 01:50:46 PM CEST // -package info.kwarc.sally.comm.core; +package info.kwarc.sally.comm.select; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/core/src/main/java/info/kwarc/sally/comm/select/package-info.java b/core/src/main/java/info/kwarc/sally/comm/select/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..bd80b18ba321ea901c718628794cb4a9abb350ff --- /dev/null +++ b/core/src/main/java/info/kwarc/sally/comm/select/package-info.java @@ -0,0 +1,9 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2014.04.23 at 01:50:46 PM CEST +// + +@javax.xml.bind.annotation.XmlSchema(namespace = "http://kwarc.info/sally/comm/select") +package info.kwarc.sally.comm.select; diff --git a/core/src/main/resources/core.xsd b/core/src/main/resources/core.xsd index fbfdd0ead40918f577836a2cd130ceac0014c1ac..4734e250be135cb1e30d2326dc9e423304444519 100644 --- a/core/src/main/resources/core.xsd +++ b/core/src/main/resources/core.xsd @@ -23,15 +23,6 @@ </xs:complexType> </xs:element> - <xs:element name="onsallyframe"> - <xs:complexType> - <xs:sequence> - <xs:element name="posx" type="xs:int" /> - <xs:element name="posy" type="xs:int" /> - </xs:sequence> - </xs:complexType> - </xs:element> - <xs:element name="heartbeatrequest"> <xs:complexType> </xs:complexType> diff --git a/core/src/main/resources/select.xsd b/core/src/main/resources/select.xsd index 3fc8398ecc2c3bd264a885cfb8fe201566fddbbe..488b0b2c702f9a0081435c5f6cfe82129ebac356 100644 --- a/core/src/main/resources/select.xsd +++ b/core/src/main/resources/select.xsd @@ -1,6 +1,15 @@ <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://kwarc.info/sally/comm/select"> - + <xs:element name="onsallyframe"> + <xs:complexType> + <xs:sequence> + <xs:element name="posx" type="xs:int" /> + <xs:element name="posy" type="xs:int" /> + </xs:sequence> + </xs:complexType> + </xs:element> + + </xs:schema> \ No newline at end of file diff --git a/docmanager/src/main/java/info/kwarc/sally4/docmanager/impl/SallyDocImpl.java b/docmanager/src/main/java/info/kwarc/sally4/docmanager/impl/SallyDocImpl.java index 07c51d4d89ef543cbd0c79947d2339c9321737ff..f06534af713eb4d2a7d56137135ba963e5f3bd4a 100644 --- a/docmanager/src/main/java/info/kwarc/sally4/docmanager/impl/SallyDocImpl.java +++ b/docmanager/src/main/java/info/kwarc/sally4/docmanager/impl/SallyDocImpl.java @@ -92,7 +92,6 @@ public class SallyDocImpl extends RouteBuilder implements SallyDoc { @Override public ProducerConsumerSplitterComponent getAlexComponent() { - log.info("will start on queue "+docStateQueue); return new ProducerConsumerSplitterComponent("activemq:queue:"+docStateQueue, "activemq:queue:"+docQueue); } diff --git a/pom.xml b/pom.xml index 609728856f6827f94d00d5e2728f2dc4041a09f9..57f92a8efff4ca953a8042c3c5516be33bbc0237 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,7 @@ <module>planetary</module> <module>servlet</module> <module>MathHubWorker</module> + <module>OfficeBase</module> <module>activemq</module> </modules> diff --git a/theo/.gitignore b/theo/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..36379653096280650924f5622e41341ed5c0101a --- /dev/null +++ b/theo/.gitignore @@ -0,0 +1,2 @@ +node +node_modules \ No newline at end of file diff --git a/theo/app.coffee b/theo/app.coffee new file mode 100644 index 0000000000000000000000000000000000000000..a8efa5dc5feeb51b6581836a3e73a425951cf605 --- /dev/null +++ b/theo/app.coffee @@ -0,0 +1,45 @@ +appjs = require('appjs'); +async = require "async" + +http = require('http') +express = require('express'); +connect = require('connect') + +SallyClient = (require "./sally_client").SallyClient + +stomp_args = + port : 61613, + host: 'localhost', + login: 'webclient', + passcode: 'webclient', +# debug: true, + +handler = (body, msg) => + console.log(msg); + +sally = new SallyClient stomp_args, handler +sally.connect ["theo"], (body, msg)-> + console.log("connected "); + +createNewWindow = (body) -> + window = appjs.createWindow(body.url, { + width : 640, + height : 460, + }); + + window.on('create', () -> + window.frame.show(); + window.frame.center(); + ) + + window.on('ready', () -> + window.process = process; + window.module = module; + ); + + window.on('close', () -> + console.log("Window Closed"); + ); + +#process.on 'SIGINT', () -> +# client.disconnect() diff --git a/theo/app.js b/theo/app.js new file mode 100644 index 0000000000000000000000000000000000000000..3739a9358f6bb05fbe8f60c5e82a2256b1662e02 --- /dev/null +++ b/theo/app.js @@ -0,0 +1,54 @@ +// Generated by CoffeeScript 1.6.3 +(function() { + var SallyClient, appjs, async, connect, createNewWindow, express, handler, http, sally, stomp_args, + _this = this; + + appjs = require('appjs'); + + async = require("async"); + + http = require('http'); + + express = require('express'); + + connect = require('connect'); + + SallyClient = (require("./sally_client")).SallyClient; + + stomp_args = { + port: 61613, + host: 'localhost', + login: 'webclient', + passcode: 'webclient' + }; + + handler = function(body, msg) { + return console.log(msg); + }; + + sally = new SallyClient(stomp_args, handler); + + sally.connect(["theo"], function(body, msg) { + return console.log("connected "); + }); + + createNewWindow = function(body) { + var window; + window = appjs.createWindow(body.url, { + width: 640, + height: 460 + }); + window.on('create', function() { + window.frame.show(); + return window.frame.center(); + }); + window.on('ready', function() { + window.process = process; + return window.module = module; + }); + return window.on('close', function() { + return console.log("Window Closed"); + }); + }; + +}).call(this); diff --git a/theo/content/index.html b/theo/content/index.html new file mode 100644 index 0000000000000000000000000000000000000000..ef5f9f1c7807149b8a7ff92f8f5bd94d1f5e841e --- /dev/null +++ b/theo/content/index.html @@ -0,0 +1,10 @@ +<!doctype html> +<html> + <head> + <title>Hello World!</title> + <link rel="stylesheet" href="style.css"> + </head> + <body> + <h1>Hello World!</h1> + </body> +</html> diff --git a/theo/npm.sh b/theo/npm.sh new file mode 100755 index 0000000000000000000000000000000000000000..0364840d8b10396e8d6f1921d1e75681870094b6 --- /dev/null +++ b/theo/npm.sh @@ -0,0 +1,2 @@ +#!/bin/bash +node/bin/npm install $1 \ No newline at end of file diff --git a/theo/sally_client.coffee b/theo/sally_client.coffee new file mode 100644 index 0000000000000000000000000000000000000000..e9f8a185df0d5309ffb2df0d6ea0e9adafd0d037 --- /dev/null +++ b/theo/sally_client.coffee @@ -0,0 +1,90 @@ +Stomp = require "stomp" +xml2js = require("xml2js"); +EventEmitter = require('events').EventEmitter +builder = new xml2js.Builder() + +createRegisterDocument = (docQueue, theoQueue, interfaces) -> + { + "registerdocument" : + '$' : + "xmlns" : "http://kwarc.info/sally/comm/core" + "documentqueue" : [ docQueue ], + "environmentid" : [ process.env.SALLYENVID ], + "interfaces" : interfaces + } + +connections = {}; + +class SallyClient + constructor : (@config, @msgHandler) -> + if connections[config.stompUrl]? + @stompClient = connections[config.stompUrl] + else + @stompClient = new Stomp.Stomp(config) + connections[config.stompUrl] = @stompClient + @stompClient.connect() + + @stompClient.on "connected", => + @stompClient.connection_div.emit("onConnected"); + + + registerDocument : (interfaces, callback) => + msg = createRegisterDocument(@privateQueue, @privateQueue+"_theo", interfaces) + @send("/queue/sally_register", msg, (msg) => + @sally_queue = msg["registerdocumentresponse"]["sallyqueue"]; + callback(); + ) + + connect : (@interfaces, callback) -> + client = @stompClient + if client.connected + return callback(); + if not client.connection_div? + client.connection_div = new EventEmitter(); + + client.connection_div.on("onConnected", (e) => + @privateQueue = "theo_"+Math.floor(Math.random()*100000); + @stompClient.subscribe({destination : "/queue/"+@privateQueue}, @stompMsgHandler) + @registerDocument(@interfaces, callback) + ) + + sendSally : (msg, callback, headers) -> + @send(@sally_queue, msg, callback, headers) + + send : (destination, msg, callback, headers) -> + if typeof msg == "object" + msg = builder.buildObject(msg) + + if callback? + corrid = Math.random(); + queue_post = "/temp-queue/editor_exchange"+corrid; + sub = @stompClient.subscribe({destination : queue_post}, (msg) => + xml2js.parseString msg, (err, body) => + if (not body.html?) and callback(body, msg) == true + return; + @stompClient.unsubscribe({destination : queue_post}); + ) + + headers ?= {}; + headers["reply-to"] = queue_post; + headers["correlation-id"] = corrid; + + headers["destination"] = destination; + headers["body"] = msg; + @stompClient.send(headers) + + stompMsgHandler : (msg, msgHeaders) => + msg = msg[0]; + + body = xml2js.parseString msg, (err,body) => + if body["heartbeatrequest"]? and body["heartbeatrequest"]["$"]["xmlns"] == "http://kwarc.info/sally/comm/core" + @send(msgHeaders["reply-to"], {"heartbeatresponse" : {"$" : { "xmlns" : "http://kwarc.info/sally/comm/core"}}}, null, + {"correlation-id" : msgHeaders["correlation-id"]}) + return; + + @msgHandler(body, msg, (sendBack) => + @send(msgHeaders["reply-to"], sendBack, null, + {"correlation-id" : msgHeaders["correlation-id"]}) + ); + +exports.SallyClient = SallyClient \ No newline at end of file diff --git a/theo/sally_client.js b/theo/sally_client.js new file mode 100644 index 0000000000000000000000000000000000000000..280ad82f18348e73998ede61be4bc69579bea8cb --- /dev/null +++ b/theo/sally_client.js @@ -0,0 +1,142 @@ +// Generated by CoffeeScript 1.6.3 +var EventEmitter, SallyClient, Stomp, builder, connections, createRegisterDocument, xml2js, + __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + +Stomp = require("stomp"); + +xml2js = require("xml2js"); + +EventEmitter = require('events').EventEmitter; + +builder = new xml2js.Builder(); + +createRegisterDocument = function(docQueue, theoQueue, interfaces) { + return { + "registerdocument": { + '$': { + "xmlns": "http://kwarc.info/sally/comm/core" + }, + "documentqueue": [docQueue], + "environmentid": [process.env.SALLYENVID], + "interfaces": interfaces + } + }; +}; + +connections = {}; + +SallyClient = (function() { + function SallyClient(config, msgHandler) { + var _this = this; + this.config = config; + this.msgHandler = msgHandler; + this.stompMsgHandler = __bind(this.stompMsgHandler, this); + this.registerDocument = __bind(this.registerDocument, this); + if (connections[config.stompUrl] != null) { + this.stompClient = connections[config.stompUrl]; + } else { + this.stompClient = new Stomp.Stomp(config); + connections[config.stompUrl] = this.stompClient; + this.stompClient.connect(); + this.stompClient.on("connected", function() { + return _this.stompClient.connection_div.emit("onConnected"); + }); + } + } + + SallyClient.prototype.registerDocument = function(interfaces, callback) { + var msg, + _this = this; + msg = createRegisterDocument(this.privateQueue, this.privateQueue + "_theo", interfaces); + return this.send("/queue/sally_register", msg, function(msg) { + _this.sally_queue = msg["registerdocumentresponse"]["sallyqueue"]; + return callback(); + }); + }; + + SallyClient.prototype.connect = function(interfaces, callback) { + var client, + _this = this; + this.interfaces = interfaces; + client = this.stompClient; + if (client.connected) { + return callback(); + } + if (client.connection_div == null) { + client.connection_div = new EventEmitter(); + } + return client.connection_div.on("onConnected", function(e) { + _this.privateQueue = "theo_" + Math.floor(Math.random() * 100000); + _this.stompClient.subscribe({ + destination: "/queue/" + _this.privateQueue + }, _this.stompMsgHandler); + return _this.registerDocument(_this.interfaces, callback); + }); + }; + + SallyClient.prototype.sendSally = function(msg, callback, headers) { + return this.send(this.sally_queue, msg, callback, headers); + }; + + SallyClient.prototype.send = function(destination, msg, callback, headers) { + var corrid, queue_post, sub, + _this = this; + if (typeof msg === "object") { + msg = builder.buildObject(msg); + } + if (callback != null) { + corrid = Math.random(); + queue_post = "/temp-queue/editor_exchange" + corrid; + sub = this.stompClient.subscribe({ + destination: queue_post + }, function(msg) { + return xml2js.parseString(msg, function(err, body) { + if ((body.html == null) && callback(body, msg) === true) { + return; + } + return _this.stompClient.unsubscribe({ + destination: queue_post + }); + }); + }); + if (headers == null) { + headers = {}; + } + headers["reply-to"] = queue_post; + headers["correlation-id"] = corrid; + } + headers["destination"] = destination; + headers["body"] = msg; + return this.stompClient.send(headers); + }; + + SallyClient.prototype.stompMsgHandler = function(msg, msgHeaders) { + var body, + _this = this; + msg = msg[0]; + return body = xml2js.parseString(msg, function(err, body) { + if ((body["heartbeatrequest"] != null) && body["heartbeatrequest"]["$"]["xmlns"] === "http://kwarc.info/sally/comm/core") { + _this.send(msgHeaders["reply-to"], { + "heartbeatresponse": { + "$": { + "xmlns": "http://kwarc.info/sally/comm/core" + } + } + }, null, { + "correlation-id": msgHeaders["correlation-id"] + }); + return; + } + return _this.msgHandler(body, msg, function(sendBack) { + return _this.send(msgHeaders["reply-to"], sendBack, null, { + "correlation-id": msgHeaders["correlation-id"] + }); + }); + }); + }; + + return SallyClient; + +})(); + +exports.SallyClient = SallyClient; diff --git a/theo/start.sh b/theo/start.sh new file mode 100755 index 0000000000000000000000000000000000000000..351fba8186b57ba01a8eae68bd8aa55def592855 --- /dev/null +++ b/theo/start.sh @@ -0,0 +1,2 @@ +coffee -c app.coffee +node/bin/node --harmony app.js \ No newline at end of file diff --git a/utils/src/main/java/info/kwarc/sally4/processors/EnrichMessageProperties.java b/utils/src/main/java/info/kwarc/sally4/processors/EnrichMessageProperties.java index 3e27ff2350556540a095e1acdbcc6cdd7d9f12a8..447a3d2990867c4eba2b3b773eb93e923ac33b32 100644 --- a/utils/src/main/java/info/kwarc/sally4/processors/EnrichMessageProperties.java +++ b/utils/src/main/java/info/kwarc/sally4/processors/EnrichMessageProperties.java @@ -7,6 +7,8 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.slf4j.Logger; +import com.sun.xml.txw2.annotation.XmlNamespace; + public class EnrichMessageProperties implements Processor { static final public String MessageType = "XMLMessageType"; @@ -15,14 +17,15 @@ public class EnrichMessageProperties implements Processor { Logger log; Pattern xmlNamespace = Pattern.compile("<(\\w+)\\s+xmlns=\"([\\w/:.]+)\"/>"); + Pattern xmlNamespace2 = Pattern.compile("<((\\w+):)?(\\w+)\\s+xmlns(:(\\w+))?=\"([\\w/:.]+)\">"); public void process(Exchange exchange) throws Exception { XMLMessageWithTypeInfo result = new XMLMessageWithTypeInfo(); String body = exchange.getIn().getBody(String.class); - Matcher m = xmlNamespace.matcher(body); + Matcher m = xmlNamespace2.matcher(body); if (m.find()) { - String msgType = m.group(1); - String namespace = m.group(2); + String msgType = m.group(3); + String namespace = m.group(6); result.setXmlMessageNamespace(namespace); result.setXmlMessageType(msgType); exchange.getIn().setBody(result); @@ -31,4 +34,13 @@ public class EnrichMessageProperties implements Processor { } } + public static void main(String[] args) { + String t = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ns2:onsallyframe xmlns:ns2=\"http://kwarc.info/sally/comm/select\">"; + Pattern xmlNamespace2 = Pattern.compile(""); + Matcher m = xmlNamespace2.matcher(t); + if (m.find()) { + System.out.println(m.group(3)); + System.out.println(m.group(6)); + } + } }