use of us.monoid.json.JSONObject in project tdi-studio-se by Talend.
the class ResetVMArgumentMigrationTask method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
ParametersType parameters = processType.getParameters();
if (parameters == null) {
return ExecutionResult.NOTHING_TO_DO;
}
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
EList listParamType = parameters.getElementParameter();
for (int j = 0; j < listParamType.size(); j++) {
ElementParameterType pType = (ElementParameterType) listParamType.get(j);
if (pType.getName().equals("JOB_RUN_VM_ARGUMENTS")) {
//$NON-NLS-1$
String value = pType.getValue().trim();
if (value != null && value.length() > 0 && !isJson(value)) {
try {
JSONObject root = new JSONObject();
JSONArray args = new JSONArray();
//$NON-NLS-1$
String[] vms = value.split(" ");
for (String vm : vms) {
args.put(vm);
}
//$NON-NLS-1$
root.put("JOB_RUN_VM_ARGUMENTS", args);
pType.setValue(root.toString());
factory.save(item, true);
break;
} catch (JSONException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
}
return ExecutionResult.SUCCESS_WITH_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
use of us.monoid.json.JSONObject in project tdi-studio-se by Talend.
the class ExchangeService method checkUserAndPass.
@Override
public String checkUserAndPass(String username, String password) {
String errorMessage = "Wrong user or password";
if (username == null || "".equals(username) || password == null || "".equals(password)) {
return errorMessage;
}
JSONObject tokenMessage = new JSONObject();
try {
tokenMessage.put("username", username);
tokenMessage.put("passwordHash", password);
JSONObject token = new us.monoid.json.JSONObject();
token.put("contributedExtension", tokenMessage);
String u = ExchangeWebService.exchangeWSServer + "contributedExtension.php?data=" + token;
JSONObject answer = ExchangeWebService.readJsonFromUrl(u);
if (answer != null && answer.get("result") != null && answer.get("result").equals("ERROR USERNAME/PASSWORD")) {
return errorMessage;
}
} catch (JSONException e) {
// if there is no result , user and pass are right and can list the extensions
return null;
} catch (IOException e) {
return errorMessage;
}
return null;
}
use of us.monoid.json.JSONObject in project tdi-studio-se by Talend.
the class ExchangeWebService method searchExtensionJSONArray.
/**
*
* DOC hcyi Comment method "searchExtensionJSONArray".
*
* @return
*/
public static JSONArray searchExtensionJSONArray(String typeExtension, String versionStudio, String category) {
JSONObject tokenMessage = new JSONObject();
JSONArray o = null;
try {
tokenMessage.put("typeExtension", typeExtension);
tokenMessage.put("versionStudio", versionStudio);
tokenMessage.put("search", category);
JSONObject token = new us.monoid.json.JSONObject();
token.put("searchExtension", tokenMessage);
String u = exchangeWSServer + "availableExtension.php?data=" + token;
JSONObject answer = readJsonFromUrl(u);
if (answer != null) {
JSONObject p = (JSONObject) answer.get("resultSearch");
o = p.getJSONArray("extensions");
}
} catch (JSONException e) {
//
} catch (IOException e) {
e.printStackTrace();
}
return o;
}
use of us.monoid.json.JSONObject in project tdi-studio-se by Talend.
the class ExchangeWebService method webServiceToken.
public void webServiceToken(String[] args) {
Resty r = new Resty();
JSONObject token = new us.monoid.json.JSONObject();
try {
JSONObject tokenMessage = new JSONObject();
tokenMessage.put("version", "4.2.2r56343");
tokenMessage.put("uniqueId", "XXXXXX");
tokenMessage.put("typeStudio", "TOS");
JSONObject properties = new JSONObject();
properties.put("tos.count.localprojects", "10");
properties.put("tos.count.jobs", "48");
properties.put("tos.count.jobsperproject", "5");
// ... //
tokenMessage.put("properties", properties);
token.put("tokenStudio", tokenMessage);
AbstractContent ac = Resty.content(token);
MultipartContent mpc = Resty.form(new FormData("data", ac));
TextResource result = r.text("http://www.talend.com/TalendRegisterWS/tokenstudio.php", mpc);
System.out.println(result.toString());
} catch (JSONException e) {
//
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
use of us.monoid.json.JSONObject in project tdi-studio-se by Talend.
the class ExchangeWebService method searchExtensionViewDetail.
public static JSONObject searchExtensionViewDetail(String idExtension, String typeExtension) {
Resty r = new Resty();
JSONObject token = new us.monoid.json.JSONObject();
JSONObject extension = new us.monoid.json.JSONObject();
try {
JSONObject tokenMessage = new JSONObject();
tokenMessage.put("typeExtension", typeExtension);
tokenMessage.put("idExtension", idExtension);
token.put("viewDetail", tokenMessage);
AbstractContent ac = Resty.content(token);
MultipartContent mpc = Resty.form(new FormData("data", ac));
TextResource result = r.text(exchangeWSServer + "availableExtension.php", mpc);
JSONObject jbo = new JSONObject(result.toString());
JSONObject resultViewDetail = jbo.getJSONObject("resultViewDetail");
extension = resultViewDetail.getJSONObject("extension");
} catch (JSONException e) {
//
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return extension;
}
Aggregations