Fix error when no derived_from type

Signed-off-by: MichaelMorris <michael.morris@est.tech>
Issue-ID: SDC-3889
Change-Id: I1f272a658137a79a545ec90e9256267e8ef7325e
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
index 8c97a04..77d17ca 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
@@ -3748,9 +3748,9 @@
         if (newResource.getResourceType().isAtomicType() && !newResource.getName().equals("Root")
             && newResource.getResourceType() != ResourceTypeEnum.CVFC) {
             ResourceTypeEnum updatedResourceType = newResource.getResourceType();
-            Component derivedFromResource = getParentComponent(newResource);
-            if (derivedFromResource.getComponentType() == ComponentTypeEnum.RESOURCE) {
-                Resource parentResource = (Resource) derivedFromResource;
+            Optional<Component> derivedFromResourceOptional = getParentComponent(newResource);
+            if (derivedFromResourceOptional.isPresent() && derivedFromResourceOptional.get().getComponentType() == ComponentTypeEnum.RESOURCE) {
+                Resource parentResource = (Resource) derivedFromResourceOptional.get();
                 if (!(parentResource.isAbstract() && (ResourceTypeEnum.VFC == parentResource.getResourceType()
                     || ResourceTypeEnum.ABSTRACT == parentResource.getResourceType())) && parentResource.getResourceType() != updatedResourceType
                     && oldResource.getResourceType() != updatedResourceType) {
@@ -3765,7 +3765,10 @@
         }
     }
 
-    private Component getParentComponent(Resource newResource) {
+    private Optional<Component> getParentComponent(Resource newResource) {
+        if (newResource.getDerivedFrom() == null) {
+            return Optional.empty();
+        }
         String toscaResourceNameDerivedFrom = newResource.getDerivedFrom().get(0);
         Either<Component, StorageOperationStatus> latestByToscaResourceName = toscaOperationFacade
             .getLatestByToscaResourceName(toscaResourceNameDerivedFrom, newResource.getModel());
@@ -3775,7 +3778,7 @@
             log.debug("#mergeOldResourceMetadataWithNew - derived from resource {} not found", toscaResourceNameDerivedFrom);
             throw new ByActionStatusComponentException(ActionStatus.RESOURCE_NOT_FOUND, toscaResourceNameDerivedFrom);
         }
-        return latestByToscaResourceName.left().value();
+        return Optional.of(latestByToscaResourceName.left().value());
     }
 
     private Resource prepareResourceForUpdate(Resource oldResource, Resource newResource, User user, boolean inTransaction, boolean needLock) {