Skip to content

Commit

Permalink
BZ-1057749 - REST API : /task/{taskId}/content returns null content
Browse files Browse the repository at this point in the history
(cherry picked from commit 96f4b40)
  • Loading branch information
Marco Rietveld committed Feb 4, 2014
1 parent 97391f5 commit 8e94711
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
package org.kie.services.client.api;

import java.net.URL;
import java.util.Collection;
import java.util.HashSet;
import java.util.Properties;

import javax.jms.ConnectionFactory;
import javax.jms.Queue;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.kie.services.client.api.command.RemoteConfiguration;
import org.kie.services.client.api.command.RemoteRuntimeEngine;

public class RemoteJmsRuntimeEngineFactory implements RemoteRuntimeEngineFactory {

private RemoteConfiguration config;

public RemoteJmsRuntimeEngineFactory(String deploymentId, ConnectionFactory connectionFactory, Queue ksessionQueue, Queue taskQueue, Queue responseQueue) {
this.config = new RemoteConfiguration(deploymentId, connectionFactory, ksessionQueue, taskQueue, responseQueue);
}

public RemoteJmsRuntimeEngineFactory(String deploymentId, URL hostUrl, String userName, String password) {
InitialContext context = getRemoteJbossInitialContext(hostUrl, userName, password);
this.config = new RemoteConfiguration(deploymentId, context);
}

public RemoteJmsRuntimeEngineFactory(String deploymentId, InitialContext context) {
this.config = new RemoteConfiguration(deploymentId, context);
}
Expand All @@ -40,22 +48,29 @@ public RemoteJmsRuntimeEngineFactory(String deploymentId, InitialContext context
this.config.setQualityOfServiceThresholdMilliSeconds(qualityofServiceThresholdMillisecs);
}

public RemoteJmsRuntimeEngineFactory(String deploymentId, ConnectionFactory connectionFactory, Queue ksessionQueue, Queue taskQueue, Queue responseQueue, String username, String password, int qualityOfServiceThresholdMillisecs, int serializationType) {
this.config = new RemoteConfiguration(deploymentId, connectionFactory, ksessionQueue, taskQueue, responseQueue, username, password);
this.config.setQualityOfServiceThresholdMilliSeconds(qualityOfServiceThresholdMillisecs);
this.config.setSerializationType(serializationType);
}

public RemoteJmsRuntimeEngineFactory(String deploymentId, InitialContext context, String username, String password, int qualityofServiceThresholdMillisecs, int serialization) {
this.config = new RemoteConfiguration(deploymentId, context, username, password);
this.config.setQualityOfServiceThresholdMilliSeconds(qualityofServiceThresholdMillisecs);
this.config.setSerializationType(serialization);
public static InitialContext getRemoteJbossInitialContext(URL url, String user, String password) {
Properties initialProps = new Properties();
initialProps.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
String jbossServerHostName = url.getHost();
initialProps.setProperty(InitialContext.PROVIDER_URL, "remote://"+ jbossServerHostName + ":4447");
initialProps.setProperty(InitialContext.SECURITY_PRINCIPAL, user);
initialProps.setProperty(InitialContext.SECURITY_CREDENTIALS, password);

for (Object keyObj : initialProps.keySet()) {
String key = (String) keyObj;
System.setProperty(key, (String) initialProps.get(key));
}
try {
return new InitialContext(initialProps);
} catch (NamingException e) {
throw new RuntimeException("Unable to create " + InitialContext.class.getSimpleName(), e);
}
}

public RemoteRuntimeEngine newRuntimeEngine() {
return new RemoteRuntimeEngine(config);
}

public void addExtraJaxbClasses(Collection<Class<?>> extraJaxbClasses ) {
this.config.addJaxbClasses(new HashSet<Class<?>>(extraJaxbClasses));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public Response taskId_content(@PathParam("taskId") long taskId) {
result = processRequestBean.doTaskOperationAndSerializeResult(
cmd,
"Unable get content " + contentId + " (from task " + taskId + ")");
content = (JaxbContent) content;
content = (JaxbContent) result;
}
return createCorrectVariant(content, headers);
}
Expand Down

0 comments on commit 8e94711

Please sign in to comment.