use of com.centurylink.mdw.model.value.user.UserVO 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.model.value.user.UserVO in project mdw-designer by CenturyLinkCloud.
the class UserDataAccessRest method getUser.
public UserVO getUser(String cuid) throws DataAccessException {
try {
String pathWithArgs = "Users/" + cuid;
if (!getServer().isSchemaVersion61())
pathWithArgs = "User?format=json&cuid=" + cuid + "&withRoles=true";
String response = invokeResourceService(pathWithArgs);
JSONObject jsonObj = new JSONObject(response);
if (jsonObj.has("status"))
// user not found -- no privileges
return new UserVO(cuid);
else
return new UserVO(jsonObj);
} catch (FileNotFoundException ex) {
return null;
} catch (IOException ex) {
throw new DataAccessOfflineException(ex.getMessage(), ex);
} catch (Exception ex) {
throw new DataAccessException(ex.getMessage(), ex);
}
}
use of com.centurylink.mdw.model.value.user.UserVO in project mdw-designer by CenturyLinkCloud.
the class DesignerDataModel method reloadPriviledges.
public void reloadPriviledges(DesignerDataAccess dao, String cuid) throws DataAccessException, RemoteException {
if (dao.noDatabase()) {
user = new UserVO();
user.setCuid(cuid);
user.setName(cuid);
user.addRoleForGroup(UserGroupVO.COMMON_GROUP, UserRoleVO.PROCESS_DESIGN);
user.addRoleForGroup(UserGroupVO.SITE_ADMIN_GROUP, UserRoleVO.PROCESS_DESIGN);
} else {
user = dao.getUser(cuid);
if (user == null) {
if (allowAnyUserToRead) {
user = new UserVO();
user.setCuid(cuid);
user.setName(cuid);
if (UserGroupVO.DEFAULT_ALL_ROLES)
user.addRoleForGroup(UserGroupVO.COMMON_GROUP, UserRoleVO.VIEW_ONLY);
} else {
throw new DataAccessException("You are not authorized to access this site");
}
}
}
}
Aggregations