summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core')
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoFactoryImpl.java17
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoImpl.java184
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionDaoFactoryImpl.java17
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionDaoImpl.java246
4 files changed, 194 insertions, 270 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoFactoryImpl.java
index 5c308e7f64..a37745bbae 100644
--- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoFactoryImpl.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,18 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.action.dao.impl;
import org.openecomp.sdc.action.dao.ActionArtifactDao;
import org.openecomp.sdc.action.dao.ActionArtifactDaoFactory;
-
public class ActionArtifactDaoFactoryImpl extends ActionArtifactDaoFactory {
- private static ActionArtifactDao instance = new ActionArtifactDaoImpl();
- @Override
- public ActionArtifactDao createInterface() {
- return instance;
- }
+ private static ActionArtifactDao instance = new ActionArtifactDaoImpl();
+
+ @Override
+ public ActionArtifactDao createInterface() {
+ return instance;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoImpl.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoImpl.java
index f9e0b00ff8..f8c2482fe9 100644
--- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoImpl.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,14 +17,23 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.action.dao.impl;
+import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.COMPLETE;
+import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.ERROR;
+import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY_DB;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INTERNAL_SERVER_ERR_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_QUERY_FAILURE_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_QUERY_FAILURE_MSG;
+
import com.datastax.driver.core.exceptions.NoHostAvailableException;
import com.datastax.driver.mapping.Mapper;
import com.datastax.driver.mapping.Result;
import com.datastax.driver.mapping.annotations.Accessor;
import com.datastax.driver.mapping.annotations.Query;
+import java.util.Collection;
+import java.util.List;
import org.openecomp.core.dao.impl.CassandraBaseDao;
import org.openecomp.core.nosqldb.api.NoSqlDb;
import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
@@ -38,111 +47,92 @@ import org.openecomp.sdc.action.util.ActionUtil;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-import java.util.Collection;
-import java.util.List;
-
-import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.COMPLETE;
-import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.ERROR;
-import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY_DB;
-import static org.openecomp.sdc.action.errors.ActionErrorConstants.*;
-
-
-public class ActionArtifactDaoImpl extends CassandraBaseDao<ActionArtifactEntity>
- implements ActionArtifactDao {
- private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
- private static Mapper<ActionArtifactEntity> mapper =
- noSqlDb.getMappingManager().mapper(ActionArtifactEntity.class);
- private static ActionArtifactAccessor accessor =
- noSqlDb.getMappingManager().createAccessor(ActionArtifactAccessor.class);
- private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
+public class ActionArtifactDaoImpl extends CassandraBaseDao<ActionArtifactEntity> implements ActionArtifactDao {
- @Override
- protected Mapper<ActionArtifactEntity> getMapper() {
- return mapper;
- }
+ private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static Mapper<ActionArtifactEntity> mapper = noSqlDb.getMappingManager().mapper(ActionArtifactEntity.class);
+ private static ActionArtifactAccessor accessor = noSqlDb.getMappingManager().createAccessor(ActionArtifactAccessor.class);
+ private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
- @Override
- protected Object[] getKeys(ActionArtifactEntity entity) {
- return new Object[]{entity.getArtifactUuId(), entity.getEffectiveVersion()};
- }
+ @Override
+ protected Mapper<ActionArtifactEntity> getMapper() {
+ return mapper;
+ }
- @Override
- public Collection<ActionArtifactEntity> list(ActionArtifactEntity entity) {
- return null;
- }
+ @Override
+ protected Object[] getKeys(ActionArtifactEntity entity) {
+ return new Object[]{entity.getArtifactUuId(), entity.getEffectiveVersion()};
+ }
+ @Override
+ public Collection<ActionArtifactEntity> list(ActionArtifactEntity entity) {
+ return null;
+ }
- @Override
- public void uploadArtifact(ActionArtifact data) {
- log.debug(" entering uploadArtifact with artifactName= " + data.getArtifactName());
- try {
- ActionUtil.actionLogPreProcessor(ActionSubOperation.CREATE_ACTION_ARTIFACT, TARGET_ENTITY_DB);
- this.create(data.toEntity());
- ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false);
- log.metrics("");
- } catch (NoHostAvailableException noHostAvailableException) {
- logGenericException(noHostAvailableException);
- throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE,
- ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
+ @Override
+ public void uploadArtifact(ActionArtifact data) {
+ log.debug(" entering uploadArtifact with artifactName= " + data.getArtifactName());
+ try {
+ ActionUtil.actionLogPreProcessor(ActionSubOperation.CREATE_ACTION_ARTIFACT, TARGET_ENTITY_DB);
+ this.create(data.toEntity());
+ ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false);
+ log.metrics("");
+ } catch (NoHostAvailableException noHostAvailableException) {
+ logGenericException(noHostAvailableException);
+ throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
+ }
+ log.debug(" exit uploadArtifact with artifactName= " + data.getArtifactName());
}
- log.debug(" exit uploadArtifact with artifactName= " + data.getArtifactName());
- }
- @Override
- public ActionArtifact downloadArtifact(int effectiveVersion, String artifactUuId) {
- log.debug(" entering downloadArtifact with artifactUUID= " + artifactUuId);
- ActionArtifact actionArtifact = null;
- try {
- ActionUtil
- .actionLogPreProcessor(ActionSubOperation.GET_ARTIFACT_BY_ARTIFACTUUID, TARGET_ENTITY_DB);
- Result<ActionArtifactEntity> result = null;
- result = accessor.getArtifactByUuId(effectiveVersion, artifactUuId);
- ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false);
- log.metrics("");
- List<ActionArtifactEntity> artifactEntities = result.all();
- if (artifactEntities != null && !artifactEntities.isEmpty()) {
- ActionArtifactEntity artifactEntity = artifactEntities.get(0);
- actionArtifact = artifactEntity.toDto();
- }
- } catch (NoHostAvailableException noHostAvailableException) {
- logGenericException(noHostAvailableException);
- throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE,
- ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
+ @Override
+ public ActionArtifact downloadArtifact(int effectiveVersion, String artifactUuId) {
+ log.debug(" entering downloadArtifact with artifactUUID= " + artifactUuId);
+ ActionArtifact actionArtifact = null;
+ try {
+ ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ARTIFACT_BY_ARTIFACTUUID, TARGET_ENTITY_DB);
+ Result<ActionArtifactEntity> result = null;
+ result = accessor.getArtifactByUuId(effectiveVersion, artifactUuId);
+ ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false);
+ log.metrics("");
+ List<ActionArtifactEntity> artifactEntities = result.all();
+ if (artifactEntities != null && !artifactEntities.isEmpty()) {
+ ActionArtifactEntity artifactEntity = artifactEntities.get(0);
+ actionArtifact = artifactEntity.toDto();
+ }
+ } catch (NoHostAvailableException noHostAvailableException) {
+ logGenericException(noHostAvailableException);
+ throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
+ }
+ log.debug(" exit downloadArtifact with artifactUUID= " + artifactUuId);
+ return actionArtifact;
}
- log.debug(" exit downloadArtifact with artifactUUID= " + artifactUuId);
- return actionArtifact;
- }
- @Override
- public void updateArtifact(ActionArtifact data) {
- log.debug(" entering updateArtifact with artifactName= " + data.getArtifactName());
- try {
- ActionUtil.actionLogPreProcessor(ActionSubOperation.UPDATE_ACTION_ARTIFACT, TARGET_ENTITY_DB);
- this.update(data.toEntity());
- ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false);
- log.metrics("");
- } catch (NoHostAvailableException noHostAvailableException) {
- logGenericException(noHostAvailableException);
- throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE,
- ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
+ @Override
+ public void updateArtifact(ActionArtifact data) {
+ log.debug(" entering updateArtifact with artifactName= " + data.getArtifactName());
+ try {
+ ActionUtil.actionLogPreProcessor(ActionSubOperation.UPDATE_ACTION_ARTIFACT, TARGET_ENTITY_DB);
+ this.update(data.toEntity());
+ ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false);
+ log.metrics("");
+ } catch (NoHostAvailableException noHostAvailableException) {
+ logGenericException(noHostAvailableException);
+ throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
+ }
+ log.debug(" exit updateArtifact with artifactName= " + data.getArtifactName());
}
- log.debug(" exit updateArtifact with artifactName= " + data.getArtifactName());
- }
- private void logGenericException(Exception exception) {
- ActionUtil.actionLogPostProcessor(ERROR, ACTION_QUERY_FAILURE_CODE,
- ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG, false);
- log.metrics("");
- ActionUtil.actionErrorLogProcessor(CategoryLogLevel.FATAL, ACTION_QUERY_FAILURE_CODE,
- ACTION_QUERY_FAILURE_MSG);
- log.error(exception.getMessage());
- }
+ private void logGenericException(Exception exception) {
+ ActionUtil.actionLogPostProcessor(ERROR, ACTION_QUERY_FAILURE_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG, false);
+ log.metrics("");
+ ActionUtil.actionErrorLogProcessor(CategoryLogLevel.FATAL, ACTION_QUERY_FAILURE_CODE, ACTION_QUERY_FAILURE_MSG);
+ log.error(exception.getMessage());
+ }
- @Accessor
- interface ActionArtifactAccessor {
+ @Accessor
+ interface ActionArtifactAccessor {
- @Query(
- "SELECT * FROM action_artifact WHERE effective_version <= ? and artifactuuid = ? limit 1")
- Result<ActionArtifactEntity> getArtifactByUuId(int effectiveVersion, String artifactUuId);
- }
+ @Query("SELECT * FROM action_artifact WHERE effective_version <= ? and artifactuuid = ? limit 1")
+ Result<ActionArtifactEntity> getArtifactByUuId(int effectiveVersion, String artifactUuId);
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionDaoFactoryImpl.java
index 72279d41fd..285e54fde7 100644
--- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionDaoFactoryImpl.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,18 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.action.dao.impl;
import org.openecomp.sdc.action.dao.ActionDao;
import org.openecomp.sdc.action.dao.ActionDaoFactory;
-
public class ActionDaoFactoryImpl extends ActionDaoFactory {
- private static ActionDao instance = new ActionDaoImpl();
- @Override
- public ActionDao createInterface() {
- return instance;
- }
+ private static ActionDao instance = new ActionDaoImpl();
+
+ @Override
+ public ActionDao createInterface() {
+ return instance;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionDaoImpl.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionDaoImpl.java
index f22fa08ee3..cdd2d5a02e 100644
--- a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionDaoImpl.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.sdc.action.dao.impl;
import static com.datastax.driver.core.querybuilder.QueryBuilder.eq;
@@ -51,7 +50,6 @@ import com.datastax.driver.mapping.Mapper;
import com.datastax.driver.mapping.Result;
import com.datastax.driver.mapping.annotations.Accessor;
import com.datastax.driver.mapping.annotations.Query;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -60,7 +58,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-
import org.openecomp.core.dao.impl.CassandraBaseDao;
import org.openecomp.core.nosqldb.api.NoSqlDb;
import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
@@ -90,37 +87,22 @@ import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
import org.slf4j.MDC;
public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements ActionDao {
+
private static final String FOR_VERSIONS = " for versions ";
private static final String VERSION = "version";
private static final String ACTION = "Action";
- private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance()
- .createInterface();
- private static Mapper<ActionEntity> mapper = noSqlDb.getMappingManager()
- .mapper(ActionEntity.class);
- private static ActionAccessor accessor = noSqlDb.getMappingManager()
- .createAccessor(ActionAccessor.class);
- private static VersionInfoDao versionInfoDao = VersionInfoDaoFactory.getInstance()
- .createInterface();
- private static VersionInfoDeletedDao versionInfoDeletedDao = VersionInfoDeletedDaoFactory.getInstance()
- .createInterface();
-
- private final Logger log = LoggerFactory.getLogger(this.getClass()
- .getName());
+ private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static Mapper<ActionEntity> mapper = noSqlDb.getMappingManager().mapper(ActionEntity.class);
+ private static ActionAccessor accessor = noSqlDb.getMappingManager().createAccessor(ActionAccessor.class);
+ private static VersionInfoDao versionInfoDao = VersionInfoDaoFactory.getInstance().createInterface();
+ private static VersionInfoDeletedDao versionInfoDeletedDao = VersionInfoDeletedDaoFactory.getInstance().createInterface();
+ private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
@Override
public void registerVersioning(String versionableEntityType) {
- ActionVersioningManagerFactory.getInstance()
- .createInterface()
- .register(versionableEntityType, new VersionableEntityMetadata(mapper.getTableMetadata()
- .getName(),
- mapper.getTableMetadata()
- .getPartitionKey()
- .get(0)
- .getName(),
- mapper.getTableMetadata()
- .getPartitionKey()
- .get(1)
- .getName()));
+ ActionVersioningManagerFactory.getInstance().createInterface().register(versionableEntityType,
+ new VersionableEntityMetadata(mapper.getTableMetadata().getName(), mapper.getTableMetadata().getPartitionKey().get(0).getName(),
+ mapper.getTableMetadata().getPartitionKey().get(1).getName()));
}
@Override
@@ -159,24 +141,18 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act
log.debug("entering deleteAction with actionInvariantUuId = " + actionInvariantUuId);
ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
VersionInfoDeletedEntity activeVersionEntity = versionInfoDeletedDao
- .get(new VersionInfoDeletedEntity(ActionConstants.ACTION_VERSIONABLE_TYPE, actionInvariantUuId));
+ .get(new VersionInfoDeletedEntity(ActionConstants.ACTION_VERSIONABLE_TYPE, actionInvariantUuId));
ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false);
log.metrics("");
-
Version activeVersion = activeVersionEntity.getActiveVersion();
- Statement getNameFromInvUuId = QueryBuilder.select()
- .column("name")
- .from("dox", ACTION)
- .where(eq("actioninvariantuuid", actionInvariantUuId))
- .and(in(VERSION, activeVersion));
+ Statement getNameFromInvUuId = QueryBuilder.select().column("name").from("dox", ACTION)
+ .where(eq("actioninvariantuuid", actionInvariantUuId)).and(in(VERSION, activeVersion));
ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_NAME_BY_ACTIONINVID, TARGET_ENTITY_DB);
ResultSet results = getSession().execute(getNameFromInvUuId);
ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false);
log.metrics("");
-
if (!results.isExhausted()) {
- String name = results.one()
- .getString("name");
+ String name = results.one().getString("name");
List<Version> versions = getVersionsByName(name);
updateActionStatusForDelete(actionInvariantUuId, versions);
}
@@ -194,60 +170,56 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act
log.debug(" entering getFilteredActions By filterType = " + filterType + " With value = " + filterId);
try {
switch (filterType) {
- case FILTER_TYPE_VENDOR:
- ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_VENDOR, TARGET_ENTITY_DB);
- result = accessor.getActionsByVendor(filterId);
- ActionUtil.actionLogPostProcessor(COMPLETE);
- log.metrics("");
- break;
- case FILTER_TYPE_CATEGORY:
- ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_CATEGORY, TARGET_ENTITY_DB);
- result = accessor.getActionsByCategory(filterId);
- ActionUtil.actionLogPostProcessor(COMPLETE);
- log.metrics("");
- break;
- case FILTER_TYPE_MODEL:
- ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_MODEL, TARGET_ENTITY_DB);
- result = accessor.getActionsByModel(filterId);
- ActionUtil.actionLogPostProcessor(COMPLETE);
- log.metrics("");
- break;
- case FILTER_TYPE_OPEN_ECOMP_COMPONENT:
- ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_COMPONENT, TARGET_ENTITY_DB);
- result = accessor.getActionsByOpenEcompComponent(filterId);
- ActionUtil.actionLogPostProcessor(COMPLETE);
- log.metrics("");
- break;
- case FILTER_TYPE_NONE:
- ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ALL_ACTIONS, TARGET_ENTITY_DB);
- result = accessor.getAllActions();
- ActionUtil.actionLogPostProcessor(COMPLETE);
- log.metrics("");
- break;
- case FILTER_TYPE_NAME:
- ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONINVID_BY_NAME, TARGET_ENTITY_DB);
- result = accessor.getInvIdByName(filterId);
- ActionUtil.actionLogPostProcessor(COMPLETE);
- log.metrics("");
- List<ActionEntity> actionEntities = result.all();
- if (actionEntities != null && !actionEntities.isEmpty()) {
- String actionInvariantUuId = actionEntities.get(0)
- .getActionInvariantUuId();
- if (actionInvariantUuId != null) {
- return getActionsByActionInvariantUuId(actionInvariantUuId);
- } else {
- return actions;
+ case FILTER_TYPE_VENDOR:
+ ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_VENDOR, TARGET_ENTITY_DB);
+ result = accessor.getActionsByVendor(filterId);
+ ActionUtil.actionLogPostProcessor(COMPLETE);
+ log.metrics("");
+ break;
+ case FILTER_TYPE_CATEGORY:
+ ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_CATEGORY, TARGET_ENTITY_DB);
+ result = accessor.getActionsByCategory(filterId);
+ ActionUtil.actionLogPostProcessor(COMPLETE);
+ log.metrics("");
+ break;
+ case FILTER_TYPE_MODEL:
+ ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_MODEL, TARGET_ENTITY_DB);
+ result = accessor.getActionsByModel(filterId);
+ ActionUtil.actionLogPostProcessor(COMPLETE);
+ log.metrics("");
+ break;
+ case FILTER_TYPE_OPEN_ECOMP_COMPONENT:
+ ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_COMPONENT, TARGET_ENTITY_DB);
+ result = accessor.getActionsByOpenEcompComponent(filterId);
+ ActionUtil.actionLogPostProcessor(COMPLETE);
+ log.metrics("");
+ break;
+ case FILTER_TYPE_NONE:
+ ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ALL_ACTIONS, TARGET_ENTITY_DB);
+ result = accessor.getAllActions();
+ ActionUtil.actionLogPostProcessor(COMPLETE);
+ log.metrics("");
+ break;
+ case FILTER_TYPE_NAME:
+ ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONINVID_BY_NAME, TARGET_ENTITY_DB);
+ result = accessor.getInvIdByName(filterId);
+ ActionUtil.actionLogPostProcessor(COMPLETE);
+ log.metrics("");
+ List<ActionEntity> actionEntities = result.all();
+ if (actionEntities != null && !actionEntities.isEmpty()) {
+ String actionInvariantUuId = actionEntities.get(0).getActionInvariantUuId();
+ if (actionInvariantUuId != null) {
+ return getActionsByActionInvariantUuId(actionInvariantUuId);
+ } else {
+ return actions;
+ }
}
- }
- break;
- default:
- break;
+ break;
+ default:
+ break;
}
if (result != null) {
- actions.addAll(result.all()
- .stream()
- .map(ActionEntity::toDto)
- .collect(Collectors.toList()));
+ actions.addAll(result.all().stream().map(ActionEntity::toDto).collect(Collectors.toList()));
}
log.debug(" exit getFilteredActions By filterType = " + filterType + " With value = " + filterId);
} catch (NoHostAvailableException noHostAvailableException) {
@@ -291,10 +263,7 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act
ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false);
log.metrics("");
if (result != null) {
- openEcompComponents.addAll(result.all()
- .stream()
- .map(OpenEcompComponentEntity::toDto)
- .collect(Collectors.toList()));
+ openEcompComponents.addAll(result.all().stream().map(OpenEcompComponentEntity::toDto).collect(Collectors.toList()));
}
} catch (NoHostAvailableException noHostAvailableException) {
logGenericException(noHostAvailableException);
@@ -313,11 +282,11 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act
VersionPredicate filter = new VersionPredicate();
ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
VersionInfoEntity versionInfoEntity = versionInfoDao
- .get(new VersionInfoEntity(ActionConstants.ACTION_VERSIONABLE_TYPE, actionInvariantUuId));
+ .get(new VersionInfoEntity(ActionConstants.ACTION_VERSIONABLE_TYPE, actionInvariantUuId));
if (versionInfoEntity == null) {
// Check for action in the Delete version info table
- VersionInfoDeletedEntity versionInfoDeletedEntity = versionInfoDeletedDao.get(
- new VersionInfoDeletedEntity(ActionConstants.ACTION_VERSIONABLE_TYPE, actionInvariantUuId));
+ VersionInfoDeletedEntity versionInfoDeletedEntity = versionInfoDeletedDao
+ .get(new VersionInfoDeletedEntity(ActionConstants.ACTION_VERSIONABLE_TYPE, actionInvariantUuId));
if (versionInfoDeletedEntity != null) {
viewableVersions = versionInfoDeletedEntity.getViewableVersions();
// Remove intermediate minor versions from viewable versions
@@ -337,30 +306,21 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act
}
// Add candidate version if available
if (versionInfoEntity.getCandidate() != null) {
- viewableVersions.add(versionInfoEntity.getCandidate()
- .getVersion());
+ viewableVersions.add(versionInfoEntity.getCandidate().getVersion());
}
}
-
MDC.put(TARGET_ENTITY, TARGET_ENTITY_DB);
ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false);
log.metrics("");
-
- log.debug("Found " + viewableVersions + " viewable version for action with actionInvariantUuId "
- + actionInvariantUuId);
-
+ log.debug("Found " + viewableVersions + " viewable version for action with actionInvariantUuId " + actionInvariantUuId);
// Fetch action data for the viewable versions
if (!viewableVersions.isEmpty()) {
ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_ACTIONINVID, TARGET_ENTITY_DB);
- Result<ActionEntity> result = accessor.getActionsByInvId(actionInvariantUuId,
- new ArrayList<>(viewableVersions));
+ Result<ActionEntity> result = accessor.getActionsByInvId(actionInvariantUuId, new ArrayList<>(viewableVersions));
ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false);
log.metrics("");
if (result != null) {
- actions.addAll(result.all()
- .stream()
- .map(ActionEntity::toDto)
- .collect(Collectors.toList()));
+ actions.addAll(result.all().stream().map(ActionEntity::toDto).collect(Collectors.toList()));
}
}
} catch (NoHostAvailableException noHostAvailableException) {
@@ -376,22 +336,17 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act
log.debug(" entering getLockedAction with actionInvariantUuId= " + actionInvariantUuId);
ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
Action action = null;
- VersionInfoEntity versionInfoEntity = versionInfoDao
- .get(new VersionInfoEntity(ActionConstants.ACTION_VERSIONABLE_TYPE, actionInvariantUuId));
+ VersionInfoEntity versionInfoEntity = versionInfoDao.get(new VersionInfoEntity(ActionConstants.ACTION_VERSIONABLE_TYPE, actionInvariantUuId));
ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false);
log.metrics("");
if (versionInfoEntity != null) {
if (versionInfoEntity.getCandidate() != null) {
- String actionUser = versionInfoEntity.getCandidate()
- .getUser();
+ String actionUser = versionInfoEntity.getCandidate().getUser();
if (actionUser != null && actionUser.equals(user)) {
Set<Version> versions = new HashSet<>();
- versions.add(versionInfoEntity.getCandidate()
- .getVersion());
- ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_ACTIONINVID,
- TARGET_ENTITY_DB);
- Result<ActionEntity> result = accessor.getActionsByInvId(actionInvariantUuId,
- new ArrayList<>(versions));
+ versions.add(versionInfoEntity.getCandidate().getVersion());
+ ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_ACTIONINVID, TARGET_ENTITY_DB);
+ Result<ActionEntity> result = accessor.getActionsByInvId(actionInvariantUuId, new ArrayList<>(versions));
ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false);
log.metrics("");
if (result != null) {
@@ -400,7 +355,7 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act
}
} else {
throw new ActionException(ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER_CODE,
- String.format(ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER, actionUser));
+ String.format(ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER, actionUser));
}
} else {
throw new ActionException(ACTION_NOT_LOCKED_CODE, ACTION_NOT_LOCKED_MSG);
@@ -412,8 +367,7 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act
}
private void logGenericException(Exception exception) {
- ActionUtil.actionLogPostProcessor(ERROR, ACTION_QUERY_FAILURE_CODE,
- ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG, false);
+ ActionUtil.actionLogPostProcessor(ERROR, ACTION_QUERY_FAILURE_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG, false);
log.metrics("");
ActionUtil.actionErrorLogProcessor(CategoryLogLevel.FATAL, ACTION_QUERY_FAILURE_CODE, ACTION_QUERY_FAILURE_MSG);
log.error(exception.getMessage());
@@ -426,47 +380,38 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act
@Override
protected Object[] getKeys(ActionEntity entity) {
- return new Object[] { entity.getActionInvariantUuId(), entity.getVersion() };
+ return new Object[]{entity.getActionInvariantUuId(), entity.getVersion()};
}
@Override
public Collection<ActionEntity> list(ActionEntity entity) {
- return accessor.getAllActions()
- .all();
+ return accessor.getAllActions().all();
}
private void updateActionStatusForDelete(String actionInvariantUuId, List<Version> versions) {
- log.debug("entering updateActionStatusForDelete with actionInvariantUuId = " + actionInvariantUuId
- + FOR_VERSIONS + versions);
+ log.debug("entering updateActionStatusForDelete with actionInvariantUuId = " + actionInvariantUuId + FOR_VERSIONS + versions);
ActionUtil.actionLogPreProcessor(ActionSubOperation.UPDATE_ACTION_STATUS, TARGET_ENTITY_DB);
// Update the status column of action table
- Statement updateStatusStatement = QueryBuilder.update("dox", ACTION)
- .with(set("status", ActionStatus.Deleted.name()))
- .where(eq("actioninvariantuuid", actionInvariantUuId))
- .and(in(VERSION, versions));
+ Statement updateStatusStatement = QueryBuilder.update("dox", ACTION).with(set("status", ActionStatus.Deleted.name()))
+ .where(eq("actioninvariantuuid", actionInvariantUuId)).and(in(VERSION, versions));
getSession().execute(updateStatusStatement);
ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false);
log.metrics("");
// Update the status in the data field of action table
updateStatusInActionData(actionInvariantUuId, versions, ActionStatus.Deleted);
- log.debug("exit updateActionStatusForDelete with actionInvariantUuId = " + actionInvariantUuId + FOR_VERSIONS
- + versions);
+ log.debug("exit updateActionStatusForDelete with actionInvariantUuId = " + actionInvariantUuId + FOR_VERSIONS + versions);
}
/**
* Update status for a list of versions for a given action.
*
- * @param actionInvariantUuId
- * Invariant UUID of the action.
- * @param versions
- * List of {@link Version} for which the status has to be
- * updated.
- * @param status
- * The status value.
+ * @param actionInvariantUuId Invariant UUID of the action.
+ * @param versions List of {@link Version} for which the status has to be updated.
+ * @param status The status value.
*/
private void updateStatusInActionData(String actionInvariantUuId, List<Version> versions, ActionStatus status) {
- log.debug("entering updateStatusInActionData for actionInvariantUuId = " + actionInvariantUuId
- + " and status = " + status + FOR_VERSIONS + versions);
+ log.debug("entering updateStatusInActionData for actionInvariantUuId = " + actionInvariantUuId + " and status = " + status + FOR_VERSIONS
+ + versions);
for (Version v : versions) {
ActionEntity entity = this.get(new ActionEntity(actionInvariantUuId, v));
String currentData = entity.getData();
@@ -480,24 +425,18 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act
}
/**
- * Get list of all major and minor version values for a given action by
- * action name.
+ * Get list of all major and minor version values for a given action by action name.
*
- * @param name
- * Name of the action.
+ * @param name Name of the action.
* @return List of {@link Version} objects for the action.
*/
private List<Version> getVersionsByName(String name) {
log.debug("entering getVersionsByName for Action Name = " + name);
ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
- Statement statement = QueryBuilder.select()
- .column(VERSION)
- .from("dox", ACTION)
- .where(eq("name", name));
+ Statement statement = QueryBuilder.select().column(VERSION).from("dox", ACTION).where(eq("name", name));
ResultSet results = getSession().execute(statement);
ActionUtil.actionLogPostProcessor(COMPLETE, null, "", false);
log.metrics("");
-
List<Version> versionList = new ArrayList<>();
for (Row row : results) {
Version version = row.get(VERSION, Version.class);
@@ -536,10 +475,10 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act
@Query("SELECT * FROM Action where actionUUID = ?")
Result<ActionEntity> actionInvariantUuId(String actionUuId);
-
}
class VersionPredicate {
+
Version activeVersion;
Version finalVersion;
@@ -548,7 +487,6 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act
int activeMinorVersion = activeVersion.getMinor();
int currentMinorVersion = version.getMinor();
int currentMajorVersion = version.getMajor();
-
if (finalVersion != null) {
if (finalVersion.getMajor() == activeMajorVersion && currentMajorVersion == finalVersion.getMajor()) {
if (currentMinorVersion < activeMinorVersion && currentMinorVersion != 0) {
@@ -562,9 +500,7 @@ public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements Act
return true;
}
}
-
return false;
}
-
}
}