You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2015/03/25 02:23:49 UTC

[04/10] stratos git commit: Removing HashMap attributes from cartridge class

Removing HashMap attributes from cartridge class


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/e6cba32f
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/e6cba32f
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/e6cba32f

Branch: refs/heads/master
Commit: e6cba32ff1719743f416d74caf7935a6912b4085
Parents: c575f4b
Author: Vishanth <vi...@gmail.com>
Authored: Wed Mar 18 15:17:56 2015 +0530
Committer: Vishanth <vi...@gmail.com>
Committed: Tue Mar 24 12:02:58 2015 +0530

----------------------------------------------------------------------
 .../context/CloudControllerContext.java         |   59 +-
 .../cloud/controller/domain/Cartridge.java      |   62 +-
 .../controller/domain/CartridgeConfig.java      |    2 +-
 .../cloud/controller/domain/CartridgeInfo.java  |    1 -
 .../iaases/kubernetes/KubernetesIaas.java       |    2 +-
 .../messaging/topology/TopologyBuilder.java     |   27 +-
 .../impl/CloudControllerServiceImpl.java        |   11 +-
 .../controller/util/CloudControllerUtil.java    |   15 +-
 .../main/resources/CloudControllerService.wsdl  | 1188 +++++++++---------
 9 files changed, 699 insertions(+), 668 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/e6cba32f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
index c503c02..c613809 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
@@ -22,12 +22,7 @@ import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.domain.Cartridge;
-import org.apache.stratos.cloud.controller.domain.ClusterContext;
-import org.apache.stratos.cloud.controller.domain.DeploymentPolicy;
-import org.apache.stratos.cloud.controller.domain.MemberContext;
-import org.apache.stratos.cloud.controller.domain.NetworkPartition;
-import org.apache.stratos.cloud.controller.domain.ServiceGroup;
+import org.apache.stratos.cloud.controller.domain.*;
 import org.apache.stratos.cloud.controller.domain.kubernetes.KubernetesCluster;
 import org.apache.stratos.cloud.controller.domain.kubernetes.KubernetesClusterContext;
 import org.apache.stratos.cloud.controller.domain.kubernetes.KubernetesHost;
@@ -77,6 +72,7 @@ public class CloudControllerContext implements Serializable {
     private static final String CC_CARTRIDGES_WRITE_LOCK = "CC_CARTRIDGES_WRITE_LOCK";
     private static final String CC_SERVICE_GROUPS_WRITE_LOCK = "CC_SERVICE_GROUPS_WRITE_LOCK";
 
+    private static final String CC_PARTITION_TO_IAAS_PROVIDER_BY_CARTRIDGE_MAP = "CC_PARTITION_TO_IAAS_PROVIDER_BY_CARTRIDGE_MAP";
     private static volatile CloudControllerContext instance;
 
     private final transient DistributedObjectProvider distributedObjectProvider;
@@ -161,6 +157,14 @@ public class CloudControllerContext implements Serializable {
 	 */
 	private Map<String, NetworkPartition> networkPartitionIDToNetworkPartitionMap;
 
+
+    /**
+     * Key - cartridge id (cartridge type is used as an unique identifier)
+     * Value - Inner Key - partition id
+     * Value - Inner Value - Corresponding IaasProvider.
+     */
+    private Map<String, Map<String, IaasProvider>> partitionToIaasProviderByCartridge;
+
     private String streamId;
     private boolean isPublisherRunning;
     private boolean isTopologySyncRunning;
@@ -191,7 +195,7 @@ public class CloudControllerContext implements Serializable {
         serviceGroupNameToServiceGroupMap = distributedObjectProvider.getMap(CC_SERVICE_GROUP_NAME_TO_SERVICE_GROUP_MAP);
 		deploymentPolicyIDToDeployPolicyMap=distributedObjectProvider.getMap(CC_DEPLOYMENT_POLICY_ID_TO_DEPLOYEMENT_POLICY_MAP);
 		networkPartitionIDToNetworkPartitionMap = distributedObjectProvider.getMap(CC_NETWORK_PARTITION_ID_TO_NETWORK_PARTITION_MAP);
-
+        partitionToIaasProviderByCartridge = distributedObjectProvider.getMap(CC_PARTITION_TO_IAAS_PROVIDER_BY_CARTRIDGE_MAP);
         // Update context from the registry
         updateContextFromRegistry();
     }
@@ -729,4 +733,45 @@ public class CloudControllerContext implements Serializable {
             destinationList.add(item);
         }
     }
+
+    public Map<String, Map<String, IaasProvider>> getPartitionToIaasProviderByCartridge() {
+        return partitionToIaasProviderByCartridge;
+    }
+
+    public void setPartitionToIaasProvider(Map<String, Map<String, IaasProvider>> partitionToIaasProviderByCartridge) {
+        this.partitionToIaasProviderByCartridge = partitionToIaasProviderByCartridge;
+    }
+
+    public void addIaasProvider(String cartridgeId, String partitionId, IaasProvider iaasProvider) {
+        Map<String, IaasProvider> partitionToIaasProvider = new ConcurrentHashMap<String, IaasProvider>();
+        partitionToIaasProvider.put(partitionId, iaasProvider);
+        this.partitionToIaasProviderByCartridge.put(cartridgeId, partitionToIaasProvider);
+    }
+
+    public void addIaasProviders(String cartridgeId, Map<String, IaasProvider> map) {
+        Map<String, IaasProvider> partitionToIaasProvider = new ConcurrentHashMap<String, IaasProvider>();
+        for (Iterator<String> iterator = map.keySet().iterator(); iterator.hasNext(); ) {
+            String key = iterator.next();
+            IaasProvider value = map.get(key);
+
+            partitionToIaasProvider.put(key, value);
+            if (log.isDebugEnabled()) {
+                log.debug("Partition map updated for the Cartridge: " + this.hashCode() + ". "
+                        + "Current Partition List: " + partitionToIaasProvider.keySet().toString());
+            }
+        }
+        this.partitionToIaasProviderByCartridge.put(cartridgeId, partitionToIaasProvider);
+    }
+
+    public IaasProvider getIaasProviderOfPartition(String cartridgeId, String partitionId) {
+        if (log.isDebugEnabled()) {
+            log.debug("Retrieving partition: " + partitionId + " for the Cartridge: " + this.hashCode() + ". "
+                    + "Current Partition List: " + getPartitionToIaasProvider(cartridgeId).keySet().toString());
+        }
+        return getPartitionToIaasProvider(cartridgeId).get(partitionId);
+    }
+
+    public Map<String, IaasProvider> getPartitionToIaasProvider(String cartridgeId) {
+        return this.partitionToIaasProviderByCartridge.get(cartridgeId);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/e6cba32f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java
index 9cdd886..fcab1fb 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java
@@ -21,11 +21,10 @@ package org.apache.stratos.cloud.controller.domain;
 import org.apache.commons.lang.builder.HashCodeBuilder;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.common.domain.LoadBalancingIPType;
+import org.apache.stratos.common.*;
 
 import java.io.Serializable;
 import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * Holds information regarding a Cartridge.
@@ -54,7 +53,7 @@ public class Cartridge implements Serializable{
     /**
      * Property map of this Cartridge.
      */
-    private Map<String, String> properties;
+    private org.apache.stratos.common.Properties properties;
     
     /**
      * A Cartridge can have 1..n {@link IaasProvider}s
@@ -64,12 +63,6 @@ public class Cartridge implements Serializable{
     private IaasProvider lastlyUsedIaas;
     private String[] exportingProperties;
 
-    /**
-     * Key - partition id
-     * Value - Corresponding IaasProvider.
-     */
-    private Map<String, IaasProvider> partitionToIaasProvider;
-
     public Cartridge(){
     	init();
     }
@@ -84,11 +77,9 @@ public class Cartridge implements Serializable{
     }
     
     private void init() {
-    	partitionToIaasProvider = new ConcurrentHashMap<String, IaasProvider>();
     	portMappings = new ArrayList<PortMapping>();
     	portMappings = new ArrayList<PortMapping>();
     	appTypeMappings = new ArrayList<AppType>();
-    	properties = new HashMap<String, String>();
     	iaases = new ArrayList<IaasProvider>();
     	deploymentDirs = new ArrayList<String>();
         tenantPartitions = "*";
@@ -102,46 +93,20 @@ public class Cartridge implements Serializable{
         this.type = type;
     }
     
-    public void addIaasProvider(String partitionId, IaasProvider iaasProvider) {
-        partitionToIaasProvider.put(partitionId, iaasProvider);
-    }
-    
-    public void addIaasProviders(Map<String, IaasProvider> map) {
-        for (Iterator<String> iterator = map.keySet().iterator(); iterator.hasNext();) {
-            String key = iterator.next();
-            IaasProvider value = map.get(key);
-            
-            partitionToIaasProvider.put(key, value);
-            if(log.isDebugEnabled()) {
-            	log.debug("Partition map updated for the Cartridge: "+this.hashCode()+". "
-            			+ "Current Partition List: "+partitionToIaasProvider.keySet().toString());
-            }
-        }
-    }
-    
-    public IaasProvider getIaasProviderOfPartition(String partitionId) {
-    	if(log.isDebugEnabled()) {
-        	log.debug("Retrieving partition: "+partitionId+" for the Cartridge: "+this.hashCode()+". "
-        			+ "Current Partition List: "+partitionToIaasProvider.keySet().toString());
-        }
-        return partitionToIaasProvider.get(partitionId);
-    }
-    
     public void addProperty(String key, String val) {
         if (key != null && val != null) {
-            properties.put(key, val);
+            Property property = new Property();
+            property.setName(key);
+            property.setValue(val);
+            properties.addProperty(property);
         }
     }
 
-    public Map<String, String> getProperties() {
+    public org.apache.stratos.common.Properties getProperties() {
         return properties;
     }
-    
-    public String getProperty(String key) {
-        return properties.get(key);
-    }
 
-    public void setProperties(Map<String, String> properties) {
+    public void setProperties(org.apache.stratos.common.Properties properties) {
         this.properties = properties;
     }
     
@@ -291,14 +256,6 @@ public class Cartridge implements Serializable{
     	this.appTypeMappings = appTypeMappings;
     }
 
-    public Map<String, IaasProvider> getPartitionToIaasProvider() {
-        return partitionToIaasProvider;
-    }
-
-    public void setPartitionToIaasProvider(Map<String, IaasProvider> partitionToIaasProvider) {
-        this.partitionToIaasProvider = partitionToIaasProvider;
-    }
-
     /**
 	 * @return the persistence
 	 */
@@ -361,6 +318,7 @@ public class Cartridge implements Serializable{
                 + ", version=" + version
                 + ", multiTenant=" + multiTenant
                 + ", properties=" + properties
-                + ", partitionToIaasProvider=" + partitionToIaasProvider + "]";
+                + "]";
     }
+
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/e6cba32f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeConfig.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeConfig.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeConfig.java
index d4989f1..afdfd2e 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeConfig.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeConfig.java
@@ -114,7 +114,7 @@ public class CartridgeConfig implements Serializable {
         return isPublic;
     }
 
-    public void setisPublic(boolean isPublic) {
+    public void setIsPublic(boolean isPublic) {
         this.isPublic = isPublic;
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/e6cba32f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeInfo.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeInfo.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeInfo.java
index 0bed133..212f975 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeInfo.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/CartridgeInfo.java
@@ -101,7 +101,6 @@ public class CartridgeInfo {
 	    this.deploymentDirs = new String[deploymentDirsList.size()];
 	    
 	    deploymentDirsList.toArray(deploymentDirs);
-	    
     }
 	
     public String getProvider() {

http://git-wip-us.apache.org/repos/asf/stratos/blob/e6cba32f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
index f6ef684..ca0fa2b 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
@@ -371,7 +371,7 @@ public class KubernetesIaas extends Iaas {
             throw new RuntimeException(message);
         }
 
-        IaasProvider iaasProvider = cartridge.getIaasProviderOfPartition(partition.getId());
+        IaasProvider iaasProvider = CloudControllerContext.getInstance().getIaasProviderOfPartition(cartridge.getType(), partition.getId());
         if (iaasProvider == null) {
             String message = "Could not find iaas provider: [partition] " + partition.getId();
             log.error(message);

http://git-wip-us.apache.org/repos/asf/stratos/blob/e6cba32f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/messaging/topology/TopologyBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/messaging/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/messaging/topology/TopologyBuilder.java
index a6347c1..7dfe4ee 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/messaging/topology/TopologyBuilder.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/messaging/topology/TopologyBuilder.java
@@ -27,6 +27,7 @@ import org.apache.stratos.cloud.controller.exception.InvalidMemberException;
 import org.apache.stratos.cloud.controller.statistics.publisher.BAMUsageDataPublisher;
 import org.apache.stratos.cloud.controller.messaging.publisher.TopologyEventPublisher;
 import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
+import org.apache.stratos.common.*;
 import org.apache.stratos.messaging.domain.application.ClusterDataHolder;
 import org.apache.stratos.messaging.domain.instance.ClusterInstance;
 import org.apache.stratos.messaging.domain.topology.*;
@@ -41,6 +42,7 @@ import org.apache.stratos.metadata.client.defaults.DefaultMetaDataServiceClient;
 import org.apache.stratos.metadata.client.defaults.MetaDataServiceClient;
 
 import java.util.*;
+import java.util.Properties;
 
 /**
  * this is to manipulate the received events by cloud controller
@@ -67,9 +69,29 @@ public class TopologyBuilder {
                     service = new Service(cartridge.getType(), serviceType);
                     List<PortMapping> portMappings = cartridge.getPortMappings();
                     Properties properties = new Properties();
-                    for (Map.Entry<String, String> entry : cartridge.getProperties().entrySet()) {
-                        properties.setProperty(entry.getKey(), entry.getValue());
+
+                    try {
+                        Property[] propertyArray = null;
+
+                        if (cartridge.getProperties() != null) {
+                            if (cartridge.getProperties().getProperties() != null){
+                                propertyArray = cartridge.getProperties().getProperties();
+                            }
+                        }
+
+                        List<Property> propertyList = new ArrayList<Property>();
+                        if (propertyArray != null) {
+                            propertyList = Arrays.asList(propertyArray);
+                            if (propertyList != null) {
+                                for (Property property : propertyList) {
+                                    properties.setProperty(property.getName(), property.getValue());
+                                }
+                            }
+                        }
+                    } catch(Exception e) {
+                        log.error(e);
                     }
+
                     service.setProperties(properties);
                     Port port;
                     //adding ports to the event
@@ -85,7 +107,6 @@ public class TopologyBuilder {
             TopologyManager.releaseWriteLock();
         }
         TopologyEventPublisher.sendServiceCreateEvent(cartridgeList);
-
     }
 
     public static void handleServiceRemoved(List<Cartridge> cartridgeList) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/e6cba32f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
index 5b6b487..76501be 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
@@ -160,7 +160,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
                                    Cartridge sourceCartridge) {
 
         List<IaasProvider> newIaasProviders = destCartridge.getIaases();
-        Map<String, IaasProvider> iaasProviderMap = sourceCartridge.getPartitionToIaasProvider();
+        Map<String, IaasProvider> iaasProviderMap = CloudControllerContext.getInstance().getPartitionToIaasProvider(sourceCartridge.getType());
 
         for (Entry<String, IaasProvider> entry : iaasProviderMap.entrySet()) {
             if (entry == null) {
@@ -173,7 +173,8 @@ public class CloudControllerServiceImpl implements CloudControllerService {
                     log.debug("Copying partition from the cartridge that is undeployed, to the new cartridge: "
                             + "[partition-id] " + partitionId + " [cartridge-type] " + destCartridge.getType());
                 }
-                destCartridge.addIaasProvider(partitionId, newIaasProviders.get(newIaasProviders.indexOf(iaasProvider)));
+                CloudControllerContext.getInstance().addIaasProvider(destCartridge.getType(), partitionId,
+                        newIaasProviders.get(newIaasProviders.indexOf(iaasProvider)));
             }
         }
     }
@@ -380,12 +381,12 @@ public class CloudControllerServiceImpl implements CloudControllerService {
             }
 
             // Validate iaas provider
-            IaasProvider iaasProvider = cartridge.getIaasProviderOfPartition(partitionId);
+            IaasProvider iaasProvider = CloudControllerContext.getInstance().getIaasProviderOfPartition(cartridge.getType(), partitionId);
             if (iaasProvider == null) {
                 String msg = String.format("Could not start instance, " +
                                 "IaaS provider not found in cartridge %s for partition %s, " +
                                 "partitions found: %s ", cartridgeType, partitionId,
-                        cartridge.getPartitionToIaasProvider().keySet().toString());
+                       CloudControllerContext.getInstance().getPartitionToIaasProvider(cartridge.getType()).keySet().toString());
                 log.error(msg);
                 throw new InvalidIaasProviderException(msg);
             }
@@ -937,7 +938,7 @@ public class CloudControllerServiceImpl implements CloudControllerService {
             }
 
             // if and only if the deployment policy valid
-            cartridge.addIaasProviders(partitionToIaasProviders);
+            CloudControllerContext.getInstance().addIaasProviders(cartridgeType, partitionToIaasProviders);
             CloudControllerContext.getInstance().updateCartridge(cartridge);
 
             // persist data

http://git-wip-us.apache.org/repos/asf/stratos/blob/e6cba32f/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
index e0837af..c5780b4 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
@@ -229,16 +229,23 @@ public class CloudControllerUtil {
 		List<Property> propList = new ArrayList<Property>();
         cartridgeInfo.setPersistence(cartridge.getPersistence());
 		
-		for (Iterator<?> iterator = cartridge.getProperties().entrySet().iterator(); iterator.hasNext();) {
+		/*for (Iterator<?> iterator = cartridge.getProperties().entrySet().iterator(); iterator.hasNext();) {
 	        @SuppressWarnings("unchecked")
             Map.Entry<String, String> entry = (Entry<String, String>) iterator.next();
 	        
 	        Property prop = new Property(entry.getKey(), entry.getValue());
 	        propList.add(prop);
+        }*/
+
+        List<Property> propertyList = new ArrayList<Property>();
+        if (cartridge.getProperties()!= null) {
+            if (cartridge.getProperties().getProperties() != null) {
+                propertyList = Arrays.asList(cartridge.getProperties().getProperties());
+                Property[] props = new Property[propertyList.size()];
+                cartridgeInfo.setProperties(propertyList.toArray(props));
+            }
         }
-		Property[] props = new Property[propList.size()];
-		
-		cartridgeInfo.setProperties(propList.toArray(props));
+
 	    cartridgeInfo.setMetadataKeys(cartridge.getMetadataKeys());
 
 		return cartridgeInfo;