use of com.netsteadfast.greenstep.vo.SysExprJobLogVO in project bamboobsc by billchen198318.
the class SystemExpressionJobUtils method executeJobForManualFromRestServiceUrl.
public static SysExprJobLogVO executeJobForManualFromRestServiceUrl(SysExprJobVO sysExprJob, String accountId, HttpServletRequest request) throws ServiceException, Exception {
SysExprJobLogVO result = new SysExprJobLogVO();
// 注意 executeJob/ 請參考 ManualJobServiceImpl.java @Path("/executeJob/") 設定是否有變更, 如果有變更的話, 這裡的 url 也要修改
String url = ApplicationSiteUtils.getBasePath(sysExprJob.getSystem(), request);
if (!url.endsWith("/")) {
url += "/";
}
//url += "services/jaxrs/executeJob/";
url += Constants.getCxfWebServiceMainPathName() + Constants.getJAXRSServerFactoryBeanAddress() + "executeJob/";
String encUploadOidStr = SystemExpressionJobUtils.getEncUploadOid(accountId, sysExprJob.getOid());
url += encUploadOidStr;
InputStreamReader isr = null;
BufferedReader reader = null;
try {
HttpClient httpClient = new HttpClient();
PostMethod post = new PostMethod(url);
/*
NameValuePair[] data = {
new NameValuePair("uploadOid", encUploadOidStr)
};
post.setRequestBody(data);
*/
post.setParameter("uploadOid", encUploadOidStr);
int statusCode = httpClient.executeMethod(post);
if (statusCode != 200 && statusCode != 202) {
throw new Exception("error, http status code: " + statusCode);
}
isr = new InputStreamReader(post.getResponseBodyAsStream());
reader = new BufferedReader(isr);
String line = "";
StringBuilder str = new StringBuilder();
while ((line = reader.readLine()) != null) {
str.append(line);
}
ObjectMapper mapper = new ObjectMapper();
result = mapper.readValue(str.toString(), SysExprJobLogVO.class);
} catch (IOException e) {
e.printStackTrace();
result.setFaultMsg(e.getMessage().toString());
} catch (Exception e) {
e.printStackTrace();
result.setFaultMsg(e.getMessage().toString());
} finally {
if (reader != null) {
reader.close();
}
if (isr != null) {
isr.close();
}
reader = null;
isr = null;
}
return result;
}
use of com.netsteadfast.greenstep.vo.SysExprJobLogVO in project bamboobsc by billchen198318.
the class SystemExpressionJobUtils method executeJobForManualWebClient.
public static SysExprJobLogVO executeJobForManualWebClient(SysExprJobVO sysExprJob, String accountId, HttpServletRequest request) throws ServiceException, Exception {
SysExprJobLogVO result = new SysExprJobLogVO();
// 注意 executeJob/ 請參考 ManualJobServiceImpl.java @Path("/executeJob/") 設定是否有變更, 如果有變更的話, 這裡的 url 也要修改
String url = ApplicationSiteUtils.getBasePath(sysExprJob.getSystem(), request);
if (!url.endsWith("/")) {
url += "/";
}
//url += "services/jaxrs/";
url += Constants.getCxfWebServiceMainPathName() + Constants.getJAXRSServerFactoryBeanAddress();
String encUploadOidStr = SystemExpressionJobUtils.getEncUploadOid(accountId, sysExprJob.getOid());
WebClient client = WebClient.create(url);
Response response = client.accept("application/json").path("executeJob/{uploadOid}", encUploadOidStr).post(encUploadOidStr);
int statusCode = response.getStatus();
if (statusCode != 200 && statusCode != 202) {
throw new Exception("error, http status code: " + statusCode);
}
String responseStr = response.readEntity(String.class);
ObjectMapper mapper = new ObjectMapper();
result = mapper.readValue(responseStr, SysExprJobLogVO.class);
return result;
}
Aggregations