Github user ramith commented on a diff in the pull request:

    https://github.com/apache/stratos/pull/84#discussion_r22095051
  
    --- Diff: 
components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java
 ---
    @@ -18,91 +18,199 @@
      */
     package org.apache.stratos.metadataservice.registry;
     
    -import java.io.File;
    -import java.util.List;
    -
    -import javax.servlet.http.HttpServletRequest;
    -import javax.ws.rs.core.Context;
    -
     import org.apache.axis2.context.ConfigurationContext;
     import org.apache.axis2.context.ConfigurationContextFactory;
     import org.apache.commons.configuration.XMLConfiguration;
     import org.apache.commons.logging.Log;
     import org.apache.commons.logging.LogFactory;
    +
    +import org.apache.stratos.metadataservice.definition.CartridgeMetaData;
     import org.apache.stratos.metadataservice.definition.NewProperty;
     import org.apache.stratos.metadataservice.util.ConfUtil;
     import org.wso2.carbon.registry.api.Registry;
     import org.wso2.carbon.registry.api.RegistryException;
    +import org.wso2.carbon.registry.api.Resource;
    +import org.wso2.carbon.registry.core.Comment;
     import org.wso2.carbon.registry.ws.client.registry.WSRegistryServiceClient;
     
    +import javax.servlet.http.HttpServletRequest;
    +import javax.ws.rs.core.Context;
    +import java.io.File;
    +import java.util.List;
    +
     /**
    - * 
      * Governance registry implementation for the registry factory
    - * 
      */
     public class GRegRegistry implements DataStore {
     
    -   private static Log log = LogFactory.getLog(GRegRegistry.class);
    -   @Context
    -   HttpServletRequest httpServletRequest;
    -
    -   private static ConfigurationContext configContext = null;
    -
    -   private static String defaultAxis2Repo = "repository/deployment/client";
    -   private static String defaultAxis2Conf = 
"repository/conf/axis2/axis2_client.xml";
    -
    -   private static final String defaultUsername = "ad...@org.com";
    -   private static final String defaultPassword = "admin123";
    -   private static final String serverURL = 
"https://localhost:9445/services/";;
    -   private static final String mainResource = "/startos/";
    -   private static final int defaultRank = 3;
    -
    -   /*
    -    * Registry initiation
    -    */
    -   private static WSRegistryServiceClient setRegistry() throws Exception {
    -
    -           XMLConfiguration conf = 
ConfUtil.getInstance(null).getConfiguration();
    -
    -           String gregUsername = 
conf.getString("metadataservice.username", defaultUsername);
    -           String gregPassword = 
conf.getString("metadataservice.password", defaultPassword);
    -           String gregServerURL = 
conf.getString("metadataservice.serverurl", serverURL);
    -           String axis2Repo = conf.getString("metadataservice.axis2Repo", 
defaultAxis2Repo);
    -           String axis2Conf = conf.getString("metadataservice.axis2Conf", 
defaultAxis2Conf);
    -           String defaultTrustStore =
    -                                      "repository" + File.separator + 
"resources" + File.separator +
    -                                              "security" + File.separator 
+ "wso2carbon.jks";
    -           String trustStorePath = 
conf.getString("metadataservice.trustStore", defaultTrustStore);
    -           String trustStorePassword =
    -                                       
conf.getString("metadataservice.trustStorePassword",
    -                                                      "wso2carbon");
    -           String trustStoreType = 
conf.getString("metadataservice.trustStoreType", "JKS");
    -
    -           System.setProperty("javax.net.ssl.trustStore", trustStorePath);
    -           System.setProperty("javax.net.ssl.trustStorePassword", 
trustStorePassword);// "wso2carbon"
    -           System.setProperty("javax.net.ssl.trustStoreType", 
trustStoreType);// "JKS"
    -           System.setProperty("carbon.repo.write.mode", "true");
    -           configContext =
    -                           
ConfigurationContextFactory.createConfigurationContextFromFileSystem(axis2Repo,
    -                                                                           
                     axis2Conf);
    -           return new WSRegistryServiceClient(gregServerURL, gregUsername, 
gregPassword, configContext);
    -   }
    +
    +    private static Log log = LogFactory.getLog(GRegRegistry.class);
    +    @Context
    +    HttpServletRequest httpServletRequest;
    +
    +    private static ConfigurationContext configContext;
    +
    +    static {
    +        configContext = null;
    +    }
    +
    +    private static final String defaultUsername = "ad...@org.com";
    +    private static final String defaultPassword = "admin123";
    +    private static final String serverURL = 
"https://localhost:9445/services/";;
    +    private static final String mainResource = "/startos/";
    +    private static final int defaultRank = 3;
     
         /*
    -     *
    -     * Remove the meta data from the registry
    -     *
    -     * @see org.apache.stratos.metadataservice.registry.DataStore#
    -     * removeCartridgeMetaDataDetails(java.lang.String, java.lang.String)
    +     * Registry initiation
          */
    -   @Override
    -   public boolean removeCartridgeMetaDataDetails(String applicationName, 
String cartridgeType)
    -                                                                           
                   throws Exception {
    -           Registry registry = setRegistry();
    -           String resourcePath = mainResource + applicationName + "/" + 
cartridgeType;
    -           registry.delete(resourcePath);
    -           return false;
    -   }
    +    private static WSRegistryServiceClient setRegistry() throws Exception {
    +
    +        XMLConfiguration conf = 
ConfUtil.getInstance(null).getConfiguration();
    +
    +        String gregUsername = conf.getString("metadataservice.username", 
defaultUsername);
    +        String gregPassword = conf.getString("metadataservice.password", 
defaultPassword);
    +        String gregServerURL = conf.getString("metadataservice.serverurl", 
serverURL);
    +        String defaultAxis2Repo = "repository/deployment/client";
    +        String axis2Repo = conf.getString("metadataservice.axis2Repo", 
defaultAxis2Repo);
    +        String defaultAxis2Conf = "repository/conf/axis2/axis2_client.xml";
    +        String axis2Conf = conf.getString("metadataservice.axis2Conf", 
defaultAxis2Conf);
    +        String defaultTrustStore =
    +                "repository" + File.separator + "resources" + 
File.separator +
    +                        "security" + File.separator + "wso2carbon.jks";
    +        String trustStorePath = 
conf.getString("metadataservice.trustStore", defaultTrustStore);
    +        String trustStorePassword =
    +                conf.getString("metadataservice.trustStorePassword",
    +                        "wso2carbon");
    +        String trustStoreType = 
conf.getString("metadataservice.trustStoreType", "JKS");
    +
    +        System.setProperty("javax.net.ssl.trustStore", trustStorePath);
    +        System.setProperty("javax.net.ssl.trustStorePassword", 
trustStorePassword);// "wso2carbon"
    +        System.setProperty("javax.net.ssl.trustStoreType", 
trustStoreType);// "JKS"
    +        System.setProperty("carbon.repo.write.mode", "true");
    +        configContext =
    +                
ConfigurationContextFactory.createConfigurationContextFromFileSystem(axis2Repo,
    +                        axis2Conf);
    +        return new WSRegistryServiceClient(gregServerURL, gregUsername, 
gregPassword, configContext);
    +    }
    +
    +
    +
    +    /**
    +     * Add the meta data to governance registry
    +     * @param applicationName
    +     * @param cartridgeType
    +     * @param cartridgeMetaData
    +     * @throws Exception
    +     */
    +    @Override
    +    public void addCartridgeMetaDataDetails(String applicationName, String 
cartridgeType,
    +                                            CartridgeMetaData 
cartridgeMetaData) throws Exception {
    +
    +        Registry registry = setRegistry();
    +        try {
    +
    +            Resource resource = registry.newResource();
    +
    +            String type = cartridgeMetaData.type;
    +
    +            resource.setContent("Application description :: " + type);
    +
    +            String resourcePath = mainResource + applicationName + "/" + 
cartridgeType;
    +
    +            resource.addProperty("Application Name", 
cartridgeMetaData.applicationName);
    +            resource.addProperty("Display Name", 
cartridgeMetaData.displayName);
    +            resource.addProperty("Description", 
cartridgeMetaData.description);
    +            resource.addProperty("Cartidge Type", cartridgeMetaData.type);
    +            resource.addProperty("provider", cartridgeMetaData.provider);
    +            resource.addProperty("Version", cartridgeMetaData.version);
    +            resource.addProperty("Host", cartridgeMetaData.host);
    +            resource.addProperty("Properties", 
cartridgeMetaData.properties);
    +            registry.put(resourcePath, resource);
    +
    +            registry.rateResource(resourcePath, defaultRank);
    +
    +            Comment comment = new Comment();
    +            comment.setText("Added the " + applicationName + " " + type + 
" cartridge");
    +            registry.addComment(resourcePath, comment);
    +
    +        } catch (Exception e) {
    +
    +            if (log.isErrorEnabled()) {
    +                log.error("addCartridgeMetaDataDetails", e);
    --- End diff --
    
    is this intentional? (checking error enabled?)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to