summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin
diff options
context:
space:
mode:
authoravigaffa <avi.gaffa@amdocs.com>2017-12-31 15:07:39 +0200
committervempo <vitaliy.emporopulo@amdocs.com>2018-01-02 09:41:41 +0200
commitda5dfcd1a354807d13849c7f4ead535ccfa722fa (patch)
treeb4ef0b97d4c25a38bf4a7a8aa5d3626d6b820a17 /openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin
parent25ca73d85757869a6d9cc33861070778503ff153 (diff)
Fixing sonar Exception Handling
Change-Id: I04eb047973a3f5c07dd9dc410cb13af974e8ded1 Issue-ID: SDC-810 Signed-off-by: avigaffa <avi.gaffa@amdocs.com> Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin')
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/ZusammenPluginUtil.java43
1 files changed, 9 insertions, 34 deletions
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/ZusammenPluginUtil.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/ZusammenPluginUtil.java
index a973590eb5..c285bf8fae 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/ZusammenPluginUtil.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-plugin/src/main/java/org/openecomp/core/zusammen/plugin/ZusammenPluginUtil.java
@@ -24,16 +24,15 @@ import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.ItemVersion;
import com.amdocs.zusammen.datatypes.item.ItemVersionChange;
import com.amdocs.zusammen.datatypes.item.ItemVersionData;
-import com.amdocs.zusammen.datatypes.item.ItemVersionDataConflict;
import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElement;
import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElementChange;
-import com.amdocs.zusammen.sdk.collaboration.types.CollaborationElementConflict;
import com.amdocs.zusammen.sdk.state.types.StateElement;
import com.amdocs.zusammen.sdk.types.ElementDescriptor;
import com.amdocs.zusammen.utils.fileutils.FileUtils;
import com.amdocs.zusammen.utils.fileutils.json.JsonUtil;
import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
import org.openecomp.core.zusammen.plugin.dao.types.VersionEntity;
+import org.openecomp.sdc.common.errors.SdcRuntimeException;
import java.io.ByteArrayInputStream;
import java.nio.ByteBuffer;
@@ -46,6 +45,10 @@ import static org.openecomp.core.zusammen.plugin.ZusammenPluginConstants.ROOT_EL
public class ZusammenPluginUtil {
+ private ZusammenPluginUtil() {
+ // prevent instantiation
+ }
+
public static String getSpaceName(SessionContext context, Space space) {
switch (space) {
case PUBLIC:
@@ -69,14 +72,6 @@ public class ZusammenPluginUtil {
public static VersionEntity convertToVersionEntity(Id versionId, Id baseVersionId,
Date creationTime,
Date modificationTime) {
-
- return convertToVersionEntity(versionId, null, baseVersionId,
- creationTime, modificationTime);
- }
-
- public static VersionEntity convertToVersionEntity(Id versionId, Id revisionId, Id baseVersionId,
- Date creationTime,
- Date modificationTime) {
VersionEntity version = new VersionEntity(versionId);
version.setBaseId(baseVersionId);
version.setCreationTime(creationTime);
@@ -180,25 +175,6 @@ public class ZusammenPluginUtil {
return versionChange;
}
- public static ItemVersionDataConflict getVersionConflict(ElementEntity localVesionData,
- ElementEntity remoteVersionData) {
- ItemVersionDataConflict versionConflict = new ItemVersionDataConflict();
- versionConflict.setLocalData(convertToVersionData(localVesionData));
- versionConflict.setRemoteData(convertToVersionData(remoteVersionData));
- return versionConflict;
- }
-
- public static CollaborationElementConflict getElementConflict(ElementContext elementContext,
- ElementEntity localElement,
- ElementEntity remoteElement) {
- CollaborationElementConflict elementConflict = new CollaborationElementConflict();
- elementConflict
- .setLocalElement(convertToCollaborationElement(elementContext, localElement));
- elementConflict.setRemoteElement(
- convertToCollaborationElement(elementContext, remoteElement));
- return elementConflict;
- }
-
public static ItemVersionData convertToVersionData(ElementEntity versionDataElement) {
ItemVersionData versionData = new ItemVersionData();
versionData.setInfo(versionDataElement.getInfo());
@@ -219,7 +195,8 @@ public class ZusammenPluginUtil {
}
public static String calculateElementHash(ElementEntity elementEntity) {
- StringBuffer elementHash = new StringBuffer();
+
+ StringBuilder elementHash = new StringBuilder();
if (elementEntity.getData() != null) {
elementHash.append(calculateSHA1(elementEntity.getData().array()));
} else {
@@ -258,13 +235,11 @@ public class ZusammenPluginUtil {
}
private static String calculateSHA1(byte[] content2Convert) {
- MessageDigest md = null;
try {
- md = MessageDigest.getInstance("SHA-1");
+ return Base64.getEncoder().encodeToString(MessageDigest.getInstance("SHA-1").digest(content2Convert));
} catch (NoSuchAlgorithmException e) {
- throw new RuntimeException(e);
+ throw new SdcRuntimeException(e);
}
- return Base64.getEncoder().encodeToString(md.digest(content2Convert));
}