use of com.centurylink.mdw.designer.utils.RestfulServer in project mdw-designer by CenturyLinkCloud.
the class DesignerDataAccess method remoteRetrieveProcess.
public ProcessVO remoteRetrieveProcess(String name, int version) throws DataAccessException {
try {
String path = "Processes?name=" + name;
if (version != 0)
path += "&version=" + RuleSetVO.formatVersion(version);
String pkgXml = ((RestfulServer) currentServer).invokeResourceService(path);
ProcessImporter importer = DataAccess.getProcessImporter(getDatabaseSchemaVersion());
PackageVO pkg = importer.importPackage(pkgXml);
ProcessVO process = pkg.getProcesses().get(0);
process.setPackageName(pkg.getName());
process.setPackageVersion(pkg.getVersionString());
if (isVcsPersist())
process.setId(currentServer.getVersionControl().getId(getLogicalFile(process)));
return process;
} catch (IOException ex) {
throw new DataAccessException("Error retrieving process: " + name + " v" + RuleSetVO.formatVersion(version), ex);
}
}
use of com.centurylink.mdw.designer.utils.RestfulServer in project mdw-designer by CenturyLinkCloud.
the class DesignerDataAccess method retryActivity.
public void retryActivity(Long activityId, Long activityInstId) throws DataAccessException, XmlException, IOException {
if (currentServer.isSchemaVersion61()) {
((RestfulServer) currentServer).retryActivityInstance(activityInstId, ActivityResultCodeConstant.RESULT_RETRY);
} else {
String request = currentServer.buildRetryActivityInstanceRequest(activityId, activityInstId, false);
String response = this.engineCall(request);
try {
String result = currentServer.getErrorMessageFromResponse(response);
if (result == null || result.length() > 0)
throw new RemoteException(result);
auditLog(Action.Retry, Entity.ActivityInstance, activityInstId, null);
} catch (XmlException e) {
throw new DataAccessException("Response is not an MDWStatusMessage");
}
}
}
use of com.centurylink.mdw.designer.utils.RestfulServer in project mdw-designer by CenturyLinkCloud.
the class Exporter 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.Exporter " + "jdbc:oracle:thin:mdwdemo/mdwdemo@mdwdevdb.dev.qintra.com:1594:mdwdev (or /path/to/root/storage) " + "com.centurylink.mdw.tests " + "/path/to/packageDef(.xml|.json)");
System.exit(0);
}
if (args.length != 2 && args.length != 3) {
System.err.println("arguments: <jdbcUrl|fileBasedRootDir> <packageName> <xmlFile>");
System.err.println("(-h for example usage)");
System.exit(-1);
}
// either jdbcUrl or local file path
String arg0 = args[0];
String packageName = args[1];
String outFile = args[2];
try {
boolean local = !arg0.startsWith("jdbc:");
RestfulServer restfulServer = new RestfulServer(local ? "jdbc://dummy" : arg0, null, "http://dummy");
DesignerDataAccess dataAccess;
if (local) {
VersionControl versionControl = new VersionControlGit();
versionControl.connect(null, null, null, new File(arg0));
restfulServer.setVersionControl(versionControl);
restfulServer.setRootDirectory(new File(arg0));
dataAccess = new DesignerDataAccess(restfulServer, null, EXPORT, false);
} else {
dataAccess = new DesignerDataAccess(restfulServer, null, EXPORT, true);
}
System.out.println("Exporting with arguments: " + arg0 + " " + packageName + " " + outFile);
Exporter exporter = new Exporter(dataAccess);
long before = System.currentTimeMillis();
String xml = exporter.exportPackage(packageName, true, outFile.endsWith(".json"));
File outputFile = new File(outFile);
if (outputFile.exists()) {
System.out.println("Overwriting existing file: " + outputFile);
} else if (!outputFile.getParentFile().exists() && !outputFile.getParentFile().mkdirs()) {
throw new IOException("Cannot create directory: " + outputFile.getParentFile());
}
exporter.writeFile(outputFile, xml.getBytes());
long afterExport = System.currentTimeMillis();
System.out.println("Time taken for export: " + ((afterExport - before) / 1000) + " s");
} catch (Exception ex) {
ex.printStackTrace();
System.exit(-1);
}
}
use of com.centurylink.mdw.designer.utils.RestfulServer 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.designer.utils.RestfulServer in project mdw-designer by CenturyLinkCloud.
the class WorkflowImageHelper method getProcessImage.
/**
* Generate a process instance image.
*/
public BufferedImage getProcessImage() throws Exception {
VersionControl vc = DataAccess.getAssetVersionControl(ApplicationContext.getAssetRoot());
String serviceUrl = ApplicationContext.getServicesUrl();
RestfulServer restfulServer = new RestfulServer("jdbc://dummy", "mdwapp", serviceUrl);
restfulServer.setVersionControl(vc);
restfulServer.setRootDirectory(ApplicationContext.getAssetRoot());
DesignerDataAccess dao = new DesignerDataAccess(restfulServer, null, "mdwapp");
// clone the process since it'll be converted to Designer
Long processId = process.getId();
process = new ProcessVO(process);
process.setId(processId);
return generateImage(dao);
}
Aggregations