You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sa...@apache.org on 2012/10/04 06:18:55 UTC
svn commit: r1393907 -
/airavata/trunk/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/registry/JCRComponentRegistry.java
Author: samindaw
Date: Thu Oct 4 04:18:54 2012
New Revision: 1393907
URL: http://svn.apache.org/viewvc?rev=1393907&view=rev
Log:
allowing default gateway & user specified from a 3rd party class
Modified:
airavata/trunk/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/registry/JCRComponentRegistry.java
Modified: airavata/trunk/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/registry/JCRComponentRegistry.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/registry/JCRComponentRegistry.java?rev=1393907&r1=1393906&r2=1393907&view=diff
==============================================================================
--- airavata/trunk/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/registry/JCRComponentRegistry.java (original)
+++ airavata/trunk/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/component/registry/JCRComponentRegistry.java Thu Oct 4 04:18:54 2012
@@ -25,7 +25,6 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Properties;
@@ -33,9 +32,11 @@ import org.apache.airavata.common.except
import org.apache.airavata.common.registry.api.exception.RegistryException;
import org.apache.airavata.commons.gfac.type.ServiceDescription;
import org.apache.airavata.registry.api.AiravataRegistry2;
+import org.apache.airavata.registry.api.AiravataRegistryConnectionDataProvider;
import org.apache.airavata.registry.api.AiravataRegistryFactory;
import org.apache.airavata.registry.api.AiravataUser;
import org.apache.airavata.registry.api.Gateway;
+import org.apache.airavata.registry.api.util.RegistryConstants;
import org.apache.airavata.registry.api.util.WebServiceUtil;
import org.apache.airavata.workflow.model.component.ComponentReference;
import org.slf4j.Logger;
@@ -46,32 +47,44 @@ public class JCRComponentRegistry extend
private static final Logger log = LoggerFactory.getLogger(JCRComponentRegistry.class);
private static final String NAME = "Application Services";
public static final String REPOSITORY_PROPERTIES = "repository.properties";
- public static final String GATEWAY_ID = "gateway.id";
- public static final String REGISTRY_USER = "registry.user";
private AiravataRegistry2 registry;
public JCRComponentRegistry(String username, String password) throws RegistryException {
- HashMap<String, String> map = new HashMap<String, String>();
- URL configURL = this.getClass().getClassLoader().getResource(REPOSITORY_PROPERTIES);
- Properties properties = new Properties();
- if(configURL != null){
- try {
- properties.load(configURL.openStream());
- if(properties.get(REGISTRY_USER) != null){
- username = (String)properties.get(REGISTRY_USER);
+ String gatewayName=null;
+ AiravataRegistryConnectionDataProvider provider = AiravataRegistryFactory.getRegistryConnectionDataProvider();
+ if (provider==null){
+ URL configURL = this.getClass().getClassLoader().getResource(REPOSITORY_PROPERTIES);
+ if(configURL != null){
+ try {
+ Properties properties = new Properties();
+ properties.load(configURL.openStream());
+ if (username==null){
+ if(properties.get(RegistryConstants.KEY_DEFAULT_REGISTRY_USER) != null){
+ username = (String)properties.get(RegistryConstants.KEY_DEFAULT_REGISTRY_USER);
+ }
+ }
+ gatewayName = (String)properties.get(RegistryConstants.KEY_DEFAULT_GATEWAY_ID);
+ } catch (MalformedURLException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (IOException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ }
+ }else{
+ if (username==null){
+ username=provider.getValue(RegistryConstants.KEY_DEFAULT_REGISTRY_USER).toString();
}
- } catch (MalformedURLException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- } catch (IOException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ gatewayName = provider.getValue(RegistryConstants.KEY_DEFAULT_GATEWAY_ID).toString();
+ }
+ if (username==null){
+ username="admin";
}
- }else {
- // provide a way to get gatewayid from xbaya gui
- properties.setProperty(GATEWAY_ID, "default");
+ if (gatewayName==null){
+ gatewayName="default";
}
try {
- this.registry = AiravataRegistryFactory.getRegistry(new Gateway((String)properties.get(GATEWAY_ID)),
+ this.registry = AiravataRegistryFactory.getRegistry(new Gateway(gatewayName),
new AiravataUser(username));
} catch (AiravataConfigurationException e) {
log.error("Error initializing AiravataRegistry2");