use of us.monoid.web.AbstractContent 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.web.AbstractContent 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;
}
use of us.monoid.web.AbstractContent in project tdi-studio-se by Talend.
the class ExchangeWebService method insertReviewService.
/**
*
* DOC hcyi Comment method "insertReviewService".
*
* @param idExtension
* @param typeExtension
* @param username
* @param passwordHash
* @param title
* @param description
* @param userRating
* @return
*/
public static WebserviceStatus insertReviewService(String idExtension, String typeExtension, String username, String passwordHash, String title, String description, String userRating) {
WebserviceStatus ws = new WebserviceStatus();
ws.setResult(false);
Resty r = new Resty();
JSONObject tokenMessage = new JSONObject();
try {
tokenMessage.put("typeExtension", typeExtension);
tokenMessage.put("idExtension", idExtension);
tokenMessage.put("username", username);
tokenMessage.put("passwordHash", passwordHash);
tokenMessage.put("title", title);
tokenMessage.put("description", description);
tokenMessage.put("userRating", userRating);
JSONObject token = new us.monoid.json.JSONObject();
token.put("review", tokenMessage);
AbstractContent ac = Resty.content(token);
MultipartContent mpc = Resty.form(new FormData("data", ac));
TextResource textResult = r.text(exchangeWSServer + "downloadedExtension.php", mpc);
JSONObject resultObject = new JSONObject(textResult.toString());
//
Object object = resultObject.get("result");
if (object != null && object.equals("INSERT OK")) {
ws.setResult(true);
//$NON-NLS-1$
ws.setMessageException(Messages.getString("ExchangeWebService.insertReviewSuccessful"));
} else {
ws.setMessageException(object.toString());
}
} 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.web.AbstractContent in project tdi-studio-se by Talend.
the class ExchangeWebService method insertionExtensionService.
/**
*
* DOC hcyi Comment method "insertionExtensionService".
*
* @param typeExtension
* @param username
* @param passwordHash
* @param category
* @param name
* @param description
* @return
*/
public static WebserviceStatus insertionExtensionService(String typeExtension, String username, String passwordHash, String category, String name, String description) {
WebserviceStatus ws = new WebserviceStatus();
ws.setResult(false);
Resty r = new Resty();
JSONObject tokenMessage = new JSONObject();
try {
tokenMessage.put("username", username);
tokenMessage.put("passwordHash", passwordHash);
tokenMessage.put("typeExtension", typeExtension);
tokenMessage.put("category", category);
tokenMessage.put("name", name);
tokenMessage.put("description", description);
JSONObject token = new us.monoid.json.JSONObject();
token.put("newExtension", tokenMessage);
AbstractContent ac = Resty.content(token);
MultipartContent mpc = Resty.form(new FormData("data", ac));
TextResource textResult = r.text(exchangeWSServer + "publishExtension.php", mpc);
JSONObject resultObject = new JSONObject(textResult.toString());
JSONObject object = (JSONObject) resultObject.get("resultNewExtension");
String idExtension = object.getString("idExtension");
//
ws.setValue(idExtension);
ws.setResult(true);
//$NON-NLS-1$
ws.setMessageException(Messages.getString("ExchangeWebService.insertionExtensionSuccessful"));
} 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.web.AbstractContent in project tdi-studio-se by Talend.
the class ExchangeWebService method insertionRevisionService.
/**
*
* DOC hcyi Comment method "insertionRevisionService".
*
* @param idExtension
* @param typeExtension
* @param username
* @param passwordHash
* @param version
* @param listVersionCompatibles
* @param filename
* @param content
* @param description
* @param agreement
* @return
*/
public static WebserviceStatus insertionRevisionService(String idExtension, String typeExtension, String username, String passwordHash, String version, String listVersionCompatibles, String filename, String content, String description, String agreement) {
byte[] fileBytes = null;
try {
File f = new File(filename);
if (f != null) {
FileInputStream fis = new FileInputStream(f);
if (fis != null) {
int len = fis.available();
fileBytes = new byte[len];
fis.read(fileBytes);
}
}
} catch (Exception e) {
//
}
WebserviceStatus ws = new WebserviceStatus();
ws.setResult(false);
Resty r = new Resty();
JSONObject tokenMessage = new JSONObject();
try {
tokenMessage.put("username", username);
tokenMessage.put("passwordHash", passwordHash);
tokenMessage.put("idExtension", idExtension);
tokenMessage.put("typeExtension", typeExtension);
tokenMessage.put("version", version);
tokenMessage.put("versionCompatibles", listVersionCompatibles);
tokenMessage.put("filename", new Path(filename).lastSegment());
tokenMessage.put("content", asHex(fileBytes));
tokenMessage.put("description", description == null ? "" : description.replace(" ", "%20"));
tokenMessage.put("agreement", agreement);
JSONObject token = new us.monoid.json.JSONObject();
token.put("newRevision", tokenMessage);
AbstractContent ac = Resty.content(token);
MultipartContent mpc = Resty.form(new FormData("data", ac));
TextResource textResult = r.text(exchangeWSServer + "addRevision.php", mpc);
JSONObject resultObject = new JSONObject(textResult.toString());
JSONObject result = (JSONObject) resultObject.get("resultNewRevision");
String idRevision = result.getString("idRevision");
//
ws.setValue(idRevision);
ws.setResult(true);
//$NON-NLS-1$
ws.setMessageException(Messages.getString("ExchangeWebService.insertionRevisionSuccessful"));
} catch (JSONException e) {
ws.setMessageException(e.getMessage());
} catch (Exception e) {
e.printStackTrace();
ws.setMessageException(e.getMessage());
}
return ws;
}
Aggregations