Discussion:
[jboss-user] [jBPM] - Re: Process Parameters through REST API?
Mai A. S
2012-09-24 09:53:04 UTC
Permalink
Mai A. S [https://community.jboss.org/people/mai.s] created the discussion

"Re: Process Parameters through REST API?"

To view the discussion, visit: https://community.jboss.org/message/761057#761057

--------------------------------------------------------------
Thanks a lot Thomas
I have the same problem
I am beginner at jbpm and I want to try your code
could you please send the functions of requestGetService and authenticate

Thanks a lot and sorry for disturbance.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/761057#761057]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Thomas Setiabudi
2012-10-04 07:52:05 UTC
Permalink
Thomas Setiabudi [https://community.jboss.org/people/thomas.setiabudi] created the discussion

"Re: Process Parameters through REST API?"

To view the discussion, visit: https://community.jboss.org/message/763120#763120

--------------------------------------------------------------
Hi Mai A. S,

Sorry it took so long time to reply, here are the requestGetService and authenticate functions

public String authenticate(String address, String username, String password) {
  String responseString = "";
  List<NameValuePair> formparams = new ArrayList<NameValuePair>();
  formparams.add(new BasicNameValuePair(KEY_USERNAME, username));
  formparams.add(new BasicNameValuePair(KEY_PASSWORD, password));
  HttpPost httpPost = new HttpPost(" http:// http://" + address
    + "/gwt-console-server/rs/process/j_security_check");
  InputStreamReader inputStreamReader = null;
  BufferedReader bufferedReader = null;
  try {
   UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formparams,
     "UTF-8");// UrlEncodedFormEntity(formparams,
        // "multipart/form-data");
   httpPost.setEntity(entity);
   HttpResponse response = httpClient.execute(httpPost);
   InputStream inputStream = response.getEntity().getContent();
   inputStreamReader = new InputStreamReader(inputStream);
   bufferedReader = new BufferedReader(inputStreamReader);
   StringBuilder stringBuilder = new StringBuilder();
   String line = bufferedReader.readLine();
   while (line != null) {
    stringBuilder.append(line);
    line = bufferedReader.readLine();
   }
   responseString = stringBuilder.toString();
  } catch (Exception e) {
   throw new RuntimeException(e);
  } finally {
   if (inputStreamReader != null) {
    try {
     inputStreamReader.close();
    } catch (Exception e) {
     throw new RuntimeException(e);
    }
   }
   if (bufferedReader != null) {
    try {
     bufferedReader.close();
    } catch (Exception e) {
     throw new RuntimeException(e);
    }
   }
  }
  return responseString;
}

public String requestGetService(String url, Map<String, Object> parameters,
   boolean multipart) {
  String responseString = "";
  MultipartEntity multiPartEntity = new MultipartEntity(
    HttpMultipartMode.BROWSER_COMPATIBLE);
  List<NameValuePair> formparams = new ArrayList<NameValuePair>();
  if (parameters == null) {
   parameters = new HashMap<String, Object>();
  }
  Set<String> keys = parameters.keySet();
  for (Iterator<String> keysIterator = keys.iterator(); keysIterator
    .hasNext();) {
   String keyString = keysIterator.next();
   String value = parameters.get(keyString).toString();
   formparams.add(new BasicNameValuePair(keyString, value));
   if (multipart) {
    try {
     StringBody stringBody = new StringBody(value, "text/plain",
       Charset.forName("UTF-8"));
     multiPartEntity
       .addPart(keyString, (ContentBody) stringBody);
    } catch (Exception e) {
     throw new RuntimeException(e);
    }
   }
  }
  HttpGet httpPost = new HttpGet(url);
  InputStreamReader inputStreamReader = null;
  BufferedReader bufferedReader = null;
  try {
   if (multipart) {
    // httpPost.setEntity(multiPartEntity);
   } else {
    // UrlEncodedFormEntity entity = new UrlEncodedFormEntity(
    // formparams, "UTF-8");// UrlEncodedFormEntity(formparams,
    // "multipart/form-data");
    // httpPost.setEntity(entity);
   }
   HttpResponse response = httpClient.execute(httpPost);
   InputStream inputStream = response.getEntity().getContent();
   inputStreamReader = new InputStreamReader(inputStream);
   bufferedReader = new BufferedReader(inputStreamReader);
   StringBuilder stringBuilder = new StringBuilder();
   String line = bufferedReader.readLine();
   while (line != null) {
    stringBuilder.append(line);
    line = bufferedReader.readLine();
   }
   responseString = stringBuilder.toString();
  } catch (Exception e) {
   throw new RuntimeException(e);
  } finally {
   if (inputStreamReader != null) {
    try {
     inputStreamReader.close();
    } catch (Exception e) {
     throw new RuntimeException(e);
    }
   }
   if (bufferedReader != null) {
    try {
     bufferedReader.close();
    } catch (Exception e) {
     throw new RuntimeException(e);
    }
   }
  }
  return responseString;
}



--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/763120#763120]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
satish babu
2012-12-07 06:19:27 UTC
Permalink
satish babu [https://community.jboss.org/people/satish549] created the discussion

"Re: Process Parameters through REST API?"

To view the discussion, visit: https://community.jboss.org/message/780562#780562

--------------------------------------------------------------
Hi Thomas,

I am trying with ur code to pass parameters to the process

Rnder URL working fine.

" http://localhost:8080/gwt-console-server/rs/form/process/ http://localhost:8080/gwt-console-server/rs/form/process/{id}/render"

when i am hitting the Authentication URL it is showing the problem like this

The time allowed for the login process has been exceeded. If you wish to continue you must either click back twice and re-click the link you requested or close and re-open your browser

Following is the console Log

<html><head><title>Apache Tomcat/6.0.35 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 408 - The time allowed for the login process has been exceeded. If you wish to continue you must either click back twice and re-click the link you requested or close and re-open your browser</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>The time allowed for the login process has been exceeded. If you wish to continue you must either click back twice and re-click the link you requested or close and re-open your browser</u></p><p><b>description</b> <u>The client did not produce a request within the time that the server was prepared to wait (The time allowed for the login process has been exceeded. If you wish to continue you must either click back twice and re-click the link you requested or close and re-open your browser).</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.35</h3></body></html>


My Authendication URL is

" http://localhost:8080/gwt-console-server/rs/identity/secure/j_security_check http://localhost:8080/gwt-console-server/rs/identity/secure/j_security_check"

Can u help on this.

Regards
Satish
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/780562#780562]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Benjamin Wirtz
2013-01-21 16:34:39 UTC
Permalink
Benjamin Wirtz [https://community.jboss.org/people/bennixview] created the discussion

"Re: Process Parameters through REST API?"

To view the discussion, visit: https://community.jboss.org/message/793290#793290

--------------------------------------------------------------
I have got the following error (HTTP Status 415 - Cannot consume content type):

<html><head><title>JBoss Web/7.0.17.Final - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 415 - Cannot consume content type</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>Cannot consume content type</u></p><p><b>description</b> <u>The server refused this request because the request entity is in a format not supported by the requested resource for the requested method (Cannot consume content type).</u></p><HR size="1" noshade="noshade"><h3>JBoss Web/7.0.17.Final</h3></body></html>

Any suggestion?
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/793290#793290]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Thomas Setiabudi
2013-01-22 01:45:46 UTC
Permalink
Thomas Setiabudi [https://community.jboss.org/people/thomas.setiabudi] created the discussion

"Re: Process Parameters through REST API?"

To view the discussion, visit: https://community.jboss.org/message/793378#793378

--------------------------------------------------------------
HI Benjamin Wirtz,

What version of JBPM5 are you using?

Maybe its better to make a new forum post about this?

Regards,
Thomas Setiabudi
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/793378#793378]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Benjamin Wirtz
2013-01-24 17:22:06 UTC
Permalink
Benjamin Wirtz [https://community.jboss.org/people/bennixview] created the discussion

"Re: Process Parameters through REST API?"

To view the discussion, visit: https://community.jboss.org/message/794129#794129

--------------------------------------------------------------
JBoss 7.1.3. / jbpm 5.4
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/794129#794129]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Loading...