use of us.monoid.json.JSONArray in project tdi-studio-se by Talend.
the class JobVMArgumentsUtil method writeString.
public String writeString(List<String> items) {
JSONObject root = new JSONObject();
JSONArray args = new JSONArray();
int size = items.size();
for (int i = 0; i < size; i++) {
String vm = items.get(i).trim();
args.put(vm);
}
try {
//$NON-NLS-1$
root.put("JOB_RUN_VM_ARGUMENTS", args);
} catch (JSONException e) {
ExceptionHandler.process(e);
}
return root.toString();
}
use of us.monoid.json.JSONArray in project tdi-studio-se by Talend.
the class RunProcessPreferenceInitializer method defaultVM.
private String defaultVM() {
JSONObject root = new JSONObject();
try {
JSONArray args = new JSONArray();
//$NON-NLS-1$
args.put("-Xms256M");
//$NON-NLS-1$
args.put("-Xmx1024M");
//$NON-NLS-1$
root.put("JOB_RUN_VM_ARGUMENTS", args);
} catch (JSONException e) {
ExceptionHandler.process(e);
}
return root.toString();
}
use of us.monoid.json.JSONArray 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.JSONArray 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.JSONArray in project tdi-studio-se by Talend.
the class ExchangeWebService method searchCategoryExtensionJSONArray.
/**
*
* DOC hcyi Comment method "searchCategoryExtensionJSONArray".
*
* @param typeExtension
* @return
*/
public static List<Category> searchCategoryExtensionJSONArray(String typeExtension) {
List<Category> fCategorys = new ArrayList<Category>();
JSONObject tokenMessage = new JSONObject();
try {
tokenMessage.put("typeExtension", typeExtension);
JSONObject token = new us.monoid.json.JSONObject();
token.put("extension", tokenMessage);
String u = exchangeWSServer + "listCategoryExtension.php?data=" + token;
JSONObject resultObj = readJsonFromUrl(u);
if (resultObj != null) {
JSONObject p = (JSONObject) resultObj.get("listCategory");
JSONArray resultArry = p.getJSONArray("category");
if (resultArry != null) {
for (int i = 0; i < resultArry.length(); i++) {
JSONObject extensionObj = resultArry.getJSONObject(i);
if (extensionObj != null) {
Category fCategory = ExchangeFactory.eINSTANCE.createCategory();
fCategory.setCategoryId(extensionObj.getString("id_category"));
fCategory.setCategoryName(extensionObj.getString("name"));
fCategorys.add(fCategory);
}
}
}
}
} catch (JSONException e) {
//
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return fCategorys;
}
Aggregations