use of com.centurylink.mdw.common.utilities.HttpHelper in project mdw-designer by CenturyLinkCloud.
the class DesignerDataAccess method sendRestfulMessage.
private String sendRestfulMessage(String mdwWebUrl, String message, Map<String, String> headers) throws DataAccessException {
try {
HttpHelper httpHelper = currentServer.getHttpHelper(mdwWebUrl + "/Services/REST");
httpHelper.setConnectTimeout(getConnectTimeout());
httpHelper.setReadTimeout(getReadTimeout());
httpHelper.setHeaders(headers);
String res = httpHelper.post(message);
return res == null ? null : res.trim();
} catch (IOException ex) {
throw new DataAccessException(0, IOEXCEPTION, ex);
}
}
use of com.centurylink.mdw.common.utilities.HttpHelper in project mdw-designer by CenturyLinkCloud.
the class DesignerDataAccess method sendSoapMessage.
private String sendSoapMessage(String mdwWebUrl, String message, Map<String, String> headers) throws DataAccessException {
try {
HttpHelper httpHelper = currentServer.getHttpHelper(mdwWebUrl + "/Services/SOAP");
httpHelper.setHeaders(headers);
httpHelper.setConnectTimeout(getConnectTimeout());
httpHelper.setReadTimeout(getReadTimeout());
String res = httpHelper.post(message);
return res == null ? null : res.trim();
} catch (IOException ex) {
throw new DataAccessException(0, IOEXCEPTION, ex);
}
}
use of com.centurylink.mdw.common.utilities.HttpHelper in project mdw-designer by CenturyLinkCloud.
the class DesignerDataAccess method executeUnitTest.
public String executeUnitTest(String message, Map<String, String> headers) throws DataAccessException {
try {
HttpHelper httpHelper = currentServer.getHttpHelper(currentServer.getMdwWebUrl() + "/Services/com/centurylink/mdw/testing/AutomatedTests/unit");
httpHelper.setConnectTimeout(getConnectTimeout());
httpHelper.setReadTimeout(getReadTimeout());
httpHelper.setHeaders(headers);
String res = httpHelper.post(message);
return res == null ? null : res.trim();
} catch (IOException ex) {
throw new DataAccessException(0, IOEXCEPTION, ex);
}
}
use of com.centurylink.mdw.common.utilities.HttpHelper in project mdw-designer by CenturyLinkCloud.
the class Importer method main.
public static void main(String[] args) {
if (args.length == 1 && "-h".equals(args[0])) {
System.out.println("Example Usage: ");
System.out.println("java com.centurylink.mdw.designer.Importer appcuid apppassword " + "jdbc:oracle:thin:mdwdemo/mdwdemo@mdwdevdb.dev.qintra.com:1594:mdwdev (or /path/to/root/storage) " + "http://lxdenvmtc143.dev.qintra.com:7021/maven/repository/mdw/com/centurylink/mdw/assets/camel/5.5.11/com.centurylink.mdw.camel-5.5.11.xml " + "overwrite=true");
System.exit(0);
}
if (args.length != 4 && args.length != 5) {
System.err.println("arguments: <user> <password> <jdbcUrl|fileBasedRootDir> <xmlFile|xmlFileUrl> <overwrite=(true|FALSE)>");
System.err.println("(-h for example usage)");
System.exit(-1);
}
String user = args[0];
String password = args[1];
// either jdbcUrl or local file path
String arg2 = args[2];
String xmlFile = args[3];
boolean overwrite = (args.length == 5 && "overwrite=true".equalsIgnoreCase(args[4])) ? true : false;
try {
DesignerDataAccess.getAuthenticator().authenticate(user, password);
boolean local = !arg2.startsWith("jdbc:");
RestfulServer restfulServer = new RestfulServer(local ? "jdbc://dummy" : arg2, user, "http://dummy");
DesignerDataAccess dataAccess;
if (local) {
VersionControl versionControl = new VersionControlGit();
versionControl.connect(null, null, null, new File(arg2));
restfulServer.setVersionControl(versionControl);
restfulServer.setRootDirectory(new File(arg2));
dataAccess = new DesignerDataAccess(restfulServer, null, user, false);
} else {
dataAccess = new DesignerDataAccess(restfulServer, null, user, true);
UserVO userVO = dataAccess.getUser(user);
if (userVO == null)
throw new DataAccessException("User: '" + user + "' not found.");
if (!userVO.hasRole(UserGroupVO.COMMON_GROUP, UserRoleVO.PROCESS_DESIGN))
throw new DataAccessException("User: '" + user + "' not authorized for " + UserRoleVO.PROCESS_DESIGN + ".");
}
String xml;
if ("http://".startsWith(xmlFile) || "https://".startsWith(xmlFile)) {
xml = new HttpHelper(new URL(xmlFile)).get();
} else {
xml = readFile(xmlFile);
}
System.out.println("Importing with arguments: " + user + " ******* " + arg2 + " " + xmlFile);
Importer importer = new Importer(dataAccess);
long before = System.currentTimeMillis();
importer.importPackage(xml, overwrite);
long afterImport = System.currentTimeMillis();
System.out.println("Time taken for import: " + ((afterImport - before) / 1000) + " s");
System.out.println("Please restart your server or refresh the MDW asset cache.");
} catch (Exception ex) {
ex.printStackTrace();
System.exit(-1);
}
}
use of com.centurylink.mdw.common.utilities.HttpHelper in project mdw-designer by CenturyLinkCloud.
the class NotificationChecker method checkNotices.
private String checkNotices() {
taskInstanceId = null;
String msg = null;
try {
String urlStr = workflowProject.getServiceUrl() + "/Services/TaskActions?user=" + workflowProject.getUser().getUsername() + "&since=" + URLEncoder.encode(StringHelper.dateToString(lastResult), "utf-8") + "&max=" + MAX_NOTICES + "&format=json";
HttpHelper httpHelper = workflowProject.getHttpHelper(urlStr);
httpHelper.setConnectTimeout(MdwPlugin.getSettings().getHttpConnectTimeout());
httpHelper.setReadTimeout(MdwPlugin.getSettings().getHttpReadTimeout());
String response = new String(httpHelper.get());
JSONArray actions = new JSONArray(response);
// String[0]), lastResult);
if (actions.length() > 0) {
msg = "";
UserActionVO firstAction = new UserActionVO(actions.getJSONObject(0));
if (actions.length() == 1) {
taskInstanceId = firstAction.getEntityId();
msg += messageLine(firstAction);
} else {
for (int i = 0; i < actions.length(); i++) {
JSONObject action = actions.getJSONObject(i);
msg += messageLine(new UserActionVO(action));
}
}
lastResult = firstAction.getRetrieveDate();
}
if (lastResult == null)
// fall back to device time
lastResult = new Date();
String lastResultStr = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").format(lastResult);
workflowProject.setPersistentProperty(NotificationChecker.NOTIF_CHECK_LAST_RESULT_KEY, lastResultStr);
} catch (Exception ex) {
PluginMessages.uiError(ex, "Check Notices", workflowProject);
}
return msg;
}
Aggregations