summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-02-19 12:35:04 +0200
committerMichael Lando <ml636r@att.com>2017-02-19 12:35:04 +0200
commitf5f13c4f6b6fe3b4d98e349dfd7db59339803436 (patch)
tree72caffc93fab394ffa3b761505775331f1c559b9 /openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java
parent451a3400b76511393c62a444f588a4ed15f4a549 (diff)
push addional code
Change-Id: Ia427bb3460cda3a896f8faced2de69eaf3807b74 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java')
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/ActionConstants.java104
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionArtifactDao.java34
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionArtifactDaoFactory.java31
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionDao.java51
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionDaoFactory.java31
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/ActionArtifactEntity.java89
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/ActionEntity.java224
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/EcompComponentEntity.java73
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionErrorConstants.java136
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionException.java52
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionExceptionMapper.java114
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionExceptionResponse.java66
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/logging/CategoryLogLevel.java29
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/logging/StatusCode.java26
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/Action.java255
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionArtifact.java139
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionArtifactProtection.java26
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionLogResponseCode.java90
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionRequest.java40
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionStatus.java28
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionSubOperation.java59
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/EcompComponent.java104
-rw-r--r--openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/util/ActionUtil.java372
23 files changed, 2173 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/ActionConstants.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/ActionConstants.java
new file mode 100644
index 0000000000..625ce7efe8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/ActionConstants.java
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action;
+
+public class ActionConstants {
+
+ //
+ public static final long MAX_ACTION_ARTIFACT_SIZE = 20 * 1024 * 1024; //20 MB
+ //REST layer constants
+ public static final String X_ECOMP_INSTANCE_ID_HEADER_PARAM = "X-ECOMP-InstanceID";
+ public static final String X_ECOMP_REQUEST_ID_HEADER_PARAM = "X-ECOMP-RequestID";
+ public static final String WWW_AUTHENTICATE_HEADER_PARAM = "WWW-Authenticate";
+
+ public static final String ACTION_REQUEST_PARAM_NAME = "name";
+ public static final String ACTION_REQUEST_PARAM_END_POINT_URI = "endpointUri";
+ public static final String SUPPORTED_MODELS_VERSION_ID = "versionId";
+ public static final String SUPPORTED_COMPONENTS_ID = "Id";
+ public static final String ACTION_REQUEST_PARAM_SUPPORTED_MODELS = SUPPORTED_MODELS_VERSION_ID
+ + " in supportedModels";
+ public static final String ACTION_REQUEST_PARAM_SUPPORTED_COMPONENTS =
+ SUPPORTED_COMPONENTS_ID + " in supportedComponents";
+
+ public static final String REQUEST_EMPTY_BODY = "{}";
+ public static final String REQUEST_TYPE_CREATE_ACTION = "REQUEST_CREATE_ACTION";
+ public static final String REQUEST_TYPE_UPDATE_ACTION = "REQUEST_UPDATE_ACTION";
+ public static final String REQUEST_TYPE_VERSION_ACTION = "REQUEST_VERSION_ACTION";
+
+ //DAO layer constants
+ public static final String ACTION_VERSIONABLE_TYPE = "Action";
+
+ //Manager constants
+ public static final String UNIQUE_ID = "actionUuId";
+ public static final String VERSION = "version";
+ public static final String INVARIANTUUID = "actionInvariantUuId";
+ public static final String STATUS = "status";
+ public static final String ARTIFACTS = "artifacts";
+ public static final String TIMESTAMP = "timeStamp";
+ public static final String UPDATED_BY = "updatedBy";
+ public static final String ARTIFACT_NAME = "artifactName";
+ public static final String ARTIFACT_FILE = "Artifact to be uploaded";
+
+ // Status
+ public static final String UNDO_CHECKOUT_RESPONSE_TEXT =
+ "Changes to the Action object successfully reverted back.";
+
+ //GET Request Filter Types
+ public static final String FILTER_TYPE_VENDOR = "VENDOR";
+ public static final String FILTER_TYPE_CATEGORY = "CATEGORY";
+ public static final String FILTER_TYPE_NAME = "NAME";
+ public static final String FILTER_TYPE_MODEL = "MODEL";
+ public static final String FILTER_TYPE_ECOMP_COMPONENT = "ECOMP_COMPONENT";
+ public static final String FILTER_TYPE_NONE = "NONE";
+
+ public static final String ARTIFACT_METADATA_ATTR_UUID = "ARTIFACT_UUID";
+ public static final String ARTIFACT_METADATA_ATTR_NAME = "ARTIFACT_NAME";
+
+ public static final String REQUEST_ID = "uuid";
+ public static final String SERVICE_INSTANCE_ID = "serviceInstanceID";
+ public static final String PARTNER_NAME = "userId";
+ public static final String SERVICE_NAME = "ServiceName";
+ public static final String INSTANCE_UUID = "InstanceUUID";
+ public static final String REMOTE_HOST = "RemoteHost";
+ public static final String CLIENT_IP = "ClientIP";
+ public static final String CATEGORY_LOG_LEVEL = "level";
+ public static final String STATUS_CODE = "StatusCode";
+ public static final String RESPONSE_CODE = "ResponseCode";
+ public static final String RESPONSE_DESCRIPTION = "ResponseDescription";
+ public static final String ELAPSED_TIME = "ElapsedTime";
+ public static final String BEGIN_TIMESTAMP = "BeginTimestamp";
+ public static final String TARGET_SERVICE_NAME = "TargetServiceName";
+ public static final String TARGET_ENTITY = "TargetEntity";
+ public static final String TARGET_ENTITY_API = "API";
+ public static final String TARGET_ENTITY_DB = "DB";
+ public static final String END_TIMESTAMP = "EndTimestamp";
+ public static final String ERROR_CATEGORY = "ErrorCategory";
+ public static final String ERROR_CODE = "ErrorCode";
+ public static final String ERROR_DESCRIPTION = "ErrorDescription";
+ public static final String MDC_ASDC_INSTANCE_UUID = "ASDC";
+ public static final String SERVICE_METRIC_BEGIN_TIMESTAMP = "SERVICE-METRIC-BEGIN-TIMESTAMP";
+ public static final String LOCAL_ADDR = "localAddr"; //map ServerIPAddress from loggingfilter
+ public static final String BE_FQDN = "beFqdn"; //map ServerFQDN from logging filter
+
+ public final class UniqueValues {
+ public static final String ACTION_NAME = "Action name";
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionArtifactDao.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionArtifactDao.java
new file mode 100644
index 0000000000..a120645512
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionArtifactDao.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.dao;
+
+import org.openecomp.core.dao.BaseDao;
+import org.openecomp.sdc.action.dao.types.ActionArtifactEntity;
+import org.openecomp.sdc.action.types.ActionArtifact;
+
+public interface ActionArtifactDao extends BaseDao<ActionArtifactEntity> {
+
+ void uploadArtifact(ActionArtifact data);
+
+ ActionArtifact downloadArtifact(int effectiveVersion, String artifactUuId);
+
+ void updateArtifact(ActionArtifact data);
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionArtifactDaoFactory.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionArtifactDaoFactory.java
new file mode 100644
index 0000000000..f0936976ba
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionArtifactDaoFactory.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.dao;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class ActionArtifactDaoFactory extends AbstractComponentFactory<ActionArtifactDao> {
+
+ public static ActionArtifactDaoFactory getInstance() {
+ return AbstractFactory.getInstance(ActionArtifactDaoFactory.class);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionDao.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionDao.java
new file mode 100644
index 0000000000..01f5014ad4
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionDao.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.dao;
+
+import org.openecomp.core.dao.BaseDao;
+import org.openecomp.sdc.action.dao.types.ActionEntity;
+import org.openecomp.sdc.action.errors.ActionException;
+import org.openecomp.sdc.action.types.Action;
+import org.openecomp.sdc.action.types.EcompComponent;
+import org.openecomp.sdc.versioning.dao.VersionableDao;
+
+import java.util.List;
+
+public interface ActionDao extends VersionableDao, BaseDao<ActionEntity> {
+
+ Action createAction(Action actionDto) throws ActionException;
+
+ Action updateAction(Action actionDto) throws ActionException;
+
+ void deleteAction(String actionInvariantUuId) throws ActionException;
+
+ List<Action> getFilteredActions(String filterType, String filterId) throws ActionException;
+
+ Action getActionsByActionUuId(String uniqueId) throws ActionException;
+
+ List<EcompComponent> getEcompComponents() throws ActionException;
+
+ List<Action> getActionsByActionInvariantUuId(String actionInvariantUuId)
+ throws ActionException;
+
+ Action getLockedAction(String actionInvariantUuId, String user) throws ActionException;
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionDaoFactory.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionDaoFactory.java
new file mode 100644
index 0000000000..d8b0c1889e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/ActionDaoFactory.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.dao;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class ActionDaoFactory extends AbstractComponentFactory<ActionDao> {
+
+ public static ActionDaoFactory getInstance() {
+ return AbstractFactory.getInstance(ActionDaoFactory.class);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/ActionArtifactEntity.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/ActionArtifactEntity.java
new file mode 100644
index 0000000000..7e56a04e1b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/ActionArtifactEntity.java
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.dao.types;
+
+import com.datastax.driver.mapping.annotations.Column;
+import com.datastax.driver.mapping.annotations.PartitionKey;
+import com.datastax.driver.mapping.annotations.Table;
+import org.openecomp.sdc.action.types.ActionArtifact;
+
+import java.nio.ByteBuffer;
+
+@Table(keyspace = "dox", name = "action_artifact")
+public class ActionArtifactEntity {
+
+ @PartitionKey
+ @Column(name = "artifactuuid")
+ private String artifactUuId;
+
+ @PartitionKey(value = 1)
+ @Column(name = "effective_version")
+ private int effectiveVersion;
+
+ @Column(name = "artifact")
+ private ByteBuffer artifact;
+
+ public ActionArtifactEntity() {
+ //Default constructor implementation
+ }
+
+ public ActionArtifactEntity(String artifactUuId, int effectiveVersion) {
+ this.artifactUuId = artifactUuId;
+ this.effectiveVersion = effectiveVersion;
+ }
+
+ public String getArtifactUuId() {
+ return artifactUuId;
+ }
+
+ public void setArtifactUuId(String artifactUuId) {
+ this.artifactUuId = artifactUuId;
+ }
+
+ public int getEffectiveVersion() {
+ return effectiveVersion;
+ }
+
+ public void setEffectiveVersion(int effectiveVersion) {
+ this.effectiveVersion = effectiveVersion;
+ }
+
+ public ByteBuffer getArtifact() {
+ return artifact;
+ }
+
+ public void setArtifact(ByteBuffer artifact) {
+ this.artifact = artifact;
+ }
+
+ /**
+ * To dto action artifact.
+ *
+ * @return the action artifact
+ */
+ public ActionArtifact toDto() {
+ ActionArtifact destination = new ActionArtifact();
+ destination.setArtifactUuId(this.getArtifactUuId());
+ destination.setEffectiveVersion(this.getEffectiveVersion());
+ destination.setArtifact(this.getArtifact().array());
+ return destination;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/ActionEntity.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/ActionEntity.java
new file mode 100644
index 0000000000..9aa9e8d375
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/ActionEntity.java
@@ -0,0 +1,224 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.dao.types;
+
+import com.datastax.driver.mapping.annotations.Column;
+import com.datastax.driver.mapping.annotations.Frozen;
+import com.datastax.driver.mapping.annotations.PartitionKey;
+import com.datastax.driver.mapping.annotations.Table;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.action.types.Action;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Table(keyspace = "dox", name = "Action")
+public class ActionEntity {
+
+ @Column(name = "actionUUID")
+ private String actionUuId;
+ @PartitionKey(value = 0)
+ @Column(name = "actionInvariantUUID")
+ private String actionInvariantUuId;
+ @PartitionKey(value = 1)
+ @Frozen
+ @Column(name = "version")
+ private Version version;
+ @Column(name = "status")
+ private String status;
+ @Column(name = "name")
+ private String name;
+ @Column(name = "vendor_list")
+ private List<String> vendorList;
+ @Column(name = "category_list")
+ private List<String> categoryList;
+ @Column(name = "timestamp")
+ private Date timestamp;
+ @Column(name = "user")
+ private String user;
+ @Column(name = "supportedModels")
+ private List<String> supportedModels;
+ @Column(name = "supportedComponents")
+ private List<String> supportedComponents;
+ @Column(name = "data")
+ private String data;
+
+ public ActionEntity() {
+ }
+
+ public ActionEntity(String actionInvariantUuId, Version version) {
+ this.actionInvariantUuId = actionInvariantUuId;
+ this.version = version;
+ }
+
+ public String getActionUuId() {
+ return actionUuId;
+ }
+
+ public void setActionUuId(String actionUuId) {
+ this.actionUuId = actionUuId;
+ }
+
+ public String getActionInvariantUuId() {
+ return actionInvariantUuId;
+ }
+
+ public void setActionInvariantUuId(String actionInvariantUuId) {
+ this.actionInvariantUuId = actionInvariantUuId;
+ }
+
+ public Version getVersion() {
+ return version;
+ }
+
+ public void setVersion(Version version) {
+ this.version = version;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<String> getVendorList() {
+ return vendorList;
+ }
+
+ /**
+ * Sets vendor list.
+ *
+ * @param vendorList the vendor list
+ */
+ public void setVendorList(List<String> vendorList) {
+ if (vendorList != null && !vendorList.isEmpty()) {
+ List<String> lowerCaseVendorList = new ArrayList<>();
+ lowerCaseVendorList
+ .addAll(vendorList.stream().map(String::toLowerCase).collect(Collectors.toList()));
+ this.vendorList = lowerCaseVendorList;
+ } else {
+ this.vendorList = vendorList;
+ }
+ }
+
+ public List<String> getCategoryList() {
+ return categoryList;
+ }
+
+ /**
+ * Sets category list.
+ *
+ * @param categoryList the category list
+ */
+ public void setCategoryList(List<String> categoryList) {
+ if (categoryList != null && !categoryList.isEmpty()) {
+ List<String> lowerCaseCategoryList = new ArrayList<>();
+ lowerCaseCategoryList
+ .addAll(categoryList.stream().map(String::toLowerCase).collect(Collectors.toList()));
+ this.categoryList = lowerCaseCategoryList;
+ } else {
+ this.categoryList = categoryList;
+ }
+ }
+
+ public Date getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(Date timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ public List<String> getSupportedModels() {
+ return supportedModels;
+ }
+
+ public void setSupportedModels(List<String> supportedModels) {
+ this.supportedModels = supportedModels;
+ }
+
+ public List<String> getSupportedComponents() {
+ return supportedComponents;
+ }
+
+ public void setSupportedComponents(List<String> supportedComponents) {
+ this.supportedComponents = supportedComponents;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ /**
+ * To dto action.
+ *
+ * @return the action
+ */
+ public Action toDto() {
+ //Action destination = new Action();
+
+ Action destination = JsonUtil.json2Object(this.getData(), Action.class);
+ destination.setData(this.getData());
+ destination.setTimestamp(this.getTimestamp());
+ destination.setUser(this.getUser());
+ destination.setData(this.getData());
+ return destination;
+ }
+
+ /*private List<HashMap<String,String>> createMapFromList(List<String> list, String idName){
+ List<HashMap<String,String>> keyValueList = new ArrayList<>();
+ if(list != null && !list.isEmpty()){
+ for(String attributeId : list){
+ HashMap<String,String> attributeIdMap = new HashMap<>();
+ attributeIdMap.put(idName,attributeId);
+ keyValueList.add(attributeIdMap);
+ }
+ return keyValueList;
+ }
+ return null;
+ }*/
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/EcompComponentEntity.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/EcompComponentEntity.java
new file mode 100644
index 0000000000..9a71023629
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/dao/types/EcompComponentEntity.java
@@ -0,0 +1,73 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.dao.types;
+
+import com.datastax.driver.mapping.annotations.Column;
+import com.datastax.driver.mapping.annotations.PartitionKey;
+import com.datastax.driver.mapping.annotations.Table;
+import org.openecomp.sdc.action.types.EcompComponent;
+
+@Table(keyspace = "dox", name = "ECOMPComponent")
+public class EcompComponentEntity {
+
+ @PartitionKey
+ @Column(name = "id")
+ private String id;
+
+ @Column(name = "name")
+ private String name;
+
+ public EcompComponentEntity() {
+ }
+
+ public EcompComponentEntity(String id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * To dto ecomp component.
+ *
+ * @return the ecomp component
+ */
+ public EcompComponent toDto() {
+ EcompComponent destination = new EcompComponent();
+ destination.setId(this.getId());
+ destination.setName(this.getName());
+ return destination;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionErrorConstants.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionErrorConstants.java
new file mode 100644
index 0000000000..092d9abee5
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionErrorConstants.java
@@ -0,0 +1,136 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.errors;
+
+public class ActionErrorConstants {
+
+ //Error Codes
+ public static final String ACTION_REQUEST_INVALID_GENERIC_CODE = "ACT0001";
+ public static final String ACTION_AUTHENTICATION_ERR_CODE = "ACT1000";
+ public static final String ACTION_AUTHORIZATION_ERR_CODE = "ACT1001";
+ public static final String ACTION_INVALID_INSTANCE_ID_CODE = "ACT1002";
+ public static final String ACTION_INVALID_REQUEST_ID_CODE = "ACT1003";
+ public static final String ACTION_INVALID_PARAM_CODE = "ACT1004";
+ //Operation <status> is not supported
+ public static final String ACTION_INVALID_REQUEST_BODY_CODE = "ACT1005";
+ //ACTION_REQUEST_BODY_EMPTY
+ public static final String ACTION_UPDATE_NOT_ALLOWED_CODE_NAME = "ACT1007";
+ public static final String ACTION_CHECKOUT_ON_LOCKED_ENTITY = "ACT1008";
+ public static final String ACTION_ENTITY_UNIQUE_VALUE_ERROR = "ACT1009";
+
+ public static final String ACTION_INVALID_SEARCH_CRITERIA = "ACT1011";
+ public static final String ACTION_MULT_SEARCH_CRITERIA = "ACT1012";
+ public static final String ACTION_UPDATE_ON_UNLOCKED_ENTITY = "ACT1013";
+ public static final String ACTION_UPDATE_INVALID_VERSION = "ACT1014";
+ public static final String ACTION_UPDATE_NOT_ALLOWED_CODE = "ACT1015";
+
+ public static final String ACTION_CHECKIN_ON_UNLOCKED_ENTITY = "ACT1017";
+ public static final String ACTION_SUBMIT_FINALIZED_ENTITY_NOT_ALLOWED = "ACT1018";
+ public static final String ACTION_SUBMIT_LOCKED_ENTITY_NOT_ALLOWED = "ACT1019";
+ public static final String ACTION_UNDO_CHECKOUT_ON_UNLOCKED_ENTITY = "ACT1020";
+ public static final String ACTION_NOT_LOCKED_CODE = "ACT1021";
+ public static final String ACTION_ARTIFACT_CHECKSUM_ERROR_CODE = "ACT1022";
+ public static final String ACTION_ARTIFACT_TOO_BIG_ERROR_CODE = "ACT1023";
+ public static final String ACTION_ARTIFACT_ALREADY_EXISTS_CODE = "ACT1025";
+ public static final String ACTION_ARTIFACT_UPDATE_READ_ONLY = "ACT1026";
+ public static final String ACTION_ARTIFACT_DELETE_READ_ONLY = "ACT1027";
+ public static final String ACTION_ARTIFACT_INVALID_PROTECTION_CODE = "ACT1028";
+ public static final String ACTION_ARTIFACT_INVALID_NAME_CODE = "ACT1029";
+
+ public static final String ACTION_EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER = "ACT1041";
+ public static final String ACTION_CHECKIN_ON_ENTITY_LOCKED_BY_OTHER_USER = "ACT1042";
+ public static final String ACTION_CHECKOUT_ON_LOCKED_ENTITY_OTHER_USER = "ACT1043";
+ public static final String ACTION_UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER = "ACT1044";
+ public static final String ACTION_ENTITY_NOT_EXIST_CODE = "ACT1045";
+ public static final String ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE = "ACT1046";
+ public static final String ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER_CODE = "ACT1047";
+ public static final String ACTION_DELETE_ON_LOCKED_ENTITY_CODE = "ACT1048";
+
+ public static final String ACTION_INTERNAL_SERVER_ERR_CODE = "ACT1060";
+ public static final String ACTION_QUERY_FAILURE_CODE = "QUERY_FAILURE";
+ public static final String ACTION_QUERY_FAILURE_MSG = "Query Failure";
+
+
+ //Error Messages
+ public static final String ACTION_REQUEST_BODY_EMPTY = "Request Body is missing";
+ //"The API failed due to missing body";
+ public static final String ACTION_REQUEST_MISSING_MANDATORY_PARAM =
+ "Missing mandatory parameter(s) : ";
+ public static final String ACTION_REQUEST_ECOMP_INSTANCE_ID_INVALID =
+ "X-ECOMP-InstanceID HTTP header missing or empty";
+ public static final String ACTION_REQUEST_ECOMP_REQUEST_ID_INVALID =
+ "X-ECOMP-RequestID HTTP header missing or empty";
+ public static final String ACTION_REQUEST_CONTENT_TYPE_INVALID =
+ "Content-Type HTTP header missing or empty";
+ public static final String ACTION_REQUEST_AUTHORIZATION_HEADER_INVALID =
+ "Authentication is required to use the API";
+ public static final String ACTION_REQUEST_INVALID_NAME =
+ "Invalid syntax for action name. No whitespaces allowed.";
+ public static final String ACTION_REQUEST_FILTER_PARAM_INVALID =
+ "Invalid Search filter criteria provided";
+ public static final String ACTION_FILTER_MULTIPLE_QUERY_PARAM_NOT_SUPPORTED =
+ "Multiple filter criteria are not supported";
+ //"Operation supports filter by one property at a time";
+ public static final String ACTION_ARTIFACT_ENTITY_NOT_EXIST = "Specified artifact is not found";
+ public static final String ACTION_REQUEST_ARTIFACT_CHECKSUM_ERROR = "Checksum error";
+ public static final String ACTION_REQUEST_ARTIFACT_INVALID_PROTECTION_VALUE =
+ "Invalid artifact protection value";
+
+ public static final String ACTION_ARTIFACT_INVALID_NAME =
+ "Artifact name cannot contain any of the following characters : #<>$+%!`&*'|{}?=/:@ "
+ + "including whitespaces, double quotes and back-slash";
+ public static final String ACTION_ARTIFACT_READ_FILE_ERROR = "Error Occurred while reading file";
+ public static final String ACTION_REQUEST_ARTIFACT_OPERATION_ALLOWED =
+ "Artifacts cannot be created/updated using this operation";
+ public static final String ACTION_ARTIFACT_TOO_BIG_ERROR =
+ "Operation is not allowed. Artifact size exceeds the maximum file size limit (20MB).";
+
+ //Business Validation Error messages
+ public static final String ACTION_UPDATE_NOT_ALLOWED_FOR_NAME =
+ "Action Name update is not allowed";
+ public static final String ACTION_UPDATE_PARAM_INVALID =
+ "Update not allowed for the parameter(s) : %s";
+ public static final String ACTION_ENTITY_NOT_EXIST = "Specified Action is not found";
+ public static final String ACTION_REQUESTED_VERSION_INVALID = "Invalid requested version : %s";
+ public static final String ACTION_UNSUPPORTED_OPERATION = "Operation %s not supported";
+ public static final String ACTION_ENTITY_UNIQUE_VALUE_MSG =
+ "%s with the value '%s' already exists.";
+ public static final String ACTION_ARTIFACT_ALREADY_EXISTS =
+ "Artifact name already exists for Action with id %s. Please use another name.";
+ public static final String ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG =
+ "The request failed due to an internal ASDC problem. ECOMP Component should continue the "
+ + "attempts, with corrected data if required, to create the resource.";
+ public static final String ACTION_ARTIFACT_DELETE_READ_ONLY_MSG =
+ "Cannot delete read only artifact.";
+ public static final String ACTION_ARTIFACT_UPDATE_READ_ONLY_MSG =
+ "Cannot update read only artifact.";
+ public static final String ACTION_NOT_LOCKED_MSG =
+ "Operation is not allowed. Action status should be Locked.";
+ public static final String ACTION_ARTIFACT_UPDATE_NAME_INVALID =
+ "Artifact name cannot be updated.";
+ public static final String ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER =
+ "Cannot delete artifact since it is locked by other user %s.";
+ public static final String UNDO_CHECKOUT_ON_UNLOCKED_ENTITY_MSG =
+ "Can not undo checkout on versionable entity %s with id %s since it is not checked out.";
+ public static final String UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER_MSG =
+ "Can not undo checkout on versionable entity %s with id"
+ + " %s since it is checked out by other user: %s.";
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionException.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionException.java
new file mode 100644
index 0000000000..fff88d6f84
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionException.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.errors;
+
+public class ActionException extends RuntimeException {
+
+ private String errorCode;
+ private String description;
+
+ public ActionException() {
+
+ }
+
+ public ActionException(String errorCode, String description) {
+ this.errorCode = errorCode;
+ this.description = description;
+ }
+
+ public String getErrorCode() {
+ return errorCode;
+ }
+
+ public void setErrorCode(String errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionExceptionMapper.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionExceptionMapper.java
new file mode 100644
index 0000000000..23c14aaaa2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionExceptionMapper.java
@@ -0,0 +1,114 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.errors;
+
+import org.openecomp.sdc.action.ActionConstants;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+
+public class ActionExceptionMapper implements ExceptionMapper<ActionException> {
+
+ @Override
+ public Response toResponse(ActionException actionException) {
+ Response response;
+ String errorCode = actionException.getErrorCode();
+ switch (errorCode) {
+ case ActionErrorConstants.ACTION_REQUEST_INVALID_GENERIC_CODE:
+ case ActionErrorConstants.ACTION_INVALID_INSTANCE_ID_CODE:
+ case ActionErrorConstants.ACTION_INVALID_REQUEST_ID_CODE:
+ case ActionErrorConstants.ACTION_INVALID_REQUEST_BODY_CODE:
+ case ActionErrorConstants.ACTION_INVALID_PARAM_CODE:
+ case ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_FOR_NAME:
+ case ActionErrorConstants.ACTION_CHECKOUT_ON_LOCKED_ENTITY:
+ case ActionErrorConstants.ACTION_ENTITY_UNIQUE_VALUE_ERROR:
+ case ActionErrorConstants.ACTION_INVALID_SEARCH_CRITERIA:
+ case ActionErrorConstants.ACTION_MULT_SEARCH_CRITERIA:
+ case ActionErrorConstants.ACTION_UPDATE_ON_UNLOCKED_ENTITY:
+ case ActionErrorConstants.ACTION_UPDATE_INVALID_VERSION:
+ case ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_CODE:
+ case ActionErrorConstants.ACTION_CHECKIN_ON_UNLOCKED_ENTITY:
+ case ActionErrorConstants.ACTION_SUBMIT_FINALIZED_ENTITY_NOT_ALLOWED:
+ case ActionErrorConstants.ACTION_SUBMIT_LOCKED_ENTITY_NOT_ALLOWED:
+ case ActionErrorConstants.ACTION_UNDO_CHECKOUT_ON_UNLOCKED_ENTITY:
+ case ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_CODE_NAME:
+ case ActionErrorConstants.ACTION_ARTIFACT_CHECKSUM_ERROR_CODE:
+ case ActionErrorConstants.ACTION_ARTIFACT_ALREADY_EXISTS_CODE:
+ case ActionErrorConstants.ACTION_ARTIFACT_INVALID_NAME_CODE:
+ case ActionErrorConstants.ACTION_ARTIFACT_TOO_BIG_ERROR_CODE:
+ case ActionErrorConstants.ACTION_ARTIFACT_INVALID_PROTECTION_CODE:
+ case ActionErrorConstants.ACTION_ARTIFACT_DELETE_READ_ONLY:
+ case ActionErrorConstants.ACTION_NOT_LOCKED_CODE:
+ response = Response
+ .status(Response.Status.BAD_REQUEST)
+ .entity(new ActionExceptionResponse(errorCode,
+ Response.Status.BAD_REQUEST.getReasonPhrase(), actionException.getDescription()))
+ .type(MediaType.APPLICATION_JSON)
+ .build();
+ break;
+ case ActionErrorConstants.ACTION_AUTHENTICATION_ERR_CODE:
+ response = Response
+ .status(Response.Status.UNAUTHORIZED)
+ .header(ActionConstants.WWW_AUTHENTICATE_HEADER_PARAM,
+ ActionErrorConstants.ACTION_REQUEST_AUTHORIZATION_HEADER_INVALID)
+ .entity(new ActionExceptionResponse(errorCode,
+ Response.Status.UNAUTHORIZED.getReasonPhrase(), actionException.getDescription()))
+ .type(MediaType.APPLICATION_JSON)
+ .build();
+ break;
+ case ActionErrorConstants.ACTION_AUTHORIZATION_ERR_CODE:
+ case ActionErrorConstants.ACTION_EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER:
+ case ActionErrorConstants.ACTION_CHECKIN_ON_ENTITY_LOCKED_BY_OTHER_USER:
+ case ActionErrorConstants.ACTION_CHECKOUT_ON_LOCKED_ENTITY_OTHER_USER:
+ case ActionErrorConstants.ACTION_UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER:
+ case ActionErrorConstants.ACTION_DELETE_ON_LOCKED_ENTITY_CODE:
+ case ActionErrorConstants.ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER_CODE:
+ case ActionErrorConstants.ACTION_ARTIFACT_UPDATE_READ_ONLY:
+ response = Response
+ .status(Response.Status.FORBIDDEN)
+ .entity(
+ new ActionExceptionResponse(errorCode, Response.Status.FORBIDDEN.getReasonPhrase(),
+ actionException.getDescription())).type(MediaType.APPLICATION_JSON)
+ .build();
+ break;
+ case ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE:
+ case ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE:
+ response = Response
+ .status(Response.Status.NOT_FOUND)
+ .entity(
+ new ActionExceptionResponse(errorCode, Response.Status.NOT_FOUND.getReasonPhrase(),
+ actionException.getDescription())).type(MediaType.APPLICATION_JSON)
+ .build();
+ break;
+ case ActionErrorConstants.ACTION_INTERNAL_SERVER_ERR_CODE:
+ default:
+ response = Response
+ .status(Response.Status.INTERNAL_SERVER_ERROR)
+ .entity(new ActionExceptionResponse(errorCode,
+ Response.Status.INTERNAL_SERVER_ERROR.getReasonPhrase(),
+ actionException.getDescription()))
+ .type(MediaType.APPLICATION_JSON)
+ .build();
+ }
+ return response;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionExceptionResponse.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionExceptionResponse.java
new file mode 100644
index 0000000000..51848464a7
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/errors/ActionExceptionResponse.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.errors;
+
+public class ActionExceptionResponse {
+ private String code;
+ private String description;
+ private String message;
+
+ /**
+ * Instantiates a new Action exception response.
+ *
+ * @param code the code
+ * @param description the description
+ * @param message the message
+ */
+ public ActionExceptionResponse(String code, String description, String message) {
+ this.code = code;
+ this.description = description;
+ this.message = message;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/logging/CategoryLogLevel.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/logging/CategoryLogLevel.java
new file mode 100644
index 0000000000..d87bed310f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/logging/CategoryLogLevel.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.logging;
+
+public enum CategoryLogLevel {
+ INFO,
+ WARN,
+ DEBUG,
+ ERROR,
+ FATAL
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/logging/StatusCode.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/logging/StatusCode.java
new file mode 100644
index 0000000000..b0d5bab12b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/logging/StatusCode.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.logging;
+
+public enum StatusCode {
+ COMPLETE,
+ ERROR
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/Action.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/Action.java
new file mode 100644
index 0000000000..176d443a81
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/Action.java
@@ -0,0 +1,255 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.types;
+
+import org.openecomp.sdc.action.ActionConstants;
+import org.openecomp.sdc.action.dao.types.ActionEntity;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+
+public class Action implements Comparable {
+ private String actionUuId;
+ private String actionInvariantUuId;
+ private String version;
+ private ActionStatus status;
+ private String name;
+ private String displayName;
+ private String endpointUri;
+ private List<String> vendorList;
+ private List<String> categoryList;
+ private Date timestamp;
+ private String user;
+ private List<HashMap<String, String>> supportedModels;
+ private List<HashMap<String, String>> supportedComponents;
+ //private List<HashMap<String,String>> artifacts;
+ private List<ActionArtifact> artifacts;
+ private String data;
+
+ public Action() {
+ }
+
+ /**
+ * Instantiates a new Action.
+ *
+ * @param action the action
+ */
+ public Action(Action action) {
+ this.actionUuId = action.getActionUuId();
+ this.actionInvariantUuId = action.getActionInvariantUuId();
+ this.name = action.getName();
+ this.setDisplayName(action.getDisplayName());
+ this.setVendorList(action.getVendorList());
+ this.setCategoryList(action.getCategoryList());
+ this.setTimestamp(action.getTimestamp());
+ this.setUser(action.getUser());
+ this.version = action.getVersion();
+ this.status = action.getStatus();
+ this.data = action.getData();
+ this.supportedComponents = action.getSupportedComponents();
+ this.supportedModels = action.getSupportedModels();
+ this.artifacts = action.getArtifacts();
+ }
+
+ public String getActionUuId() {
+ return actionUuId;
+ }
+
+ public void setActionUuId(String actionUuId) {
+ this.actionUuId = actionUuId;
+ }
+
+ public String getActionInvariantUuId() {
+ return actionInvariantUuId;
+ }
+
+ public void setActionInvariantUuId(String actionInvariantUuId) {
+ this.actionInvariantUuId = actionInvariantUuId;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public ActionStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(ActionStatus status) {
+ this.status = status;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getEndpointUri() {
+ return endpointUri;
+ }
+
+ public void setEndpointUri(String endpointUri) {
+ this.endpointUri = endpointUri;
+ }
+
+ public List<String> getVendorList() {
+ return vendorList;
+ }
+
+ public void setVendorList(List<String> vendorList) {
+ this.vendorList = vendorList;
+ }
+
+ public List<String> getCategoryList() {
+ return categoryList;
+ }
+
+ public void setCategoryList(List<String> categoryList) {
+ this.categoryList = categoryList;
+ }
+
+ public Date getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(Date timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ public List<HashMap<String, String>> getSupportedModels() {
+ return supportedModels;
+ }
+
+ public void setSupportedModels(List<HashMap<String, String>> supportedModels) {
+ this.supportedModels = supportedModels;
+ }
+
+ public List<HashMap<String, String>> getSupportedComponents() {
+ return supportedComponents;
+ }
+
+ public void setSupportedComponents(List<HashMap<String, String>> supportedComponents) {
+ this.supportedComponents = supportedComponents;
+ }
+
+ public List<ActionArtifact> getArtifacts() {
+ return artifacts;
+ }
+
+ public void setArtifacts(List<ActionArtifact> artifacts) {
+ this.artifacts = artifacts;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+
+ /**
+ * To entity action entity.
+ *
+ * @return the action entity
+ */
+ public ActionEntity toEntity() {
+ ActionEntity destination = new ActionEntity();
+
+ destination
+ .setActionUuId(this.getActionUuId() != null ? this.getActionUuId().toUpperCase() : null);
+ destination.setActionInvariantUuId(
+ this.getActionInvariantUuId() != null ? this.getActionInvariantUuId().toUpperCase() : null);
+ destination.setName(this.getName() != null ? this.getName().toLowerCase() : null);
+ destination.setVendorList(this.getVendorList());
+ destination.setCategoryList(this.getCategoryList());
+ destination.setTimestamp(this.getTimestamp());
+ destination.setUser(this.getUser());
+ destination.setVersion(Version.valueOf(this.getVersion()));
+ if (this.getStatus() != null) {
+ destination.setStatus(this.getStatus().name());
+ }
+ destination.setSupportedComponents(
+ getIdFromMap(this.getSupportedComponents(), ActionConstants.SUPPORTED_COMPONENTS_ID));
+ destination.setSupportedModels(
+ getIdFromMap(this.getSupportedModels(), ActionConstants.SUPPORTED_MODELS_VERSION_ID));
+ destination.setData(this.getData());
+ return destination;
+ }
+
+ private List<String> getIdFromMap(List<HashMap<String, String>> map, String idName) {
+ List<String> list = new ArrayList<>();
+ if (map != null && !map.isEmpty()) {
+ map.forEach(entry -> {
+ if (entry.containsKey(idName)) {
+ list.add(entry.get(idName) != null ? entry.get(idName).toLowerCase() : null);
+ }
+ });
+ return list;
+ }
+ return null;
+ }
+
+ @Override
+ public int compareTo(Object object) {
+ Action obj = (Action) object;
+ Version thisVersion = Version.valueOf(this.version);
+ Version objVersion = Version.valueOf(obj.getVersion());
+ if (obj.getName().compareTo(this.getName()) == 0) {
+ return compareVersions(objVersion, thisVersion);
+ }
+ return obj.getName().compareTo(this.getName());
+ }
+
+ private int compareVersions(Version objVersion, Version thisVersion) {
+ if (objVersion.getMajor() == thisVersion.getMajor()) {
+ return Integer.compare(objVersion.getMinor(), thisVersion.getMinor());
+ }
+ return Integer.compare(objVersion.getMajor(), thisVersion.getMajor());
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionArtifact.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionArtifact.java
new file mode 100644
index 0000000000..ef41673541
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionArtifact.java
@@ -0,0 +1,139 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.types;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.openecomp.sdc.action.dao.types.ActionArtifactEntity;
+
+import java.nio.ByteBuffer;
+import java.util.Date;
+
+public class ActionArtifact {
+ private String artifactUuId;
+
+ @JsonIgnore
+ private Integer effectiveVersion;
+
+ private String artifactName;
+ private String artifactLabel;
+ private String artifactCategory;
+ private String artifactDescription;
+ private String artifactProtection;
+ private Date timestamp;
+ private byte[] artifact;
+
+ public String getArtifactUuId() {
+ return artifactUuId;
+ }
+
+ public void setArtifactUuId(String artifactUuId) {
+ this.artifactUuId = artifactUuId;
+ }
+
+ public Integer getEffectiveVersion() {
+ return effectiveVersion;
+ }
+
+ public void setEffectiveVersion(Integer effectiveVersion) {
+ this.effectiveVersion = effectiveVersion;
+ }
+
+ public String getArtifactName() {
+ return artifactName;
+ }
+
+ public void setArtifactName(String artifactName) {
+ this.artifactName = artifactName;
+ }
+
+ public String getArtifactLabel() {
+ return artifactLabel;
+ }
+
+ public void setArtifactLabel(String artifactLabel) {
+ this.artifactLabel = artifactLabel;
+ }
+
+ public String getArtifactCategory() {
+ return artifactCategory;
+ }
+
+ public void setArtifactCategory(String artifactCategory) {
+ this.artifactCategory = artifactCategory;
+ }
+
+ public String getArtifactDescription() {
+ return artifactDescription;
+ }
+
+ public void setArtifactDescription(String artifactDescription) {
+ this.artifactDescription = artifactDescription;
+ }
+
+ public String getArtifactProtection() {
+ return artifactProtection;
+ }
+
+ public void setArtifactProtection(String artifactProtection) {
+ this.artifactProtection = artifactProtection;
+ }
+
+ public Date getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(Date timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public byte[] getArtifact() {
+ return artifact;
+ }
+
+ public void setArtifact(byte[] artifact) {
+ this.artifact = artifact;
+ }
+
+ /**
+ * To entity action artifact entity.
+ *
+ * @return the action artifact entity
+ */
+ public ActionArtifactEntity toEntity() {
+ ActionArtifactEntity destination = new ActionArtifactEntity();
+ destination.setArtifactUuId(this.getArtifactUuId());
+ destination.setEffectiveVersion(this.getEffectiveVersion());
+ destination.setArtifact(ByteBuffer.wrap(this.getArtifact()));
+
+ return destination;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof ActionArtifact) {
+ ActionArtifact temp = (ActionArtifact) obj;
+ if (artifactUuId.equals(temp.getArtifactUuId())) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionArtifactProtection.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionArtifactProtection.java
new file mode 100644
index 0000000000..636f24d781
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionArtifactProtection.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.types;
+
+public enum ActionArtifactProtection {
+ readOnly,
+ readWrite
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionLogResponseCode.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionLogResponseCode.java
new file mode 100644
index 0000000000..c3de8aa4dc
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionLogResponseCode.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.types;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public enum ActionLogResponseCode {
+
+ MISSING_AUTHORIZATION(100),
+ FORBIDDEN(101),
+ UPDATE_ON_LOCKED_ENTITY(102),
+ CHECKIN_ON_LOCKED_ENTITY_OTHER_USER(103),
+ CHECKOUT_ON_LOCKED_ENTITY(104),
+ UNDO_CHECKOUT_ON_LOCKED_ENTITY(105),
+ DELETE_ARTIFACT_ON_LOCKED_ENTITY(106),
+ DELETE_ON_LOCKED_ENTITY_OTHER_USER(107),
+ INTERNAL_SERVER_ERROR(201),
+ MISSING_MANDATORY_PARAMS(300),
+ MISSING_INSTANCE_ID_HEADER(301),
+ MISSING_REQUEST_ID_HEADER(302),
+ MISSING_REQUEST_BODY(303),
+ INVALID_SEARCH_FILTER_CRITERIA(304),
+ INVALID_REQUESTED_VERSION(305),
+ CHECKSUM_ERROR(306),
+ ARTIFACT_TOO_BIG(307),
+ ACTION_NOT_FOUND(308),
+ ARTIFACT_NOT_FOUND(309),
+ METHOD_NOT_ALLOWED(310),
+ INVALID_REQUEST_PARAM(311),
+ ARTIFACT_PROTECTION_INVALID(312),
+ ACTION_NAME_UPDATE_NOT_ALLOWED(501),
+ //METHOD_NOT_ALLOWED(502),
+ ACTION_NAME_ALREADY_EXISTS(503),
+ MULTIPLE_FILTER_CRITERIA_NOT_SUPPORTED(504),
+ UPDATE_ON_UNLOCKED_ENTITY(505),
+ UPDATE_NOT_ALLOWED(506),
+ //METHOD_NOT_ALLOWED(507),
+ CHECKIN_ON_UNLOCKED_ENTITY(508),
+ SUBMIT_ON_FINAL_ENTITY(509),
+ SUBMIT_ON_LOCKED_ENTITY_OTHER_USER(510),
+ UNDO_CHECKOUT_ON_UNLOCKED_ENTITY(511),
+ ACTION_NOT_LOCKED(512),
+ ARTIFACT_ALREADY_EXISTS(513),
+ ARTIFACT_UPDATE_READ_ONLY(514),
+ ARTIFACT_DELETE_READ_ONLY(515),
+ ARTIFACT_NAME_INVALID(516),
+ ARTIFACT_CREATE_UPDATE_NOT_ALLOWED(518),
+ QUERY_FAILURE(519);
+
+ private static Map<Integer, ActionLogResponseCode> mapValueToEnum = new HashMap<>();
+
+ static {
+ for (ActionLogResponseCode responseCode : ActionLogResponseCode.values()) {
+ mapValueToEnum.put(responseCode.value, responseCode);
+ }
+ }
+
+ private int value;
+
+ ActionLogResponseCode(int value) {
+ this.value = value;
+ }
+
+ public static ActionLogResponseCode parseValue(int value) {
+ return mapValueToEnum.get(value);
+ }
+
+ public int getValue() {
+ return value;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionRequest.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionRequest.java
new file mode 100644
index 0000000000..1a20f9ecb7
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionRequest.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.types;
+
+public enum ActionRequest {
+ CREATE_ACTION,
+ UPDATE_ACTION,
+ DELETE_ACTION,
+ GET_FILTERED_ACTIONS,
+ GET_ACTIONS_INVARIANT_ID,
+ GET_ECOMP_COMPONENTS,
+ ACTION_VERSIONING,
+ CHECKOUT_ACTION,
+ CHECKIN_ACTION,
+ SUBMIT_ACTION,
+ UNDO_CHECKOUT_ACTION,
+ UPLOAD_ARTIFACT,
+ DOWNLOAD_ARTIFACT,
+ UPDATE_ARTIFACT,
+ DELETE_ARTIFACT,
+ GET_ACTION_UUID
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionStatus.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionStatus.java
new file mode 100644
index 0000000000..af3516e1eb
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionStatus.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.types;
+
+public enum ActionStatus {
+ Locked,
+ Available,
+ Final,
+ Deleted
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionSubOperation.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionSubOperation.java
new file mode 100644
index 0000000000..0dd97e6646
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/ActionSubOperation.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.types;
+
+public enum ActionSubOperation {
+ //Versioning operations
+ CREATE_ACTION_VERSION,
+ CREATE_ACTION_UNIQUE_VALUE,
+ GET_ACTION_VERSION,
+ //Action DAO operations
+ CREATE_ACTION_ENTITY,
+ GET_ACTIONENTITY_BY_ACTIONINVID,
+ GET_ACTIONENTITY_BY_ACTIONUUID,
+ GET_ACTIONENTITY_BY_VENDOR,
+ GET_ACTIONENTITY_BY_CATEGORY,
+ GET_ACTIONENTITY_BY_MODEL,
+ GET_ACTIONENTITY_BY_COMPONENT,
+ GET_ACTIONENTITY_BY_VERSION,
+ GET_ALL_ACTIONS,
+ GET_ACTIONINVID_BY_NAME,
+ GET_ECOMP_COMPONENTS_ENTITY,
+ GET_VERSIONINFO_FOR_ALL_ACTIONS,
+ GET_NAME_BY_ACTIONINVID,
+ CHECKOUT_ACTION,
+ UNDO_CHECKOUT_ACTION,
+ CHECKIN_ACTION,
+ SUBMIT_ACTION,
+ UPDATE_ACTION,
+ UPDATE_ACTION_STATUS,
+ DELETE_UNIQUEVALUE,
+ DELETE_ACTIONVERSION,
+ DELETE_ARTIFACT,
+ DELETE_ACTION,
+ //Validations
+ VALIDATE_ACTION_UNIQUE_NAME,
+ //Artifacts
+ GET_ARTIFACT_BY_ARTIFACTUUID,
+ CREATE_ACTION_ARTIFACT,
+ UPDATE_ACTION_ARTIFACT,
+ DELETE_ACTION_ARTIFACT,
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/EcompComponent.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/EcompComponent.java
new file mode 100644
index 0000000000..cbcebb13ef
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/types/EcompComponent.java
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.types;
+
+import org.openecomp.sdc.action.dao.types.EcompComponentEntity;
+
+public class EcompComponent {
+
+ private String id;
+ private String name;
+
+ public EcompComponent() {
+ //Default constructor
+ }
+
+ public EcompComponent(String name, String id) {
+ this.name = name;
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * To entity ecomp component entity.
+ *
+ * @return the ecomp component entity
+ */
+ public EcompComponentEntity toEntity() {
+ EcompComponentEntity destination = new EcompComponentEntity();
+ destination.setId(this.getId());
+ destination.setName(this.getName());
+ return destination;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object == null) {
+ return false;
+ }
+ if (this.getClass() != object.getClass()) {
+ return false;
+ }
+ EcompComponent obj = (EcompComponent) object;
+ if (id == null) {
+ if (obj.id != null) {
+ return false;
+ }
+ } else if (!id.equals(obj.id)) {
+ return false;
+ }
+ if (name == null) {
+ if (obj.name != null) {
+ return false;
+ }
+ } else if (!name.equals(obj.name)) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/util/ActionUtil.java b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/util/ActionUtil.java
new file mode 100644
index 0000000000..787f6abc26
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-action-lib/openecomp-sdc-action-api/src/main/java/org/openecomp/sdc/action/util/ActionUtil.java
@@ -0,0 +1,372 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.action.util;
+
+import static org.openecomp.sdc.action.ActionConstants.BEGIN_TIMESTAMP;
+import static org.openecomp.sdc.action.ActionConstants.ELAPSED_TIME;
+import static org.openecomp.sdc.action.ActionConstants.END_TIMESTAMP;
+import static org.openecomp.sdc.action.ActionConstants.ERROR_CATEGORY;
+import static org.openecomp.sdc.action.ActionConstants.ERROR_CODE;
+import static org.openecomp.sdc.action.ActionConstants.ERROR_DESCRIPTION;
+import static org.openecomp.sdc.action.ActionConstants.RESPONSE_CODE;
+import static org.openecomp.sdc.action.ActionConstants.RESPONSE_DESCRIPTION;
+import static org.openecomp.sdc.action.ActionConstants.SERVICE_METRIC_BEGIN_TIMESTAMP;
+import static org.openecomp.sdc.action.ActionConstants.STATUS_CODE;
+import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY;
+import static org.openecomp.sdc.action.ActionConstants.TARGET_SERVICE_NAME;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_ALREADY_EXISTS_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_CHECKSUM_ERROR_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_DELETE_READ_ONLY;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_INVALID_NAME_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_INVALID_PROTECTION_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_TOO_BIG_ERROR_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_UPDATE_READ_ONLY;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_AUTHENTICATION_ERR_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_AUTHORIZATION_ERR_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_CHECKIN_ON_ENTITY_LOCKED_BY_OTHER_USER;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_CHECKIN_ON_UNLOCKED_ENTITY;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_CHECKOUT_ON_LOCKED_ENTITY;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_CHECKOUT_ON_LOCKED_ENTITY_OTHER_USER;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_DELETE_ON_LOCKED_ENTITY_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_UNIQUE_VALUE_ERROR;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INTERNAL_SERVER_ERR_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_INSTANCE_ID_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_PARAM_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_REQUEST_BODY_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_REQUEST_ID_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INVALID_SEARCH_CRITERIA;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_MULT_SEARCH_CRITERIA;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_NOT_LOCKED_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_QUERY_FAILURE_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_INVALID_GENERIC_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_SUBMIT_FINALIZED_ENTITY_NOT_ALLOWED;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_SUBMIT_LOCKED_ENTITY_NOT_ALLOWED;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UNDO_CHECKOUT_ON_UNLOCKED_ENTITY;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UPDATE_INVALID_VERSION;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_CODE;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_CODE_NAME;
+import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UPDATE_ON_UNLOCKED_ENTITY;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.ACTION_NAME_ALREADY_EXISTS;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.ACTION_NAME_UPDATE_NOT_ALLOWED;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.ACTION_NOT_FOUND;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.ACTION_NOT_LOCKED;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.ARTIFACT_ALREADY_EXISTS;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.ARTIFACT_DELETE_READ_ONLY;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.ARTIFACT_NAME_INVALID;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.ARTIFACT_NOT_FOUND;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.ARTIFACT_PROTECTION_INVALID;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.ARTIFACT_TOO_BIG;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.ARTIFACT_UPDATE_READ_ONLY;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.CHECKIN_ON_LOCKED_ENTITY_OTHER_USER;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.CHECKIN_ON_UNLOCKED_ENTITY;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.CHECKOUT_ON_LOCKED_ENTITY;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.CHECKSUM_ERROR;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.DELETE_ARTIFACT_ON_LOCKED_ENTITY;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.DELETE_ON_LOCKED_ENTITY_OTHER_USER;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.INTERNAL_SERVER_ERROR;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.INVALID_REQUESTED_VERSION;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.INVALID_REQUEST_PARAM;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.INVALID_SEARCH_FILTER_CRITERIA;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.MISSING_AUTHORIZATION;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.MISSING_INSTANCE_ID_HEADER;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.MISSING_REQUEST_BODY;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.MISSING_REQUEST_ID_HEADER;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.MULTIPLE_FILTER_CRITERIA_NOT_SUPPORTED;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.QUERY_FAILURE;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.SUBMIT_ON_FINAL_ENTITY;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.SUBMIT_ON_LOCKED_ENTITY_OTHER_USER;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.UNDO_CHECKOUT_ON_LOCKED_ENTITY;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.UNDO_CHECKOUT_ON_UNLOCKED_ENTITY;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.UPDATE_NOT_ALLOWED;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.UPDATE_ON_LOCKED_ENTITY;
+import static org.openecomp.sdc.action.types.ActionLogResponseCode.UPDATE_ON_UNLOCKED_ENTITY;
+
+import org.openecomp.sdc.action.logging.CategoryLogLevel;
+import org.openecomp.sdc.action.logging.StatusCode;
+import org.openecomp.sdc.action.types.ActionLogResponseCode;
+import org.openecomp.sdc.action.types.ActionSubOperation;
+import org.slf4j.MDC;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.time.ZoneOffset;
+import java.util.Date;
+import java.util.TimeZone;
+
+
+public class ActionUtil {
+
+ private static final String UTC_DATE_FORMAT = "dd MMM yyyy kk:mm:ss z";
+ private static final String LOG_UTC_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS";
+
+ /**
+ * Get Current Timestamp in UTC format.
+ *
+ * @return Current Timestamp in UTC format.
+ */
+ public static Date getCurrentTimeStampUtc() {
+ return Date.from(java.time.ZonedDateTime.now(ZoneOffset.UTC).toInstant());
+ }
+
+ /**
+ * Convert timestamp to UTC format date string.
+ *
+ * @param timeStamp UTC timestamp to be converted to the UTC Date format.
+ * @return UTC formatted Date string from timestamp.
+ */
+ public static String getUtcDateStringFromTimestamp(Date timeStamp) {
+ DateFormat df = new SimpleDateFormat(UTC_DATE_FORMAT);
+ df.setTimeZone(TimeZone.getTimeZone("GMT"));
+ return df.format(timeStamp);
+ }
+
+ /**
+ * Convert timestamp to UTC format date string.
+ *
+ * @param timeStamp UTC timestamp to be converted to the UTC Date format.
+ * @return UTC formatted Date string from timestamp.
+ */
+ public static String getLogUtcDateStringFromTimestamp(Date timeStamp) {
+ DateFormat df = new SimpleDateFormat(LOG_UTC_DATE_FORMAT);
+ df.setTimeZone(TimeZone.getTimeZone("GMT"));
+ return df.format(timeStamp);
+ }
+
+ /**
+ * Method to set up specific attributes MDC for the current logging operation.
+ *
+ * @param subOperation Request Name.
+ */
+ public static void actionLogPreProcessor(ActionSubOperation subOperation, String targetEntity) {
+ MDC.put(BEGIN_TIMESTAMP, String.valueOf(System.currentTimeMillis()));
+ if (subOperation != null) {
+ MDC.put(TARGET_SERVICE_NAME, subOperation.name());
+ }
+
+ MDC.put(TARGET_ENTITY, targetEntity);
+ }
+
+ /**
+ * Method to enhance the MDC after the logging operation for Metrics and Audit logs.
+ *
+ * @param statusCode Response code for the current operation.
+ */
+ public static void actionLogPostProcessor(StatusCode statusCode) {
+ actionLogPostProcessor(statusCode, false);
+ }
+
+ public static void actionLogPostProcessor(StatusCode statusCode, boolean isServiceMetricLog) {
+ actionLogPostProcessor(statusCode, null, isServiceMetricLog);
+ }
+
+ public static void actionLogPostProcessor(StatusCode statusCode, String responseCode,
+ boolean isServiceMetricLog) {
+ actionLogPostProcessor(statusCode, responseCode, null, isServiceMetricLog);
+ }
+
+ /**
+ * Method to enhance the MDC after the logging operation for Metrics and Audit logs.
+ *
+ * @param statusCode Response code for the current operation.
+ */
+
+ public static void actionLogPostProcessor(StatusCode statusCode, String responseCode,
+ String responseDescription,
+ boolean isServiceMetricLog) {
+ MDC.put(STATUS_CODE, statusCode.name());
+ if (responseCode != null) {
+ int logResponseCode = getLogResponseCode(responseCode);
+ MDC.put(RESPONSE_CODE, Integer.toString(logResponseCode));
+ }
+ MDC.put(RESPONSE_DESCRIPTION, responseDescription);
+ long beginTimestamp;
+ if (isServiceMetricLog) {
+ beginTimestamp = Long.valueOf(MDC.get(SERVICE_METRIC_BEGIN_TIMESTAMP));
+ } else {
+ beginTimestamp = Long.valueOf(MDC.get(BEGIN_TIMESTAMP));
+ }
+ long endTimestamp = System.currentTimeMillis();
+ MDC.put(BEGIN_TIMESTAMP, getLogUtcDateStringFromTimestamp(new Date(beginTimestamp)));
+ MDC.put(END_TIMESTAMP, getLogUtcDateStringFromTimestamp(new Date(endTimestamp)));
+ MDC.put(ELAPSED_TIME, String.valueOf(endTimestamp - beginTimestamp));
+ }
+
+ /**
+ * Action Library Error logging Helper.
+ *
+ * @param errorCategory WARN or ERROR.
+ * @param errorCode Action Library exception code.
+ * @param errorDescription Description of the error.
+ */
+ public static void actionErrorLogProcessor(CategoryLogLevel errorCategory, String errorCode,
+ String errorDescription) {
+ MDC.put(ERROR_CATEGORY, errorCategory.name());
+ if (errorCode != null) {
+ String errorType = "";
+ switch (errorCategory) {
+ case WARN:
+ errorType = "W";
+ break;
+ case ERROR:
+ errorType = "E";
+ break;
+ case FATAL:
+ errorType = "F";
+ break;
+ default:
+ break;
+ }
+ MDC.put(ERROR_CODE, getLogResponseCode(errorCode) + errorType);
+ }
+ MDC.put(ERROR_DESCRIPTION, errorDescription);
+ }
+
+ /**
+ * Method to convert Action Library exception codes to OPENECOMP Audit codes in {@link.
+ * ActionLogResponseCode} e.g: ACT1060 --> 201.
+ *
+ * @param errorCode Action library exception code.
+ * @return Audit log code corresponding to the Action Library exception.
+ */
+ public static int getLogResponseCode(String errorCode) {
+ ActionLogResponseCode responseCode = INTERNAL_SERVER_ERROR;
+ switch (errorCode) {
+ case ACTION_REQUEST_INVALID_GENERIC_CODE:
+ responseCode = INVALID_REQUEST_PARAM;
+ break;
+ case ACTION_AUTHENTICATION_ERR_CODE:
+ break;
+ case ACTION_AUTHORIZATION_ERR_CODE:
+ responseCode = MISSING_AUTHORIZATION;
+ break;
+ case ACTION_INVALID_INSTANCE_ID_CODE:
+ responseCode = MISSING_INSTANCE_ID_HEADER;
+ break;
+ case ACTION_INVALID_REQUEST_ID_CODE:
+ responseCode = MISSING_REQUEST_ID_HEADER;
+ break;
+ case ACTION_INVALID_PARAM_CODE:
+ responseCode = INVALID_REQUEST_PARAM;
+ break;
+ case ACTION_INVALID_REQUEST_BODY_CODE:
+ responseCode = MISSING_REQUEST_BODY;
+ break;
+ case ACTION_UPDATE_NOT_ALLOWED_CODE_NAME:
+ responseCode = ACTION_NAME_UPDATE_NOT_ALLOWED;
+ break;
+ case ACTION_CHECKOUT_ON_LOCKED_ENTITY:
+ responseCode = CHECKOUT_ON_LOCKED_ENTITY;
+ break;
+ case ACTION_ENTITY_UNIQUE_VALUE_ERROR:
+ responseCode = ACTION_NAME_ALREADY_EXISTS;
+ break;
+ case ACTION_INVALID_SEARCH_CRITERIA:
+ responseCode = INVALID_SEARCH_FILTER_CRITERIA;
+ break;
+ case ACTION_MULT_SEARCH_CRITERIA:
+ responseCode = MULTIPLE_FILTER_CRITERIA_NOT_SUPPORTED;
+ break;
+ case ACTION_UPDATE_ON_UNLOCKED_ENTITY:
+ responseCode = UPDATE_ON_UNLOCKED_ENTITY;
+ break;
+ case ACTION_UPDATE_INVALID_VERSION:
+ responseCode = INVALID_REQUESTED_VERSION;
+ break;
+ case ACTION_UPDATE_NOT_ALLOWED_CODE:
+ responseCode = UPDATE_NOT_ALLOWED;
+ break;
+ case ACTION_CHECKIN_ON_UNLOCKED_ENTITY:
+ responseCode = CHECKIN_ON_UNLOCKED_ENTITY;
+ break;
+ case ACTION_SUBMIT_FINALIZED_ENTITY_NOT_ALLOWED:
+ responseCode = SUBMIT_ON_FINAL_ENTITY;
+ break;
+ case ACTION_SUBMIT_LOCKED_ENTITY_NOT_ALLOWED:
+ responseCode = SUBMIT_ON_LOCKED_ENTITY_OTHER_USER;
+ break;
+ case ACTION_UNDO_CHECKOUT_ON_UNLOCKED_ENTITY:
+ responseCode = UNDO_CHECKOUT_ON_UNLOCKED_ENTITY;
+ break;
+ case ACTION_NOT_LOCKED_CODE:
+ responseCode = ACTION_NOT_LOCKED;
+ break;
+ case ACTION_ARTIFACT_CHECKSUM_ERROR_CODE:
+ responseCode = CHECKSUM_ERROR;
+ break;
+ case ACTION_ARTIFACT_TOO_BIG_ERROR_CODE:
+ responseCode = ARTIFACT_TOO_BIG;
+ break;
+ case ACTION_ARTIFACT_ALREADY_EXISTS_CODE:
+ responseCode = ARTIFACT_ALREADY_EXISTS;
+ break;
+ case ACTION_ARTIFACT_UPDATE_READ_ONLY:
+ responseCode = ARTIFACT_UPDATE_READ_ONLY;
+ break;
+ case ACTION_ARTIFACT_DELETE_READ_ONLY:
+ responseCode = ARTIFACT_DELETE_READ_ONLY;
+ break;
+ case ACTION_ARTIFACT_INVALID_PROTECTION_CODE:
+ responseCode = ARTIFACT_PROTECTION_INVALID;
+ break;
+ case ACTION_ARTIFACT_INVALID_NAME_CODE:
+ responseCode = ARTIFACT_NAME_INVALID;
+ break;
+ case ACTION_EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER:
+ responseCode = UPDATE_ON_LOCKED_ENTITY;
+ break;
+ case ACTION_CHECKIN_ON_ENTITY_LOCKED_BY_OTHER_USER:
+ responseCode = CHECKIN_ON_LOCKED_ENTITY_OTHER_USER;
+ break;
+ case ACTION_CHECKOUT_ON_LOCKED_ENTITY_OTHER_USER:
+ responseCode = CHECKOUT_ON_LOCKED_ENTITY;
+ break;
+ case ACTION_UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER:
+ responseCode = UNDO_CHECKOUT_ON_LOCKED_ENTITY;
+ break;
+ case ACTION_ENTITY_NOT_EXIST_CODE:
+ responseCode = ACTION_NOT_FOUND;
+ break;
+ case ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE:
+ responseCode = ARTIFACT_NOT_FOUND;
+ break;
+ case ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER_CODE:
+ responseCode = DELETE_ARTIFACT_ON_LOCKED_ENTITY;
+ break;
+ case ACTION_DELETE_ON_LOCKED_ENTITY_CODE:
+ responseCode = DELETE_ON_LOCKED_ENTITY_OTHER_USER;
+ break;
+ case ACTION_INTERNAL_SERVER_ERR_CODE:
+ responseCode = INTERNAL_SERVER_ERROR;
+ break;
+ case ACTION_QUERY_FAILURE_CODE:
+ responseCode = QUERY_FAILURE;
+ break;
+ default:
+ break;
+ }
+ return responseCode.getValue();
+ }
+}