diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core')
3 files changed, 52 insertions, 36 deletions
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/ZusammenConnector.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/ZusammenConnector.java index 09851afcfe..7932902dad 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/ZusammenConnector.java +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/ZusammenConnector.java @@ -1,3 +1,19 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.openecomp.core.zusammen.db; import com.amdocs.zusammen.adaptor.inbound.api.types.item.*; @@ -71,10 +87,10 @@ public interface ZusammenConnector { Id elementId); Element saveElement(SessionContext context, ElementContext elementContext, - ZusammenElement element, String message); + Element element, String message); void resolveElementConflict(SessionContext context, ElementContext elementContext, - ZusammenElement element, Resolution resolution); + Element element, Resolution resolution); void resetVersionHistory(SessionContext context, Id itemId, Id versionId, String changeRef); } diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java index 3a2854d081..474b7303ab 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/db/impl/ZusammenConnectorImpl.java @@ -19,21 +19,30 @@ import com.amdocs.zusammen.adaptor.inbound.api.health.HealthAdaptorFactory; import com.amdocs.zusammen.adaptor.inbound.api.item.ElementAdaptorFactory; import com.amdocs.zusammen.adaptor.inbound.api.item.ItemAdaptorFactory; import com.amdocs.zusammen.adaptor.inbound.api.item.ItemVersionAdaptorFactory; -import com.amdocs.zusammen.adaptor.inbound.api.types.item.*; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementConflict; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ItemVersionConflict; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.MergeResult; import com.amdocs.zusammen.commons.health.data.HealthInfo; import com.amdocs.zusammen.datatypes.Id; import com.amdocs.zusammen.datatypes.SessionContext; import com.amdocs.zusammen.datatypes.Space; -import com.amdocs.zusammen.datatypes.item.*; +import com.amdocs.zusammen.datatypes.item.ElementContext; +import com.amdocs.zusammen.datatypes.item.Info; +import com.amdocs.zusammen.datatypes.item.Item; +import com.amdocs.zusammen.datatypes.item.ItemVersion; +import com.amdocs.zusammen.datatypes.item.ItemVersionData; +import com.amdocs.zusammen.datatypes.item.ItemVersionStatus; +import com.amdocs.zusammen.datatypes.item.Resolution; import com.amdocs.zusammen.datatypes.itemversion.ItemVersionRevisions; import com.amdocs.zusammen.datatypes.itemversion.Tag; import com.amdocs.zusammen.datatypes.response.Response; +import java.util.Collection; import org.openecomp.core.zusammen.db.ZusammenConnector; import org.openecomp.core.zusammen.impl.CassandraConnectionInitializer; import org.openecomp.sdc.common.errors.SdcRuntimeException; -import java.util.Collection; - public class ZusammenConnectorImpl implements ZusammenConnector { private static final String GET_ELEMENT_ERR_MSG = @@ -355,8 +364,7 @@ public class ZusammenConnectorImpl implements ZusammenConnector { } @Override - public Element saveElement(SessionContext context, ElementContext elementContext, - ZusammenElement element, String message) { + public Element saveElement(SessionContext context, ElementContext elementContext, Element element, String message) { Response<Element> response = elementAdaptorFactory.createInterface(context) .save(context, elementContext, element, message); if (!response.isSuccessful()) { @@ -369,9 +377,8 @@ public class ZusammenConnectorImpl implements ZusammenConnector { } @Override - public void resolveElementConflict(SessionContext context, ElementContext elementContext, - ZusammenElement element, - Resolution resolution) { + public void resolveElementConflict(SessionContext context, ElementContext elementContext, Element element, + Resolution resolution) { Response<Void> response = elementAdaptorFactory.createInterface(context) .resolveConflict(context, elementContext, element, resolution); if (!response.isSuccessful()) { diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ZusammenAdaptorImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ZusammenAdaptorImpl.java index 186ad7f6cb..4efa2486a2 100644 --- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ZusammenAdaptorImpl.java +++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/ZusammenAdaptorImpl.java @@ -15,22 +15,31 @@ */ package org.openecomp.core.zusammen.impl; -import com.amdocs.zusammen.adaptor.inbound.api.types.item.*; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementConflict; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ItemVersionConflict; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; import com.amdocs.zusammen.commons.health.data.HealthInfo; import com.amdocs.zusammen.datatypes.Id; import com.amdocs.zusammen.datatypes.SessionContext; -import com.amdocs.zusammen.datatypes.item.*; +import com.amdocs.zusammen.datatypes.item.Action; +import com.amdocs.zusammen.datatypes.item.ElementContext; +import com.amdocs.zusammen.datatypes.item.Info; +import com.amdocs.zusammen.datatypes.item.Item; +import com.amdocs.zusammen.datatypes.item.ItemVersion; +import com.amdocs.zusammen.datatypes.item.ItemVersionData; +import com.amdocs.zusammen.datatypes.item.ItemVersionStatus; +import com.amdocs.zusammen.datatypes.item.Resolution; import com.amdocs.zusammen.datatypes.itemversion.ItemVersionRevisions; import com.amdocs.zusammen.datatypes.itemversion.Tag; -import org.openecomp.core.zusammen.api.ZusammenAdaptor; -import org.openecomp.core.zusammen.db.ZusammenConnector; - import java.util.ArrayList; import java.util.Collection; -import java.util.List; import java.util.Optional; import java.util.function.Predicate; import java.util.stream.Collectors; +import org.openecomp.core.zusammen.api.ZusammenAdaptor; +import org.openecomp.core.zusammen.db.ZusammenConnector; public class ZusammenAdaptorImpl implements ZusammenAdaptor { @@ -145,6 +154,9 @@ public class ZusammenAdaptorImpl implements ZusammenAdaptor { if (element.getElementId() != null) { return; } + if (element.getInfo() == null || element.getInfo().getName() == null) { + throw new IllegalArgumentException("When saving element to zusammen - its Id or name must be supplied"); + } Optional<ElementInfo> elementInfo = getElementInfoByName(context, elementContext, parentElementId, element.getInfo().getName()); if (elementInfo.isPresent()) { @@ -190,19 +202,6 @@ public class ZusammenAdaptorImpl implements ZusammenAdaptor { } @Override - public Optional<ItemVersion> getFirstVersion(SessionContext context, Id itemId) { - Collection<ItemVersion> versions = connector.listPublicVersions(context, itemId); - if (versions == null || versions.isEmpty()) { - return Optional.empty(); - } - List<ItemVersion> itemVersions = new ArrayList<>(versions); - sortItemVersionListByModificationTimeDescOrder(itemVersions); - ItemVersion itemVersion = itemVersions.iterator().next(); - - return Optional.ofNullable(itemVersion); - } - - @Override public Collection<ItemVersion> listPublicVersions(SessionContext context, Id itemId) { return connector.listPublicVersions(context, itemId); } @@ -289,10 +288,4 @@ public class ZusammenAdaptorImpl implements ZusammenAdaptor { public String getVersion(SessionContext context) { return connector.getVersion(context); } - - private static void sortItemVersionListByModificationTimeDescOrder( - List<ItemVersion> itemVersions) { - itemVersions.sort((o1, o2) -> Integer.compare(o2.getId().getValue().length(), - o1.getId().getValue().length())); - } } |