use of us.monoid.json.JSONException in project tdi-studio-se by Talend.
the class ExchangeWebService method searchLastRevisionForExtensionService.
/**
*
* DOC hcyi Comment method "searchLastRevisionForExtensionService".
*
* @param idExtension
* @param username
* @param passwordHash
* @return
*/
public static WebserviceStatus searchLastRevisionForExtensionService(String idExtension, String username, String passwordHash) {
WebserviceStatus ws = new WebserviceStatus();
ws.setResult(false);
JSONObject tokenMessage = new JSONObject();
try {
tokenMessage.put("username", username);
tokenMessage.put("passwordHash", passwordHash);
tokenMessage.put("idExtension", idExtension);
JSONObject token = new us.monoid.json.JSONObject();
token.put("extension", tokenMessage);
String u = exchangeWSServer + "modifyExtension.php?data=" + token;
JSONObject answer = readJsonFromUrl(u);
if (answer != null) {
Object object = answer.get("lastRevision");
if (object != null && !object.equals("")) {
ws.setValue(object.toString());
ws.setResult(true);
}
}
} 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.JSONException in project tdi-studio-se by Talend.
the class ExchangeWebService method searchContributedExtensionJSONArray.
/**
*
* DOC hcyi Comment method "searchContributedExtensionJSONArray".
*
* @return
*/
public static JSONArray searchContributedExtensionJSONArray(String username, String passwordHash) {
JSONObject tokenMessage = new JSONObject();
JSONArray o = null;
try {
tokenMessage.put("username", username);
tokenMessage.put("passwordHash", passwordHash);
JSONObject token = new us.monoid.json.JSONObject();
token.put("contributedExtension", tokenMessage);
String u = exchangeWSServer + "contributedExtension.php?data=" + token;
JSONObject answer = readJsonFromUrl(u);
if (answer != null) {
JSONObject p = (JSONObject) answer.get("listContributedExtension");
o = p.getJSONArray("extensions");
}
} catch (JSONException e) {
//
} catch (IOException e) {
e.printStackTrace();
}
return o;
}
use of us.monoid.json.JSONException 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.JSONException 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.JSONException in project tdi-studio-se by Talend.
the class TosTokenCollector method collectProjectDetails.
private JSONObject collectProjectDetails() throws PersistenceException, JSONException {
JSONObject jObject = new JSONObject();
Project currentProject = ProjectManager.getInstance().getCurrentProject();
final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
JSONObject repoStats = new JSONObject();
// metadata
for (DynaEnum type : ERepositoryObjectType.values()) {
if (type instanceof ERepositoryObjectType && ((ERepositoryObjectType) type).isResourceItem()) {
try {
List<IRepositoryViewObject> all = factory.getAll(currentProject, (ERepositoryObjectType) type);
int nb = all.size();
if (ERepositoryObjectType.TDQ_INDICATOR_ELEMENT.equals(type) || ERepositoryObjectType.TDQ_PATTERN_ELEMENT.equals(type) || ERepositoryObjectType.TDQ_RULES.equals(type) || "TDQ_SOURCE_FILE_ELEMENT".equals(type.getType())) {
//$NON-NLS-1$
continue;
}
if (ERepositoryObjectType.ROUTINES.equals(type)) {
nb = 0;
List<IRepositoryViewObject> newList = new ArrayList<IRepositoryViewObject>();
for (IRepositoryViewObject object : all) {
RoutineItem rItem = (RoutineItem) object.getProperty().getItem();
if (!rItem.isBuiltIn()) {
nb++;
newList.add(object);
}
}
all = newList;
}
if (ERepositoryObjectType.SQLPATTERNS.equals(type)) {
nb = 0;
for (IRepositoryViewObject object : all) {
SQLPatternItem spItem = (SQLPatternItem) object.getProperty().getItem();
if (!spItem.isSystem()) {
nb++;
}
}
}
if ("MDM.DataModel".equals(type.getType())) {
//$NON-NLS-1$
nb = 0;
for (IRepositoryViewObject object : all) {
String path = object.getProperty().getItem().getState().getPath();
if (!"System".equals(path)) {
//$NON-NLS-1$
nb++;
}
}
}
if (nb > 0) {
JSONObject typeStats = new JSONObject();
//$NON-NLS-1$
typeStats.put("nb", nb);
if (ERepositoryObjectType.getAllTypesOfProcess().contains(type)) {
JSONObject jobDetails = new JSONObject();
collectJobDetails(all, jobDetails);
//$NON-NLS-1$
typeStats.put("details", jobDetails);
}
if (ERepositoryObjectType.ROUTINES.equals(type) || //$NON-NLS-1$
((ERepositoryObjectType) type).getFolder().startsWith("metadata/") || ERepositoryObjectType.CONTEXT.equals(type) || type.equals(ERepositoryObjectType.JOBLET)) {
int nbUsed = 0;
for (IRepositoryViewObject object : all) {
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsHaveRelationWith(object.getId());
relations.addAll(RelationshipItemBuilder.getInstance().getItemsHaveRelationWith(object.getLabel()));
if (relations.size() > 0) {
nbUsed++;
}
}
//$NON-NLS-1$
typeStats.put("nb.used", nbUsed);
}
if (ERepositoryObjectType.METADATA_CONNECTIONS.equals(type)) {
JSONObject objects = new JSONObject();
for (IRepositoryViewObject object : all) {
DatabaseConnectionItem item = (DatabaseConnectionItem) object.getProperty().getItem();
String dbType = ((DatabaseConnection) item.getConnection()).getDatabaseType();
int nbDbTypes = 1;
if (objects.has(dbType)) {
nbDbTypes = objects.getInt(dbType);
nbDbTypes++;
}
objects.put(dbType, nbDbTypes);
}
//$NON-NLS-1$
typeStats.put("types", objects);
}
repoStats.put(type.getType(), typeStats);
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
//$NON-NLS-1$
jObject.put(PROJECTS.getKey(), repoStats);
jObject.put(TYPE.getKey(), ProjectManager.getInstance().getProjectType(currentProject));
int nbRef = ProjectManager.getInstance().getAllReferencedProjects().size();
if (nbRef > 0) {
jObject.put("nb.refProjects", nbRef);
}
return jObject;
}
Aggregations