use of us.monoid.json.JSONObject in project tdi-studio-se by Talend.
the class ExchangeWebService method downloadingExtensionService.
/**
*
* DOC hcyi Comment method "downloadingExtensionService".
*
* @param idExtension
* @param typeExtension
* @param username
* @param passwordHash
* @return
*/
public static WebserviceStatus downloadingExtensionService(String idExtension, String typeExtension, String username, String passwordHash) {
WebserviceStatus ws = new WebserviceStatus();
ws.setResult(false);
JSONObject tokenMessage = new JSONObject();
try {
tokenMessage.put("typeExtension", typeExtension);
tokenMessage.put("idExtension", idExtension);
tokenMessage.put("username", username);
tokenMessage.put("passwordHash", passwordHash);
JSONObject token = new us.monoid.json.JSONObject();
token.put("downloadedExtension", tokenMessage);
String u = exchangeWSServer + "downloadedExtension.php?data=" + token;
JSONObject answer = readJsonFromUrl(u);
if (answer != null) {
JSONObject resultObj = (JSONObject) answer.get("resultDownloadExtension");
String linkDownload = resultObj.getString("linkDownload");
//
ws.setValue(linkDownload);
ws.setResult(true);
//$NON-NLS-1$
ws.setMessageException(Messages.getString("ExchangeWebService.downloadingExtensionSuccessful"));
}
} catch (JSONException e) {
//
ws.setMessageException(e.getMessage());
} catch (IOException e) {
e.printStackTrace();
ws.setMessageException(e.getMessage());
} catch (Exception e) {
e.printStackTrace();
ws.setMessageException(e.getMessage());
}
return ws;
}
use of us.monoid.json.JSONObject in project tdi-studio-se by Talend.
the class RunProcessTokenCollector method collect.
/* (non-Javadoc)
* @see org.talend.core.ui.token.AbstractTokenCollector#collect()
*/
@Override
public JSONObject collect() throws Exception {
JSONObject object = new JSONObject();
IPreferenceStore preferenceStore = RunProcessPlugin.getDefault().getPreferenceStore();
int numRun = preferenceStore.getInt(TOS_COUNT_RUNS.getPrefKey());
object.put(TOS_COUNT_RUNS.getKey(), numRun);
int numDebugRun = preferenceStore.getInt(TOS_COUNT_DEBUG_RUNS.getPrefKey());
object.put(TOS_COUNT_DEBUG_RUNS.getKey(), numDebugRun);
return object;
}
use of us.monoid.json.JSONObject in project tdi-studio-se by Talend.
the class ComponentSearcher method getContributedExtensions.
/**
* Find Contributed components.
*
* @param version The tos version.
* @param language The project language.
* @return
*/
public static List<ComponentExtension> getContributedExtensions(String version, ECodeLanguage language, String username, String passwordHash) {
List<ComponentExtension> extensions = new ArrayList<ComponentExtension>();
try {
JSONArray extensionsJSONArray = ExchangeWebService.searchContributedExtensionJSONArray(username, passwordHash);
if (extensionsJSONArray != null) {
int size = extensionsJSONArray.length();
for (int i = 0; i < size; i++) {
JSONObject extensionObj = extensionsJSONArray.getJSONObject(i);
Map<String, ComponentExtension> extensionsMap = new HashMap<String, ComponentExtension>();
ComponentExtension extension = extensionsMap.get(extensionObj.getString("name"));
if (extension == null) {
extension = ExchangeFactory.eINSTANCE.createComponentExtension();
//
extension.setIdExtension(extensionObj.getString("idExtension"));
extension.setTypeExtension(extensionObj.getString("typeExtension"));
extension.setLabel(extensionObj.getString("name"));
if (extensionObj.getString("dateExtension") != null && !"".equals(extensionObj.getString("dateExtension"))) {
extension.setPublicationDate(formatter.parse(extensionObj.getString("dateExtension")));
} else {
extension.setPublicationDate(formatter.parse(formatter.format(new Date())));
}
extension.setLastVersionAvailable(extensionObj.getString("lastVersion"));
extensionsMap.put(extension.getIdExtension(), extension);
extensions.add(extension);
}
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
return extensions;
}
use of us.monoid.json.JSONObject in project tdi-studio-se by Talend.
the class JobVMArgumentsUtil method readString.
public List<String> readString(String stringList) {
if (stringList == null || "".equals(stringList)) {
//$NON-NLS-1$
return EMPTY_STRING_LIST;
}
ArrayList<String> result = new ArrayList<String>(50);
try {
JSONObject root = new JSONObject(stringList);
//$NON-NLS-1$
Object obj = root.get("JOB_RUN_VM_ARGUMENTS");
if (obj != null && (obj instanceof JSONArray)) {
JSONArray array = (JSONArray) obj;
for (int i = 0; i < array.length(); i++) {
result.add((String) array.get(i));
}
}
} catch (JSONException e) {
ExceptionHandler.process(e);
}
return result;
}
use of us.monoid.json.JSONObject in project tdi-studio-se by Talend.
the class TosTokenCollector method priorCollect.
@Override
public void priorCollect() throws Exception {
// for all projects
JSONObject allProjectRecords = null;
IPreferenceStore preferenceStore = RepositoryPlugin.getDefault().getPreferenceStore();
String records = preferenceStore.getString(PREF_TOS_JOBS_RECORDS);
try {
// reset
allProjectRecords = new JSONObject(records);
} catch (Exception e) {
// the value is not set, or is empty
allProjectRecords = new JSONObject();
}
JSONObject currentProjectObject = collectProjectDetails();
Project currentProject = ProjectManager.getInstance().getCurrentProject();
allProjectRecords.put(currentProject.getTechnicalLabel(), currentProjectObject);
//
preferenceStore.setValue(PREF_TOS_JOBS_RECORDS, allProjectRecords.toString());
}
Aggregations