Fix the problem "when upload package throws an exception "String index out of range...
authornancylizi <li.zi30@zte.com.cn>
Thu, 13 Oct 2016 04:39:32 +0000 (12:39 +0800)
committerhuangjian <huang.jian12@zte.com.cn>
Mon, 17 Oct 2016 12:24:44 +0000 (20:24 +0800)
Change-Id: I594c2e47b104d237390dc9f45d4447e3129f2594
Issue-id:TOSCA-115
Signed-off-by: nancylizi <li.zi30@zte.com.cn>
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapperUtil.java

index 763e200..3ae5fef 100644 (file)
@@ -403,19 +403,21 @@ public class PackageWrapperUtil {
       reader = new BufferedReader(new FileReader(file));
       String tempString = null;
       while ((tempString = reader.readLine()) != null) {
-        int count1 = tempString.indexOf(":");
-        String meta = tempString.substring(0, count1).trim();
-        if (meta.equalsIgnoreCase(CommonConstant.CSAR_TYPE_META)) {
-          int count = tempString.indexOf(":") + 1;
-          basicInfo.setType(EnumType.valueOf(tempString.substring(count).trim()));
-        }
-        if (meta.equalsIgnoreCase(CommonConstant.CSAR_PROVIDER_META)) {
-          int count = tempString.indexOf(":") + 1;
-          basicInfo.setProvider(tempString.substring(count).trim());
-        }
-        if (meta.equalsIgnoreCase(CommonConstant.CSAR_VERSION_META)) {
-          int count = tempString.indexOf(":") + 1;
-          basicInfo.setVersion(tempString.substring(count).trim());
+        if (!tempString.equals("")) {
+          int count1 = tempString.indexOf(":");
+          String meta = tempString.substring(0, count1).trim();
+          if (meta.equalsIgnoreCase(CommonConstant.CSAR_TYPE_META)) {
+            int count = tempString.indexOf(":") + 1;
+            basicInfo.setType(EnumType.valueOf(tempString.substring(count).trim()));
+          }
+          if (meta.equalsIgnoreCase(CommonConstant.CSAR_PROVIDER_META)) {
+            int count = tempString.indexOf(":") + 1;
+            basicInfo.setProvider(tempString.substring(count).trim());
+          }
+          if (meta.equalsIgnoreCase(CommonConstant.CSAR_VERSION_META)) {
+            int count = tempString.indexOf(":") + 1;
+            basicInfo.setVersion(tempString.substring(count).trim());
+          }
         }
       }
       reader.close();