use of org.apache.airavata.registry.core.experiment.catalog.resources.GatewayResource in project airavata by apache.
the class ExperimentCatalogInitUtil method initializeDB.
public static void initializeDB() {
System.setProperty("registry.initialize.state", "0");
try {
jdbcDriver = ServerSettings.getSetting(REGISTRY_JDBC_DRIVER);
jdbcURl = ServerSettings.getSetting(REGISTRY_JDBC_URL);
jdbcUser = ServerSettings.getSetting(REGISTRY_JDBC_USER);
jdbcPassword = ServerSettings.getSetting(REGISTRY_JDBC_PASSWORD);
jdbcURl = jdbcURl + "?" + "user=" + jdbcUser + "&" + "password=" + jdbcPassword;
} catch (ApplicationSettingsException e) {
logger.error("Unable to read airavata server properties", e.getMessage());
}
if (getDBType(jdbcURl).equals("derby") && isDerbyStartEnabled()) {
startDerbyInServerMode();
}
db = new JdbcStorage(10, 50, jdbcURl, jdbcDriver, true);
Connection conn = null;
try {
conn = db.connect();
if (!DatabaseCreator.isDatabaseStructureCreated(CONFIGURATION_TABLE, conn)) {
DatabaseCreator.createRegistryDatabase("database_scripts/expcatalog", conn);
logger.info("New Database created for Experiment Catalog !!!");
} else {
logger.info("Database already created for Experiment Catalog !!!");
}
try {
GatewayResource gateway;
if (!ExpCatResourceUtils.isGatewayExist(ServerSettings.getDefaultUserGateway())) {
gateway = (GatewayResource) ExpCatResourceUtils.createGateway(ServerSettings.getDefaultUserGateway());
gateway.setGatewayApprovalStatus(GatewayApprovalStatus.APPROVED.toString());
gateway.save();
} else {
gateway = (GatewayResource) ExpCatResourceUtils.getGateway(ServerSettings.getDefaultUserGateway());
}
UserResource user;
if (!ExpCatResourceUtils.isUserExist(ServerSettings.getDefaultUser(), ServerSettings.getDefaultUserGateway())) {
user = ExpCatResourceUtils.createUser(ServerSettings.getDefaultUser(), ServerSettings.getDefaultUserPassword(), ServerSettings.getDefaultUserGateway());
user.save();
} else {
user = (UserResource) ExpCatResourceUtils.getUser(ServerSettings.getDefaultUser(), ServerSettings.getDefaultUserGateway());
}
WorkerResource workerResource;
if (!gateway.isExists(ResourceType.GATEWAY_WORKER, ServerSettings.getDefaultUserGateway())) {
workerResource = (WorkerResource) gateway.create(ResourceType.GATEWAY_WORKER);
workerResource.setUser(user.getUserName());
workerResource.save();
} else {
workerResource = (WorkerResource) gateway.get(ResourceType.GATEWAY_WORKER, ServerSettings.getDefaultUser());
}
ProjectResource projectResource;
if (!workerResource.isExists(ResourceType.PROJECT, DEFAULT_PROJECT_NAME)) {
projectResource = workerResource.createProject(DEFAULT_PROJECT_NAME);
projectResource.setName(DEFAULT_PROJECT_NAME);
projectResource.setGatewayId(gateway.getGatewayId());
projectResource.save();
}
} catch (ApplicationSettingsException e) {
logger.error("Unable to read airavata-server properties...", e.getMessage());
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new RuntimeException("Database failure", e);
} finally {
db.closeConnection(conn);
try {
if (conn != null) {
if (!conn.getAutoCommit()) {
conn.commit();
}
conn.close();
}
} catch (SQLException e) {
logger.error("Error while closing database connection...", e.getMessage(), e);
}
}
System.setProperty("registry.initialize.state", "1");
}
use of org.apache.airavata.registry.core.experiment.catalog.resources.GatewayResource in project airavata by apache.
the class GatewayRegistry method updateGateway.
public void updateGateway(String gatewayId, Gateway updatedGateway) throws RegistryException {
try {
GatewayResource existingGateway = (GatewayResource) ExpCatResourceUtils.getGateway(gatewayId);
existingGateway.setGatewayApprovalStatus(updatedGateway.getGatewayApprovalStatus().toString());
existingGateway.setGatewayName(updatedGateway.getGatewayName());
existingGateway.setEmailAddress(updatedGateway.getEmailAddress());
existingGateway.setDomain(updatedGateway.getDomain());
existingGateway.setGatewayAcronym(updatedGateway.getGatewayAcronym());
existingGateway.setGatewayUrl(updatedGateway.getGatewayURL());
existingGateway.setGatewayPublicAbstract(updatedGateway.getGatewayPublicAbstract());
existingGateway.setReviewProposalDescription(updatedGateway.getReviewProposalDescription());
existingGateway.setGatewayAdminFirstName(updatedGateway.getGatewayAdminFirstName());
existingGateway.setGetGatewayAdminLastName(updatedGateway.getGatewayAdminLastName());
existingGateway.setGatewayAdminEmail(updatedGateway.getGatewayAdminEmail());
existingGateway.setIdentityServerUserName(updatedGateway.getIdentityServerUserName());
existingGateway.setIdentityServerPasswordToken(updatedGateway.getIdentityServerPasswordToken());
existingGateway.setDeclinedReason(updatedGateway.getDeclinedReason());
existingGateway.setOauthClientId(updatedGateway.getOauthClientId());
existingGateway.setOauthClientSecret(updatedGateway.getOauthClientSecret());
existingGateway.setRequesterUsername(updatedGateway.getRequesterUsername());
existingGateway.save();
} catch (RegistryException e) {
logger.error("Error while updating gateway to registry", e);
throw new RegistryException(e);
}
}
use of org.apache.airavata.registry.core.experiment.catalog.resources.GatewayResource in project airavata by apache.
the class NewRegistryUserDialog method ok.
private void ok() {
setData();
String status = updateStatus();
if (status == null) {
try {
// Properties properties = Utils.loadProperties();
GatewayResource gatewayResource = (GatewayResource) ExpCatResourceUtils.getGateway(getGatewayName());
UserResource userResource = (UserResource) gatewayResource.create(ResourceType.USER);
userResource.setUserName(getUsername());
userResource.setPassword(getPassword());
userResource.save();
WorkerResource workerResource = (WorkerResource) gatewayResource.create(ResourceType.GATEWAY_WORKER);
workerResource.setUser(userResource.getUserName());
workerResource.save();
setUserCreated(true);
// JCRComponentRegistry registry = new JCRComponentRegistry(getUsername(),getPassword());
} catch (Exception e) {
engine.getGUI().getErrorWindow().error(e.getMessage());
}
} else {
engine.getGUI().getErrorWindow().error(status);
}
close();
}
use of org.apache.airavata.registry.core.experiment.catalog.resources.GatewayResource in project airavata by apache.
the class GatewayRegistry method addGateway.
public String addGateway(Gateway gateway) throws RegistryException {
try {
GatewayResource resource = (GatewayResource) ExpCatResourceUtils.createGateway(gateway.getGatewayId());
resource.setGatewayApprovalStatus(gateway.getGatewayApprovalStatus().toString());
resource.setGatewayName(gateway.getGatewayName());
resource.setEmailAddress(gateway.getEmailAddress());
resource.setDomain(gateway.getDomain());
resource.setGatewayAcronym(gateway.getGatewayAcronym());
resource.setGatewayUrl(gateway.getGatewayURL());
resource.setGatewayPublicAbstract(gateway.getGatewayPublicAbstract());
resource.setReviewProposalDescription(gateway.getReviewProposalDescription());
resource.setGatewayAdminFirstName(gateway.getGatewayAdminFirstName());
resource.setGetGatewayAdminLastName(gateway.getGatewayAdminLastName());
resource.setGatewayAdminEmail(gateway.getGatewayAdminEmail());
resource.setIdentityServerUserName(gateway.getIdentityServerUserName());
resource.setIdentityServerPasswordToken(gateway.getIdentityServerPasswordToken());
resource.setDeclinedReason(gateway.getDeclinedReason());
resource.setOauthClientId(gateway.getOauthClientId());
resource.setOauthClientSecret(gateway.getOauthClientSecret());
resource.setRequestCreationTime(new Timestamp(System.currentTimeMillis()));
resource.setRequesterUsername(gateway.getRequesterUsername());
resource.save();
return gateway.getGatewayId();
} catch (RegistryException e) {
logger.error("Error while saving gateway to registry", e);
throw new RegistryException(e);
}
}
Aggregations