aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-conflict-manager
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-03-22 15:33:06 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-03-24 06:59:47 +0000
commitd378c37fbd1ecec7b43394926f1ca32a695e07de (patch)
tree5c8a085f8732f980d871d966ac49361644efa698 /openecomp-be/backend/openecomp-sdc-conflict-manager
parenta6ae7294ecd336d7e88f915710b08e2658eaee00 (diff)
Reformat openecomp-be
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3449 Change-Id: I13e02322f8e00820cc5a1d85752caaeda9bf10d1
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-conflict-manager')
-rw-r--r--openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManager.java16
-rw-r--r--openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManagerFactory.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerFactoryImpl.java13
-rw-r--r--openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerImpl.java139
4 files changed, 67 insertions, 103 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManager.java b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManager.java
index 28c32e049f..1231469f31 100644
--- a/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManager.java
+++ b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManager.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.conflicts;
import org.openecomp.conflicts.types.Conflict;
@@ -27,14 +26,13 @@ import org.openecomp.sdc.versioning.dao.types.Version;
public interface ConflictsManager {
- boolean isConflicted(String itemId, Version version);
+ boolean isConflicted(String itemId, Version version);
- ItemVersionConflict getConflict(String itemId, Version version);
+ ItemVersionConflict getConflict(String itemId, Version version);
- void finalizeMerge(String itemId, Version version);
+ void finalizeMerge(String itemId, Version version);
- Conflict getConflict(String itemId, Version version, String conflictId);
+ Conflict getConflict(String itemId, Version version, String conflictId);
- void resolveConflict(String itemId, Version version, String conflictId,
- ConflictResolution resolution);
+ void resolveConflict(String itemId, Version version, String conflictId, ConflictResolution resolution);
}
diff --git a/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManagerFactory.java b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManagerFactory.java
index 7a24cfd311..b13a4329c3 100644
--- a/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManagerFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/ConflictsManagerFactory.java
@@ -22,8 +22,8 @@ package org.openecomp.sdc.conflicts;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
-
public abstract class ConflictsManagerFactory extends AbstractComponentFactory<ConflictsManager> {
+
public static ConflictsManagerFactory getInstance() {
return AbstractFactory.getInstance(ConflictsManagerFactory.class);
}
diff --git a/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerFactoryImpl.java
index 2d703c4a87..72347580b0 100644
--- a/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerFactoryImpl.java
@@ -19,17 +19,16 @@
*/
package org.openecomp.sdc.conflicts.impl;
-
import org.openecomp.conflicts.dao.ConflictsDaoFactory;
import org.openecomp.sdc.conflicts.ConflictsManager;
import org.openecomp.sdc.conflicts.ConflictsManagerFactory;
public class ConflictsManagerFactoryImpl extends ConflictsManagerFactory {
- private static final ConflictsManager INSTANCE =
- new ConflictsManagerImpl(ConflictsDaoFactory.getInstance().createInterface());
- @Override
- public ConflictsManager createInterface() {
- return INSTANCE;
- }
+ private static final ConflictsManager INSTANCE = new ConflictsManagerImpl(ConflictsDaoFactory.getInstance().createInterface());
+
+ @Override
+ public ConflictsManager createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerImpl.java b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerImpl.java
index 284823baac..5ae23783c4 100644
--- a/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-conflict-manager/src/main/java/org/openecomp/sdc/conflicts/impl/ConflictsManagerImpl.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,9 +17,9 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.conflicts.impl;
+import java.util.Optional;
import org.openecomp.conflicts.ItemMergeHandler;
import org.openecomp.conflicts.ItemMergeHandlerFactory;
import org.openecomp.conflicts.dao.ConflictsDao;
@@ -33,100 +33,67 @@ import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.conflicts.ConflictsManager;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Optional;
-
public class ConflictsManagerImpl implements ConflictsManager {
- private static final String ELEMENT_CONFLICT_NOT_EXIST_ERR_ID = "ELEMENT_CONFLICT_NOT_EXIST";
- private static final String ELEMENT_CONFLICT_NOT_EXISTS_MSG =
- "Item Id %s, version Id %s, element conflict with Id %s does not exists.";
-
- private final ConflictsDao conflictsDao;
-
- public ConflictsManagerImpl(ConflictsDao conflictsDao) {
- this.conflictsDao = conflictsDao;
- }
-
- @Override
- public boolean isConflicted(String itemId, Version version) {
- Optional<ItemMergeHandler> itemMergeHandler =
- ItemMergeHandlerFactory.getInstance().createInterface(itemId);
-
- return conflictsDao.isConflicted(itemId, version) ||
- (itemMergeHandler.isPresent() &&
- itemMergeHandler.get().isConflicted(itemId, version));
- }
-
- @Override
- public ItemVersionConflict getConflict(String itemId, Version version) {
- ItemVersionConflict conflicts = conflictsDao.getConflict(itemId, version);
+ private static final String ELEMENT_CONFLICT_NOT_EXIST_ERR_ID = "ELEMENT_CONFLICT_NOT_EXIST";
+ private static final String ELEMENT_CONFLICT_NOT_EXISTS_MSG = "Item Id %s, version Id %s, element conflict with Id %s does not exists.";
+ private final ConflictsDao conflictsDao;
- ItemMergeHandlerFactory.getInstance().createInterface(itemId)
- .ifPresent(itemMergeHandler -> itemMergeHandler
- .postListConflicts(itemId, version, conflicts));
-
- return conflicts;
- }
-
- @Override
- public void finalizeMerge(String itemId, Version version) {
- ItemMergeHandlerFactory.getInstance().createInterface(itemId)
- .ifPresent(mergeHandler -> mergeHandler.finalizeMerge(itemId, version));
- }
-
- @Override
- public Conflict getConflict(String itemId, Version version, String conflictId) {
- Optional<ItemMergeHandler> itemMergeHandler =
- ItemMergeHandlerFactory.getInstance().createInterface(itemId);
- if (itemMergeHandler.isPresent()) {
- Optional<Conflict> conflict =
- itemMergeHandler.get().getConflict(itemId, version, conflictId);
- if (conflict.isPresent()) {
- return conflict.get();
- }
+ public ConflictsManagerImpl(ConflictsDao conflictsDao) {
+ this.conflictsDao = conflictsDao;
}
- Conflict conflict = conflictsDao.getConflict(itemId, version, conflictId);
-
- itemMergeHandler.ifPresent(mergeHandler ->
- mergeHandler.postGetConflict(itemId, version, conflict));
-
- if (conflict == null) {
- throw getConflictNotExistException(itemId, version, conflictId);
+ @Override
+ public boolean isConflicted(String itemId, Version version) {
+ Optional<ItemMergeHandler> itemMergeHandler = ItemMergeHandlerFactory.getInstance().createInterface(itemId);
+ return conflictsDao.isConflicted(itemId, version) || (itemMergeHandler.isPresent() && itemMergeHandler.get().isConflicted(itemId, version));
}
- return conflict;
- }
- @Override
- public void resolveConflict(String itemId, Version version, String conflictId,
- ConflictResolution resolution) {
- if (Resolution.OTHER.equals(resolution.getResolution())) {
- throw new UnsupportedOperationException(
- "Resolution other than 'THEIRS' or 'YOURS' is not supported.");
+ @Override
+ public ItemVersionConflict getConflict(String itemId, Version version) {
+ ItemVersionConflict conflicts = conflictsDao.getConflict(itemId, version);
+ ItemMergeHandlerFactory.getInstance().createInterface(itemId)
+ .ifPresent(itemMergeHandler -> itemMergeHandler.postListConflicts(itemId, version, conflicts));
+ return conflicts;
}
- Optional<ItemMergeHandler> itemMergeHandler =
- ItemMergeHandlerFactory.getInstance().createInterface(itemId);
- if (!itemMergeHandler.isPresent() ||
- !itemMergeHandler.get()
- .resolveConflict(itemId, version, conflictId, resolution)) {
-
- getConflict(itemId, version, conflictId); // validate that the conflict exist
- itemMergeHandler.ifPresent(mergeHandler ->
- mergeHandler.preResolveConflict(itemId, version, conflictId, resolution));
+ @Override
+ public void finalizeMerge(String itemId, Version version) {
+ ItemMergeHandlerFactory.getInstance().createInterface(itemId).ifPresent(mergeHandler -> mergeHandler.finalizeMerge(itemId, version));
+ }
- conflictsDao.resolveConflict(itemId, version, conflictId, resolution);
+ @Override
+ public Conflict getConflict(String itemId, Version version, String conflictId) {
+ Optional<ItemMergeHandler> itemMergeHandler = ItemMergeHandlerFactory.getInstance().createInterface(itemId);
+ if (itemMergeHandler.isPresent()) {
+ Optional<Conflict> conflict = itemMergeHandler.get().getConflict(itemId, version, conflictId);
+ if (conflict.isPresent()) {
+ return conflict.get();
+ }
+ }
+ Conflict conflict = conflictsDao.getConflict(itemId, version, conflictId);
+ itemMergeHandler.ifPresent(mergeHandler -> mergeHandler.postGetConflict(itemId, version, conflict));
+ if (conflict == null) {
+ throw getConflictNotExistException(itemId, version, conflictId);
+ }
+ return conflict;
}
- }
- private CoreException getConflictNotExistException(String itemId, Version version,
- String conflictId) {
- return new CoreException(new ErrorCode.ErrorCodeBuilder()
- .withCategory(ErrorCategory.APPLICATION)
- .withId(ELEMENT_CONFLICT_NOT_EXIST_ERR_ID)
- .withMessage(
- String.format(ELEMENT_CONFLICT_NOT_EXISTS_MSG, itemId, version.getId(), conflictId))
- .build());
- }
+ @Override
+ public void resolveConflict(String itemId, Version version, String conflictId, ConflictResolution resolution) {
+ if (Resolution.OTHER.equals(resolution.getResolution())) {
+ throw new UnsupportedOperationException("Resolution other than 'THEIRS' or 'YOURS' is not supported.");
+ }
+ Optional<ItemMergeHandler> itemMergeHandler = ItemMergeHandlerFactory.getInstance().createInterface(itemId);
+ if (!itemMergeHandler.isPresent() || !itemMergeHandler.get().resolveConflict(itemId, version, conflictId, resolution)) {
+ getConflict(itemId, version, conflictId); // validate that the conflict exist
+ itemMergeHandler.ifPresent(mergeHandler -> mergeHandler.preResolveConflict(itemId, version, conflictId, resolution));
+ conflictsDao.resolveConflict(itemId, version, conflictId, resolution);
+ }
+ }
+ private CoreException getConflictNotExistException(String itemId, Version version, String conflictId) {
+ return new CoreException(new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).withId(ELEMENT_CONFLICT_NOT_EXIST_ERR_ID)
+ .withMessage(String.format(ELEMENT_CONFLICT_NOT_EXISTS_MSG, itemId, version.getId(), conflictId)).build());
+ }
}