aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-core/src/main/java/org/openecomp/sdc/action/dao/impl/ActionArtifactDaoImpl.java')
-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
1 files changed, 87 insertions, 97 deletions
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);
+ }
}