aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api')
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/pom.xml15
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/convertor/ElementConvertor.java37
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenAdaptor.java73
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenUtil.java38
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/types/AsdcElement.java131
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/types/ElementPropertyName.java6
6 files changed, 257 insertions, 43 deletions
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/pom.xml b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/pom.xml
index 538a7fb42a..ee59b5bf77 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/pom.xml
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/pom.xml
@@ -20,6 +20,16 @@
</dependency>
<dependency>
<groupId>org.openecomp.sdc.core</groupId>
+ <artifactId>openecomp-session-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-versioning-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.core</groupId>
<artifactId>openecomp-facade-api</artifactId>
<version>${project.version}</version>
</dependency>
@@ -43,6 +53,11 @@
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
+ <dependency>
+ <groupId>com.amdocs.zusammen</groupId>
+ <artifactId>zusammen-datatypes</artifactId>
+ <version>${zusammen.version}</version>
+ </dependency>
</dependencies>
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/convertor/ElementConvertor.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/convertor/ElementConvertor.java
new file mode 100644
index 0000000000..68c709826f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/convertor/ElementConvertor.java
@@ -0,0 +1,37 @@
+package org.openecomp.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.datatypes.item.Item;
+import com.amdocs.zusammen.datatypes.item.ItemVersion;
+import org.openecomp.sdc.datatypes.model.ElementType;
+import org.openecomp.types.ElementPropertyName;
+
+public abstract class ElementConvertor<T> {
+
+ public static ElementType getElementType(Element element) {
+ return ElementType
+ .valueOf(element.getInfo().getProperty(ElementPropertyName.elementType.name()));
+ }
+
+ public static String getElementName(Element element) {
+ return element.getInfo().getName();
+ }
+
+
+ abstract public T convert(Element element);
+
+ public T convert( ElementInfo elementInfo) {
+ throw new UnsupportedOperationException("convert elementInfo item is not supported ");
+ }
+
+
+ public T convert( Item item) {
+ throw new UnsupportedOperationException("convert from item is not supported ");
+ }
+
+
+ public T convert( ItemVersion itemVersion) {
+ throw new UnsupportedOperationException("convert from itemVersion is not supported ");
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenAdaptor.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenAdaptor.java
index 2ba447fd6a..35c07cbee0 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenAdaptor.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenAdaptor.java
@@ -1,7 +1,9 @@
package org.openecomp.core.zusammen.api;
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;
@@ -11,31 +13,53 @@ 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.Tag;
+import org.openecomp.sdc.versioning.dao.types.Revision;
import java.util.Collection;
+import java.util.List;
import java.util.Optional;
public interface ZusammenAdaptor {
Collection<Item> listItems(SessionContext context);
+ Item getItem(SessionContext context, Id itemId);
+
Id createItem(SessionContext context, Info info);
void updateItem(SessionContext context, Id itemId, Info info);
- // TODO: 4/4/2017 fix this workaround when versionId will be recieved from UI
+ // TODO: 4/4/2017 remove this workaround when versionId will be recieved from UI
Optional<ItemVersion> getFirstVersion(SessionContext context, Id itemId);
+ Collection<ItemVersion> listPublicVersions(SessionContext context, Id itemId);
+
+ ItemVersion getPublicVersion(SessionContext context, Id itemId, Id versionId);
+
Id createVersion(SessionContext context, Id itemId, Id baseVersionId,
ItemVersionData itemVersionData);
void updateVersion(SessionContext context, Id itemId, Id versionId,
ItemVersionData itemVersionData);
+ ItemVersion getVersion(SessionContext context, Id itemId, Id versionId);
+
+ ItemVersionStatus getVersionStatus(SessionContext context, Id itemId, Id versionId);
+
+ ItemVersionConflict getVersionConflict(SessionContext context, Id itemId, Id versionId);
+
void tagVersion(SessionContext context, Id itemId, Id versionId, Tag tag);
- void resetVersionHistory(SessionContext context, Id itemId, Id versionId, String changeRef);
+ void resetVersionHistory(SessionContext context, Id itemId, Id versionId, String version);
+
+ void publishVersion(SessionContext context, Id itemId, Id versionId, String message);
+
+ void syncVersion(SessionContext context, Id itemId, Id versionId);
+
+ void forceSyncVersion(SessionContext context, Id itemId, Id versionId);
Optional<ElementInfo> getElementInfo(SessionContext context, ElementContext elementContext,
Id elementId);
@@ -43,38 +67,39 @@ public interface ZusammenAdaptor {
Optional<Element> getElement(SessionContext context, ElementContext elementContext,
String elementId); // TODO: 4/3/2017 change to Id
- Optional<Element> getElementByName(
- SessionContext context, ElementContext elementContext, Id parentElementId,
- String elementName);
+ Optional<Element> getElementByName(SessionContext context, ElementContext elementContext,
+ Id parentElementId, String elementName);
- Collection<ElementInfo> listElements(SessionContext context,
- ElementContext elementContext,
+ Collection<ElementInfo> listElements(SessionContext context, ElementContext elementContext,
Id parentElementId);
- Collection<Element> listElementData(SessionContext context,
- ElementContext elementContext,
+ Collection<Element> listElementData(SessionContext context, ElementContext elementContext,
Id parentElementId);
/**
- * Lists the sub elements of the element named <elementName> which is a sub element of <parentElementId>
- * @param context
- * @param elementContext
- * @param parentElementId
- * @param elementName
- * @return
+ * Lists the sub elements of the element named elementName which is a sub element of
+ * parentElementId
*/
- Collection<ElementInfo> listElementsByName(
- SessionContext context, ElementContext elementContext, Id parentElementId,
- String elementName);
+ Collection<ElementInfo> listElementsByName(SessionContext context, ElementContext elementContext,
+ Id parentElementId, String elementName);
+
+ Optional<ElementInfo> getElementInfoByName(SessionContext context, ElementContext elementContext,
+ Id parentElementId, String elementName);
- Optional<ElementInfo> getElementInfoByName(
- SessionContext context, ElementContext elementContext, Id parentElementId,
- String elementName);
+ Optional<ElementConflict> getElementConflict(SessionContext context,
+ ElementContext elementContext, Id elementId);
- Optional<Element> saveElement(SessionContext context, ElementContext elementContext,
- ZusammenElement element, String message);
+ Element saveElement(SessionContext context, ElementContext elementContext,
+ ZusammenElement element, String message);
+
+ void resolveElementConflict(SessionContext context, ElementContext elementContext,
+ ZusammenElement element, Resolution resolution);
Collection<HealthInfo> checkHealth(SessionContext context);
- String getVersion(SessionContext sessionContext);
+ String getVersion(SessionContext context);
+
+ void revert(SessionContext sessionContext, String itemId, String versionId, String revisionId);
+
+ List<Revision> listRevisions(SessionContext sessionContext, String itemId, String versionId);
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenUtil.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenUtil.java
index 3df6151fae..623f958ceb 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenUtil.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/core/zusammen/api/ZusammenUtil.java
@@ -1,40 +1,40 @@
package org.openecomp.core.zusammen.api;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.SessionContext;
import com.amdocs.zusammen.datatypes.UserInfo;
import com.amdocs.zusammen.datatypes.item.Action;
import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.datatypes.item.ItemVersionData;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
+import org.openecomp.sdc.datatypes.model.ElementType;
+import org.openecomp.types.ElementPropertyName;
public class ZusammenUtil {
- // TODO: 3/19/2017 add user and tenant args
+
public static SessionContext createSessionContext() {
+ org.openecomp.sdc.common.session.SessionContext asdcSessionContext =
+ SessionContextProviderFactory.getInstance().createInterface().get();
+
SessionContext sessionContext = new SessionContext();
- sessionContext.setUser(new UserInfo("GLOBAL_USER"));
- sessionContext.setTenant("dox");
+ sessionContext.setUser(new UserInfo(asdcSessionContext.getUser().getUserId()));
+ sessionContext.setTenant(asdcSessionContext.getTenant());
return sessionContext;
}
- public static ZusammenElement buildStructuralElement(String structureElementName,
- Action action) {
- ZusammenElement element = new ZusammenElement();
+ public static ZusammenElement buildStructuralElement(ElementType elementType, Action action) {
+ ZusammenElement element = buildElement(null, action);
Info info = new Info();
- info.setName(structureElementName);
+ info.setName(elementType.name());
+ info.addProperty(ElementPropertyName.elementType.name(), elementType.name());
element.setInfo(info);
- if (action != null) {
- element.setAction(action);
- }
return element;
}
- // TODO: 4/24/2017 remove upon working with more than one single version
- public static ItemVersionData createFirstVersionData() {
- Info info = new Info();
- info.setName("main version");
- ItemVersionData itemVersionData = new ItemVersionData();
- itemVersionData.setInfo(info);
- return itemVersionData;
+ public static ZusammenElement buildElement(Id elementId, Action action) {
+ ZusammenElement element = new ZusammenElement();
+ element.setElementId(elementId);
+ element.setAction(action);
+ return element;
}
-
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/types/AsdcElement.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/types/AsdcElement.java
new file mode 100644
index 0000000000..ae9c1fcd44
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/types/AsdcElement.java
@@ -0,0 +1,131 @@
+package org.openecomp.types;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Relation;
+import com.amdocs.zusammen.utils.fileutils.FileUtils;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+
+public class AsdcElement implements Element {
+
+ private String type;
+ private String name;
+ private String description;
+
+ private Map<String, Object> properties;
+ private byte[] data;
+ private Collection<Relation> relations;
+ private Collection<Element> subElements = new ArrayList<>();
+ private Action action;
+ private Id elementId;
+
+ @Override
+ public Action getAction() {
+ return this.action;
+ }
+
+ @Override
+ public Id getElementId() {
+ return this.elementId;
+ }
+
+ @Override
+ public Info getInfo() {
+ Info info = new Info();
+ info.setProperties(this.properties);
+ info.addProperty(ElementPropertyName.elementType.name(), this.type != null ? this.type : this.name);
+ info.setName(this.name);
+ info.setDescription(this.description);
+
+ return info;
+ }
+
+ @Override
+ public Collection<Relation> getRelations() {
+ return this.relations;
+ }
+
+ @Override
+ public InputStream getData() {
+ return FileUtils.toInputStream(this.data);
+ }
+
+ @Override
+ public InputStream getSearchableData() {
+ return null;
+ }
+
+ @Override
+ public InputStream getVisualization() {
+ return null;
+ }
+
+
+ @Override
+ public Collection<Element> getSubElements() {
+ return this.subElements;
+ }
+
+ public void setElementId(Id elementId) {
+ this.elementId = elementId;
+ }
+
+ public void setData(InputStream data) {
+ this.data = FileUtils.toByteArray(data);
+ }
+
+ public void setRelations(Collection<Relation> relations) {
+ this.relations = relations;
+ }
+
+ public void setSubElements(Collection<Element> subElements) {
+ this.subElements = subElements;
+ }
+
+ public void setAction(Action action) {
+ this.action = action;
+ }
+
+ public AsdcElement addSubElement(Element element) {
+ this.subElements.add(element);
+ return this;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Map<String, Object> properties) {
+ this.properties = properties;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/types/ElementPropertyName.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/types/ElementPropertyName.java
new file mode 100644
index 0000000000..ddbef7d8a4
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-api/src/main/java/org/openecomp/types/ElementPropertyName.java
@@ -0,0 +1,6 @@
+package org.openecomp.types;
+
+public enum ElementPropertyName {
+ elementType,
+ compositionData
+}