2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openecomp.sdc.action.impl;
19 import org.apache.commons.collections4.CollectionUtils;
20 import org.apache.commons.lang.StringUtils;
21 import org.openecomp.core.dao.UniqueValueDaoFactory;
22 import org.openecomp.core.util.UniqueValueUtil;
23 import org.openecomp.core.utilities.CommonMethods;
24 import org.openecomp.core.utilities.json.JsonUtil;
25 import org.openecomp.sdc.action.ActionConstants;
26 import org.openecomp.sdc.action.ActionManager;
27 import org.openecomp.sdc.action.dao.ActionArtifactDao;
28 import org.openecomp.sdc.action.dao.ActionArtifactDaoFactory;
29 import org.openecomp.sdc.action.dao.ActionDao;
30 import org.openecomp.sdc.action.dao.ActionDaoFactory;
31 import org.openecomp.sdc.action.dao.types.ActionArtifactEntity;
32 import org.openecomp.sdc.action.dao.types.ActionEntity;
33 import org.openecomp.sdc.action.errors.ActionErrorConstants;
34 import org.openecomp.sdc.action.errors.ActionException;
35 import org.openecomp.sdc.action.logging.StatusCode;
36 import org.openecomp.sdc.action.types.*;
37 import org.openecomp.sdc.common.errors.CoreException;
38 import org.openecomp.sdc.logging.api.Logger;
39 import org.openecomp.sdc.logging.api.LoggerFactory;
40 import org.openecomp.sdc.versioning.ActionVersioningManager;
41 import org.openecomp.sdc.versioning.ActionVersioningManagerFactory;
42 import org.openecomp.sdc.versioning.dao.VersionInfoDao;
43 import org.openecomp.sdc.versioning.dao.VersionInfoDaoFactory;
44 import org.openecomp.sdc.versioning.dao.types.UserCandidateVersion;
45 import org.openecomp.sdc.versioning.dao.types.Version;
46 import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity;
47 import org.openecomp.sdc.versioning.errors.EntityNotExistErrorBuilder;
48 import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
49 import org.openecomp.sdc.versioning.types.VersionInfo;
50 import org.openecomp.sdc.versioning.types.VersionableEntityAction;
55 import static org.openecomp.sdc.action.ActionConstants.*;
56 import static org.openecomp.sdc.action.errors.ActionErrorConstants.*;
57 import static org.openecomp.sdc.action.util.ActionUtil.*;
58 import static org.openecomp.sdc.versioning.dao.types.Version.VERSION_STRING_VIOLATION_MSG;
61 * Manager Implementation for {@link ActionManager Action Library Operations} <br> Handles Business
62 * layer validations and acts as an interface between the REST and DAO layers.
64 public class ActionManagerImpl implements ActionManager {
66 private static final ActionDao actionDao = ActionDaoFactory.getInstance().createInterface();
67 private static final ActionVersioningManager versioningManager =
68 ActionVersioningManagerFactory.getInstance().createInterface();
69 private static final ActionArtifactDao actionArtifactDao =
70 ActionArtifactDaoFactory.getInstance().createInterface();
71 private static VersionInfoDao versionInfoDao =
72 VersionInfoDaoFactory.getInstance().createInterface();
74 private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
76 public ActionManagerImpl() {
77 actionDao.registerVersioning(ACTION_VERSIONABLE_TYPE);
81 * List All Major, Last Minor and Candidate version (if any) for Given Action Invariant UUID
83 * @param invariantId Invariant UUID of the action for which the information is required
84 * @return List of All Major, Last Minor and Candidate version if any Of {@link Action} with given
85 * actionInvariantUuId.
86 * @throws ActionException Exception with an action library specific code, short description and
87 * detailed message for the error occurred during the operation
91 public List<Action> getActionsByActionInvariantUuId(String invariantId) throws ActionException {
94 log.debug(" entering getActionsByActionInvariantUuId with invariantID = " + invariantId);
96 .getActionsByActionInvariantUuId(invariantId != null ? invariantId.toUpperCase() : null);
98 if (actions != null && actions.isEmpty()) {
99 throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST);
102 log.debug(" exit getActionsByActionInvariantUuId with invariantID = " + invariantId);
107 * Get list of actions based on a filter criteria. If no filter is sent all actions will be
110 * @param filterType Filter by Vendor/Category/Model/Component/None
111 * @param filterValue Filter Parameter Value (Vendor ID/Category ID/Model ID/Component ID)
112 * @return List of {@link Action} objects based on a filter criteria <br> Empty List if no records
113 * match the provided filter criteria
114 * @throws ActionException Exception with an action library specific code, short description and
115 * detailed message for the error occurred for the error occurred during
119 public List<Action> getFilteredActions(String filterType, String filterValue)
120 throws ActionException {
121 List<Action> actions;
122 log.debug(" entering getFilteredActions By filterType = " + filterType + " With value = "
124 switch (filterType) {
125 case FILTER_TYPE_NONE:
126 //Business validation for OPENECOMP Component type fetch (if any)
128 case FILTER_TYPE_VENDOR:
129 //Business validation for vendor type fetch (if any)
131 case FILTER_TYPE_CATEGORY:
132 //Business validation for Category type fetch (if any)
134 case FILTER_TYPE_MODEL:
135 //Business validation for model type fetch (if any)
137 case FILTER_TYPE_OPEN_ECOMP_COMPONENT:
138 //Business validation for OPENECOMP Component type fetch (if any)
140 case FILTER_TYPE_NAME:
142 .getFilteredActions(filterType, filterValue != null ? filterValue.toLowerCase() : null);
143 if (actions != null && actions.isEmpty()) {
144 throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST);
146 log.debug(" exit getFilteredActions By filterType = " + filterType + " With value = "
153 .getFilteredActions(filterType, filterValue != null ? filterValue.toLowerCase() : null);
154 List<Action> majorMinorVersionList = getMajorMinorVersionActions(actions);
155 Collections.sort(majorMinorVersionList);
157 " exit getFilteredActions By filterType = " + filterType + " With value = " + filterValue);
158 return majorMinorVersionList;
162 * Get the properties of an action version by its UUID.
164 * @param actionUuId UUID of the specific action version
165 * @return {@link Action} object corresponding the version represented by the UUID
166 * @throws ActionException Exception with an action library specific code, short description and
167 * detailed message for the error occurred for the error occurred during
171 public Action getActionsByActionUuId(String actionUuId) throws ActionException {
172 log.debug(" entering getActionsByActionUuId with actionUUID = " + actionUuId);
174 actionDao.getActionsByActionUuId(actionUuId != null ? actionUuId.toUpperCase() : null);
176 if (action == null) {
177 throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST);
180 log.debug(" exit getActionsByActionUuId with actionUUID = " + actionUuId);
185 * List OPENECOMP Components supported by Action Library.
187 * @return List of {@link OpenEcompComponent} objects supported by Action Library <br> Empty List if
188 * no components are found
189 * @throws ActionException Exception with an action library specific code, short description and
190 * detailed message for the error occurred for the error occurred during
194 public List<OpenEcompComponent> getOpenEcompComponents() throws ActionException {
195 return actionDao.getOpenEcompComponents();
202 * @param actionInvariantUuId Invariant UUID of the action to be deleted
203 * @param user User id of the user performing the operation
206 public void deleteAction(String actionInvariantUuId, String user) throws ActionException {
208 log.debug("entering deleteAction with actionInvariantUuId = " + actionInvariantUuId
209 + " and user = " + user);
210 actionLogPreProcessor(ActionSubOperation.DELETE_ACTION, TARGET_ENTITY_API);
211 versioningManager.delete(ACTION_VERSIONABLE_TYPE, actionInvariantUuId, user);
212 actionLogPostProcessor(StatusCode.COMPLETE);
214 actionDao.deleteAction(actionInvariantUuId);
215 } catch (CoreException ce) {
216 formAndThrowException(ce);
221 * Create a new Action.
223 * @param action Action object model of the user request for creating an action
224 * @param user AT&T id of the user sending the create request
225 * @return {@link Action} model object for the created action
226 * @throws ActionException Exception with an action library specific code, short description and
227 * detailed message for the error occurred for the error occurred during
231 public Action createAction(Action action, String user) throws ActionException {
232 UniqueValueUtil uniqueValueUtil =
233 new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface());
235 actionLogPreProcessor(ActionSubOperation.VALIDATE_ACTION_UNIQUE_NAME, TARGET_ENTITY_API);
237 .validateUniqueValue(ActionConstants.UniqueValues.ACTION_NAME, action.getName());
238 actionLogPostProcessor(StatusCode.COMPLETE);
239 } catch (CoreException exception) {
240 String errorDesc = String
241 .format(ACTION_ENTITY_UNIQUE_VALUE_MSG, ActionConstants.UniqueValues.ACTION_NAME,
243 log.error(errorDesc, exception);
244 actionLogPostProcessor(StatusCode.ERROR, ACTION_ENTITY_UNIQUE_VALUE_ERROR, errorDesc, false);
245 throw new ActionException(ACTION_ENTITY_UNIQUE_VALUE_ERROR, errorDesc);
249 action.setUser(user);
250 action.setTimestamp(getCurrentTimeStampUtc());
251 action.setActionInvariantUuId(CommonMethods.nextUuId());
252 action.setActionUuId(CommonMethods.nextUuId());
254 actionLogPreProcessor(ActionSubOperation.CREATE_ACTION_VERSION, TARGET_ENTITY_API);
256 versioningManager.create(ACTION_VERSIONABLE_TYPE, action.getActionInvariantUuId(), user);
257 actionLogPostProcessor(StatusCode.COMPLETE);
260 action.setVersion(version.toString());
261 action.setStatus(ActionStatus.Locked);
262 action = updateData(action);
263 action = actionDao.createAction(action);
265 actionLogPreProcessor(ActionSubOperation.CREATE_ACTION_UNIQUE_VALUE, TARGET_ENTITY_API);
266 uniqueValueUtil.createUniqueValue(ActionConstants.UniqueValues.ACTION_NAME, action.getName());
267 actionLogPostProcessor(StatusCode.COMPLETE);
274 * Update an existing action.
276 * @param action Action object model of the user request for creating an action
277 * @param user AT&T id of the user sending the update request
278 * @return {@link Action} model object for the update action
279 * @throws ActionException Exception with an action library specific code, short description and
280 * detailed message for the error occurred for the error occurred during
284 public Action updateAction(Action action, String user) throws ActionException {
286 log.debug("entering updateAction to update action with invariantUuId = "
287 + action.getActionInvariantUuId() + " by user = " + user);
288 String invariantUuId = action.getActionInvariantUuId();
289 actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_API);
290 VersionInfo versionInfo = versioningManager
291 .getEntityVersionInfo(ACTION_VERSIONABLE_TYPE, invariantUuId, user,
292 VersionableEntityAction.Write);
293 actionLogPostProcessor(StatusCode.COMPLETE);
296 Version activeVersion = versionInfo.getActiveVersion();
297 validateActions(action, activeVersion);
298 action.setStatus(ActionStatus.Locked); //Status will be Checkout for update
300 action.setUser(user);
301 action.setTimestamp(getCurrentTimeStampUtc());
302 actionDao.updateAction(action);
304 } catch (CoreException ce) {
305 formAndThrowException(ce);
307 log.debug("exit updateAction");
312 * Checkout an existing action.
314 * @param invariantUuId actionInvariantUuId of the action to be checked out
315 * @param user AT&T id of the user sending the checkout request
316 * @return {@link Action} model object for the checkout action
317 * @throws ActionException Exception with an action library specific code, short description and
318 * detailed message for the error occurred for the error occurred during
322 public Action checkout(String invariantUuId, String user) throws ActionException {
323 Version version = null;
324 ActionEntity actionEntity = null;
327 "entering checkout for Action with invariantUUID= " + invariantUuId + " by user = "
329 actionLogPreProcessor(ActionSubOperation.CHECKOUT_ACTION, TARGET_ENTITY_API);
330 version = versioningManager.checkout(ACTION_VERSIONABLE_TYPE, invariantUuId, user);
331 actionLogPostProcessor(StatusCode.COMPLETE);
335 updateUniqueIdForVersion(invariantUuId, version, ActionStatus.Locked.name(), user);
336 } catch (CoreException exception) {
337 if (exception.code() != null && exception.code().id().equals(
338 VersioningErrorCodes.CHECKOT_ON_LOCKED_ENTITY)) {
339 actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
340 VersionInfoEntity versionInfoEntity =
341 versionInfoDao.get(new VersionInfoEntity(ACTION_VERSIONABLE_TYPE, invariantUuId));
342 actionLogPostProcessor(StatusCode.COMPLETE);
344 String checkoutUser = versionInfoEntity.getCandidate().getUser();
346 "Actual checkout user for Action with invariantUUID= " + invariantUuId + " is = "
348 if (!checkoutUser.equals(user)) {
349 throw new ActionException(ACTION_CHECKOUT_ON_LOCKED_ENTITY_OTHER_USER,
350 exception.getMessage());
353 formAndThrowException(exception);
356 "exit checkout for Action with invariantUUID= " + invariantUuId + " by user = " + user);
357 return actionEntity != null ? actionEntity.toDto() : new Action();
361 * Undo an already checked out action.
363 * @param invariantUuId actionInvariantUuId of the checked out action
364 * @param user AT&T id of the user sending the request
365 * @throws ActionException Exception with an action library specific code, short description and
366 * detailed message for the error occurred for the error occurred during
370 public void undoCheckout(String invariantUuId, String user) throws ActionException {
374 "entering undoCheckout for Action with invariantUUID= " + invariantUuId + " by user = "
377 actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
378 //Get list of uploaded artifacts in this checked out version
379 VersionInfoEntity versionInfoEntity =
380 versionInfoDao.get(new VersionInfoEntity(ACTION_VERSIONABLE_TYPE, invariantUuId));
381 actionLogPostProcessor(StatusCode.COMPLETE);
383 if (versionInfoEntity == null) {
384 throw new CoreException(
385 new EntityNotExistErrorBuilder(ACTION_VERSIONABLE_TYPE, invariantUuId).build());
387 UserCandidateVersion candidate = versionInfoEntity.getCandidate();
388 Version activeVersion;
389 if (candidate != null) {
390 activeVersion = candidate.getVersion();
392 activeVersion = versionInfoEntity.getActiveVersion();
395 actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_VERSION, TARGET_ENTITY_DB);
396 Action action = actionDao.get(new ActionEntity(invariantUuId, activeVersion)).toDto();
397 actionLogPostProcessor(StatusCode.COMPLETE);
400 //Perform undo checkout on the action
401 actionLogPreProcessor(ActionSubOperation.UNDO_CHECKOUT_ACTION, TARGET_ENTITY_API);
402 version = versioningManager.undoCheckout(ACTION_VERSIONABLE_TYPE, invariantUuId, user);
403 actionLogPostProcessor(StatusCode.COMPLETE);
406 if (version.equals(new Version(0, 0))) {
407 actionLogPreProcessor(ActionSubOperation.DELETE_UNIQUEVALUE, TARGET_ENTITY_API);
408 UniqueValueUtil uniqueValueUtil =
409 new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface());
411 .deleteUniqueValue(ActionConstants.UniqueValues.ACTION_NAME, action.getName());
412 actionLogPostProcessor(StatusCode.COMPLETE);
415 actionLogPreProcessor(ActionSubOperation.DELETE_ACTIONVERSION, TARGET_ENTITY_DB);
416 //Added for the case where Create->Undo_Checkout->Checkout should not get the action
417 versionInfoDao.delete(new VersionInfoEntity(ACTION_VERSIONABLE_TYPE, invariantUuId));
418 actionLogPostProcessor(StatusCode.COMPLETE);
422 List<ActionArtifact> currentVersionArtifacts = action.getArtifacts();
424 //Delete the artifacts from action_artifact table (if any)
425 if (CollectionUtils.isNotEmpty(currentVersionArtifacts) &&
426 currentVersionArtifacts.size() > 0) {
427 for (ActionArtifact artifact : currentVersionArtifacts) {
428 ActionArtifactEntity artifactDeleteEntity =
429 new ActionArtifactEntity(artifact.getArtifactUuId(),
430 getEffectiveVersion(activeVersion.toString()));
431 actionLogPreProcessor(ActionSubOperation.DELETE_ARTIFACT, TARGET_ENTITY_DB);
432 actionArtifactDao.delete(artifactDeleteEntity);
433 actionLogPostProcessor(StatusCode.COMPLETE);
437 } catch (CoreException exception) {
438 formAndThrowException(exception);
441 "exit undoCheckout for Action with invariantUUID= " + invariantUuId + " by user = " + user);
445 * Checkin a checked out action.
447 * @param invariantUuId actionInvariantUuId of the checked out action
448 * @param user AT&T id of the user sending the request
449 * @return {@link Action} model object for the updated action
450 * @throws ActionException Exception with an action library specific code, short description and
451 * detailed message for the error occurred for the error occurred during
455 public Action checkin(String invariantUuId, String user) throws ActionException {
456 Version version = null;
457 ActionEntity actionEntity = null;
459 log.debug("entering checkin for Action with invariantUUID= " + invariantUuId + " by user = "
461 actionLogPreProcessor(ActionSubOperation.CHECKIN_ACTION, TARGET_ENTITY_API);
462 version = versioningManager.checkin(ACTION_VERSIONABLE_TYPE, invariantUuId, user, null);
463 actionLogPostProcessor(StatusCode.COMPLETE);
466 updateStatusForVersion(invariantUuId, version, ActionStatus.Available.name(), user);
467 } catch (CoreException exception) {
468 formAndThrowException(exception);
471 "exit checkin for Action with invariantUUID= " + invariantUuId + " by user = " + user);
472 return actionEntity != null ? actionEntity.toDto() : new Action();
476 * Submit a checked in action.
478 * @param invariantUuId actionInvariantUuId of the checked in action
479 * @param user AT&T id of the user sending the request
480 * @return {@link Action} model object for the updated action
481 * @throws ActionException Exception with an action library specific code, short description and
482 * detailed message for the error occurred for the error occurred during
486 public Action submit(String invariantUuId, String user) throws ActionException {
487 Version version = null;
488 ActionEntity actionEntity = null;
491 "entering submit for Action with invariantUUID= " + invariantUuId + " by user = " + user);
492 actionLogPreProcessor(ActionSubOperation.SUBMIT_ACTION, TARGET_ENTITY_API);
493 version = versioningManager.submit(ACTION_VERSIONABLE_TYPE, invariantUuId, user, null);
494 actionLogPostProcessor(StatusCode.COMPLETE);
497 updateUniqueIdForVersion(invariantUuId, version, ActionStatus.Final.name(), user);
498 } catch (CoreException exception) {
499 formAndThrowException(exception);
501 log.debug("exit submit for Action with invariantUUID= " + invariantUuId + " by user = " + user);
502 return actionEntity != null ? actionEntity.toDto() : new Action();
506 * Download an artifact of an action.
508 * @param artifactUuId {@link ActionArtifact} object representing the artifact and its metadata
509 * @param actionUuId UUID of the action for which the artifact has to be downloaded
510 * @return downloaded action artifact object
513 public ActionArtifact downloadArtifact(String actionUuId, String artifactUuId)
514 throws ActionException {
515 log.debug(" entering downloadArtifact with actionUUID= " + actionUuId + " and artifactUUID= "
517 Action action = actionDao.getActionsByActionUuId(actionUuId);
518 ActionArtifact actionArtifact;
519 if (action != null) {
520 MDC.put(SERVICE_INSTANCE_ID, action.getActionInvariantUuId());
521 List<ActionArtifact> artifacts = action.getArtifacts();
522 String actionVersion = action.getVersion();
523 int effectiveVersion = getEffectiveVersion(actionVersion);
524 ActionArtifact artifactMetadata =
525 getArtifactMetadataFromAction(artifacts, ARTIFACT_METADATA_ATTR_UUID, artifactUuId);
526 if (artifactMetadata != null) {
527 String artifactName = artifactMetadata.getArtifactName();
528 actionArtifact = actionArtifactDao.downloadArtifact(effectiveVersion, artifactUuId);
529 actionArtifact.setArtifactName(artifactName);
532 throw new ActionException(ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE,
533 ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST);
536 throw new ActionException(ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE,
537 ActionErrorConstants.ACTION_ENTITY_NOT_EXIST);
539 log.debug(" exit downloadArtifact with actionUUID= " + actionUuId + " and artifactUUID= "
541 return actionArtifact;
545 * Upload an artifact to an action.
547 * @param artifact {@link ActionArtifact} object representing the artifact and its
549 * @param actionInvariantUuId Invariant UUID of the action to which the artifact has to be
551 * @param user User ID of the user sending the request
552 * @return Uploaded action artifact object
555 public ActionArtifact uploadArtifact(ActionArtifact artifact, String actionInvariantUuId,
557 ActionArtifact uploadArtifactResponse = new ActionArtifact();
559 log.debug("entering uploadArtifact with actionInvariantUuId= " + actionInvariantUuId
560 + "artifactName= " + artifact.getArtifactName());
561 actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
562 VersionInfo versionInfo = versioningManager
563 .getEntityVersionInfo(ACTION_VERSIONABLE_TYPE, actionInvariantUuId, user,
564 VersionableEntityAction.Write);
565 actionLogPostProcessor(StatusCode.COMPLETE);
567 Version activeVersion = versionInfo.getActiveVersion();
568 actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_ACTIONINVID, TARGET_ENTITY_DB);
569 Action action = actionDao.get(new ActionEntity(actionInvariantUuId, activeVersion)).toDto();
570 actionLogPostProcessor(StatusCode.COMPLETE);
572 String artifactUuId = generateActionArtifactUuId(action, artifact.getArtifactName());
573 //Check for Unique document name
574 List<ActionArtifact> actionArtifacts = action.getArtifacts();
575 ActionArtifact artifactMetadata =
576 getArtifactMetadataFromAction(actionArtifacts, ARTIFACT_METADATA_ATTR_NAME,
577 artifact.getArtifactName());
578 if (artifactMetadata != null) {
579 throw new ActionException(ACTION_ARTIFACT_ALREADY_EXISTS_CODE,
580 String.format(ACTION_ARTIFACT_ALREADY_EXISTS, actionInvariantUuId));
583 //Create the artifact
584 artifact.setArtifactUuId(artifactUuId);
585 artifact.setTimestamp(getCurrentTimeStampUtc());
586 artifact.setEffectiveVersion(getEffectiveVersion(activeVersion.toString()));
587 actionArtifactDao.uploadArtifact(artifact);
589 //Update the action data field and timestamp
590 addArtifactMetadataInActionData(action, artifact);
592 //Set the response object
593 uploadArtifactResponse.setArtifactUuId(artifact.getArtifactUuId());
594 } catch (CoreException ce) {
595 formAndThrowException(ce);
598 "exit uploadArtifact with actionInvariantUuId= " + actionInvariantUuId + "artifactName= "
599 + artifact.getArtifactName());
600 return uploadArtifactResponse;
604 public void deleteArtifact(String actionInvariantUuId, String artifactUuId, String user)
605 throws ActionException {
607 "enter deleteArtifact with actionInvariantUuId= " + actionInvariantUuId + "artifactUUID= "
608 + artifactUuId + " and user = " + user);
609 Action action = actionDao.getLockedAction(actionInvariantUuId, user);
610 List<ActionArtifact> actionArtifacts = action.getArtifacts();
611 ActionArtifact artifactMetadata =
612 getArtifactMetadataFromAction(actionArtifacts, ARTIFACT_METADATA_ATTR_UUID, artifactUuId);
613 if (artifactMetadata == null) {
614 throw new ActionException(ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE,
615 ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST);
617 if (artifactMetadata.getArtifactProtection().equals(ActionArtifactProtection.readOnly.name())) {
618 throw new ActionException(ACTION_ARTIFACT_DELETE_READ_ONLY,
619 ACTION_ARTIFACT_DELETE_READ_ONLY_MSG);
622 //Update action by removing artifact metadata
623 String jsonData = action.getData();
624 List<ActionArtifact> artifacts = action.getArtifacts();//action.getArtifacts();
625 ActionArtifact artifact = null;
626 Iterator<ActionArtifact> it = artifacts.iterator();
627 while (it.hasNext()) {
628 artifact = it.next();
629 String artifactId = artifact.getArtifactUuId();
630 if (artifactId.equals(artifactUuId)) {
635 Map dataMap = JsonUtil.json2Object(jsonData, LinkedHashMap.class);
636 dataMap.put("artifacts", artifacts);
637 String data = JsonUtil.object2Json(dataMap);
638 ActionEntity actionEntity = action.toEntity();
639 actionEntity.setData(data);
640 actionLogPreProcessor(ActionSubOperation.UPDATE_ACTION, TARGET_ENTITY_DB);
641 actionDao.update(actionEntity);
642 actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
644 // delete Artifact if it's upload and delete action on same checkout version
645 String artifactName = artifactMetadata.getArtifactName();
646 String generatedArtifactUuId = generateActionArtifactUuId(action, artifactName);
647 if (generatedArtifactUuId.equals(artifactUuId)) {
648 if (artifact != null) {
649 ActionArtifactEntity artifactDeleteEntity =
650 new ActionArtifactEntity(artifact.getArtifactUuId(),
651 getEffectiveVersion(action.getVersion()));
652 actionLogPreProcessor(ActionSubOperation.DELETE_ACTION_ARTIFACT, TARGET_ENTITY_DB);
653 actionArtifactDao.delete(artifactDeleteEntity);
655 actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
661 "exit deleteArtifact with actionInvariantUuId= " + actionInvariantUuId + "artifactUUID= "
662 + artifactUuId + " and user = " + user);
666 * Update an existing artifact.
668 * @param artifact {@link ActionArtifact} object representing the artifact and its
670 * @param actionInvariantUuId Invariant UUID of the action to which the artifact has to be
672 * @param user User ID of the user sending the request
674 public void updateArtifact(ActionArtifact artifact, String actionInvariantUuId, String user) {
676 log.debug("Enter updateArtifact with actionInvariantUuId= " + actionInvariantUuId
677 + "artifactUUID= " + artifact.getArtifactUuId() + " and user = " + user);
678 actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_API);
679 VersionInfo versionInfo = versioningManager
680 .getEntityVersionInfo(ACTION_VERSIONABLE_TYPE, actionInvariantUuId, user,
681 VersionableEntityAction.Write);
682 actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
684 Version activeVersion = versionInfo.getActiveVersion();
685 actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_ACTIONINVID, TARGET_ENTITY_DB);
686 Action action = actionDao.get(new ActionEntity(actionInvariantUuId, activeVersion)).toDto();
687 actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
689 List<ActionArtifact> actionArtifacts = action.getArtifacts();
690 ActionArtifact artifactMetadataByUuId =
691 getArtifactMetadataFromAction(actionArtifacts, ARTIFACT_METADATA_ATTR_UUID,
692 artifact.getArtifactUuId());
693 //Check if artifact is already in action or not
694 if (artifactMetadataByUuId == null) {
695 throw new ActionException(ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE,
696 ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST);
698 //If user tries to change artifact name
699 if (artifact.getArtifactName() != null
700 && !artifactMetadataByUuId.getArtifactName().equalsIgnoreCase(
701 artifact.getArtifactName())) {
702 throw new ActionException(ACTION_UPDATE_NOT_ALLOWED_CODE,
703 ACTION_ARTIFACT_UPDATE_NAME_INVALID);
706 byte[] payload = artifact.getArtifact();
707 String artifactLabel = artifact.getArtifactLabel();
708 String artifactCategory = artifact.getArtifactCategory();
709 String artifactDescription = artifact.getArtifactDescription();
710 String artifactProtection = artifact.getArtifactProtection();
711 String artifactName = artifact.getArtifactName();
712 //If artifact read only
713 if (artifactMetadataByUuId.getArtifactProtection()
714 .equals(ActionArtifactProtection.readOnly.name())) {
715 if (artifactName != null || artifactLabel != null || artifactCategory != null
716 || artifactDescription != null || payload != null) {
717 throw new ActionException(ACTION_ARTIFACT_UPDATE_READ_ONLY,
718 ACTION_ARTIFACT_UPDATE_READ_ONLY_MSG);
720 //Changing value from readOnly to readWrite
721 if (artifactProtection != null
722 && artifactProtection.equals(ActionArtifactProtection.readWrite.name())) {
723 artifactMetadataByUuId.setArtifactProtection(ActionArtifactProtection.readWrite.name());
724 artifactMetadataByUuId.setTimestamp(getCurrentTimeStampUtc());
725 updateArtifactMetadataInActionData(action, artifactMetadataByUuId);
728 int effectiveVersion = getEffectiveVersion(activeVersion.toString());
729 if (artifactLabel != null) {
730 artifactMetadataByUuId.setArtifactLabel(artifactLabel);
732 if (artifactCategory != null) {
733 artifactMetadataByUuId.setArtifactCategory(artifactCategory);
735 if (artifactDescription != null) {
736 artifactMetadataByUuId.setArtifactDescription(artifactDescription);
738 if (artifactProtection != null) {
739 artifactMetadataByUuId.setArtifactProtection(artifactProtection);
741 if (payload != null) {
742 //get artifact data from action_artifact table for updating the content
743 ActionArtifact artifactContent = new ActionArtifact();
744 artifactContent.setArtifactUuId(artifact.getArtifactUuId());
745 artifactContent.setArtifact(payload);
746 artifactContent.setEffectiveVersion(effectiveVersion);
747 actionArtifactDao.updateArtifact(artifactContent);
749 //Update the action data field and timestamp
750 artifactMetadataByUuId.setTimestamp(getCurrentTimeStampUtc());
751 updateArtifactMetadataInActionData(action, artifactMetadataByUuId);
753 log.debug("exit updateArtifact with actionInvariantUuId= " + actionInvariantUuId
754 + "artifactUUID= " + artifact.getArtifactUuId() + " and user = " + user);
755 } catch (CoreException coreException) {
756 formAndThrowException(coreException);
761 * Generate artifact UUID at runtime using action name and effective version.
763 * @param action {@link Action} for which the artifact is being uploaded/updated/downloaded
764 * @param artifactName Artifact name
765 * @return Generated UUID string
767 private String generateActionArtifactUuId(Action action, String artifactName) {
768 int effectiveVersion = getEffectiveVersion(action.getVersion());
769 //Upper case for maintaining case-insensitive behavior for the artifact names
770 String artifactUuIdString =
771 action.getName().toUpperCase() + effectiveVersion + artifactName.toUpperCase();
772 String generateArtifactUuId =
773 UUID.nameUUIDFromBytes((artifactUuIdString).getBytes()).toString();
774 String artifactUuId = generateArtifactUuId.replace("-", "");
775 return artifactUuId.toUpperCase();
779 * Generate the effective action version for artifact operations.
781 * @param actionVersion Version of the action as a string
782 * @return Effective version to be used for artifact operations
784 private int getEffectiveVersion(String actionVersion) {
785 Version version = Version.valueOf(actionVersion);
786 return version.getMajor() * 10000 + version.getMinor();
790 * Update the data field of the Action object with the modified/generated fields after an
793 * @param action Action object whose data field has to be updated
794 * @return Updated {@link Action} object
796 private Action updateData(Action action) {
797 log.debug("entering updateData to update data json for action with actionuuid= "
798 + action.getActionUuId());
799 Map<String, String> dataMap = new LinkedHashMap<>();
800 dataMap.put(ActionConstants.UNIQUE_ID, action.getActionUuId());
801 dataMap.put(ActionConstants.VERSION, action.getVersion());
802 dataMap.put(ActionConstants.INVARIANTUUID, action.getActionInvariantUuId());
803 dataMap.put(ActionConstants.STATUS, action.getStatus().name());
805 String data = action.getData();
806 Map<String, String> currentDataMap = JsonUtil.json2Object(data, LinkedHashMap.class);
807 dataMap.putAll(currentDataMap);
808 data = JsonUtil.object2Json(dataMap);
809 action.setData(data);
810 log.debug("exit updateData");
815 * Method to add the artifact metadata in the data attribute of action table.
817 * @param action Action to which artifact is uploaded
818 * @param artifact Uploaded artifact object
820 private void addArtifactMetadataInActionData(Action action, ActionArtifact artifact) {
822 ActionArtifact artifactMetadata = new ActionArtifact();
823 artifactMetadata.setArtifactUuId(artifact.getArtifactUuId());
824 artifactMetadata.setArtifactName(artifact.getArtifactName());
825 artifactMetadata.setArtifactProtection(artifact.getArtifactProtection());
826 artifactMetadata.setArtifactLabel(artifact.getArtifactLabel());
827 artifactMetadata.setArtifactDescription(artifact.getArtifactDescription());
828 artifactMetadata.setArtifactCategory(artifact.getArtifactCategory());
829 artifactMetadata.setTimestamp(artifact.getTimestamp());
831 List<ActionArtifact> actionArtifacts = action.getArtifacts();
832 if (actionArtifacts == null) {
833 actionArtifacts = new ArrayList<>();
835 actionArtifacts.add(artifactMetadata);
836 action.setArtifacts(actionArtifacts);
837 String currentData = action.getData();
838 Map<String, Object> currentDataMap = JsonUtil.json2Object(currentData, LinkedHashMap.class);
839 currentDataMap.put(ActionConstants.ARTIFACTS, actionArtifacts);
840 String updatedActionData = JsonUtil.object2Json(currentDataMap);
841 action.setData(updatedActionData);
842 action.setTimestamp(artifact.getTimestamp());
843 actionDao.updateAction(action);
847 * Get a list of last major and last minor version (no candidate) of action from a list of
850 * @param actions Exhaustive list of the action versions
851 * @return List {@link Action} of last major and last minor version (no candidate) of action from
854 private List<Action> getMajorMinorVersionActions(List<Action> actions) {
855 log.debug(" entering getMajorMinorVersionActions for actions ");
856 List<Action> list = new LinkedList<>();
857 actionLogPreProcessor(ActionSubOperation.GET_VERSIONINFO_FOR_ALL_ACTIONS, TARGET_ENTITY_API);
858 Map<String, VersionInfo> actionVersionMap = versioningManager
859 .listEntitiesVersionInfo(ACTION_VERSIONABLE_TYPE, "", VersionableEntityAction.Read);
860 actionLogPostProcessor(StatusCode.COMPLETE);
862 for (Action action : actions) {
863 if (action.getStatus() == ActionStatus.Deleted) {
866 VersionInfo actionVersionInfo = actionVersionMap.get(action.getActionInvariantUuId());
867 if (actionVersionInfo.getActiveVersion() != null
868 && actionVersionInfo.getActiveVersion().equals(Version.valueOf(action.getVersion()))) {
870 } else if (actionVersionInfo.getLatestFinalVersion() != null
871 && actionVersionInfo.getLatestFinalVersion().equals(Version.valueOf(action.getVersion()))
873 !actionVersionInfo.getLatestFinalVersion().equals(actionVersionInfo.getActiveVersion())) {
877 log.debug(" exit getMajorMinorVersionActions for actions ");
882 * CoreException object wrapper from Version library to Action Library Exception.
884 * @param exception CoreException object from version library
886 private void formAndThrowException(CoreException exception) {
887 log.debug("entering formAndThrowException with input CoreException =" + exception.code().id()
888 + " " + exception.getMessage());
889 String errorDescription = exception.getMessage();
890 String errorCode = exception.code().id();
891 ActionException actionException = new ActionException();
893 case VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST:
894 actionException.setErrorCode(ACTION_ENTITY_NOT_EXIST_CODE);
895 actionException.setDescription(ACTION_ENTITY_NOT_EXIST);
897 case VersioningErrorCodes.CHECKOT_ON_LOCKED_ENTITY:
898 actionException.setErrorCode(ACTION_CHECKOUT_ON_LOCKED_ENTITY);
899 actionException.setDescription(errorDescription);
901 case VersioningErrorCodes.CHECKIN_ON_UNLOCKED_ENTITY:
902 actionException.setErrorCode(ACTION_CHECKIN_ON_UNLOCKED_ENTITY);
903 actionException.setDescription(errorDescription);
905 case VersioningErrorCodes.SUBMIT_FINALIZED_ENTITY_NOT_ALLOWED:
906 actionException.setErrorCode(ACTION_SUBMIT_FINALIZED_ENTITY_NOT_ALLOWED);
907 actionException.setDescription(errorDescription);
909 case VersioningErrorCodes.SUBMIT_LOCKED_ENTITY_NOT_ALLOWED:
910 actionException.setErrorCode(ACTION_SUBMIT_LOCKED_ENTITY_NOT_ALLOWED);
911 actionException.setDescription(errorDescription);
913 case VersioningErrorCodes.UNDO_CHECKOUT_ON_UNLOCKED_ENTITY:
914 actionException.setErrorCode(ACTION_UNDO_CHECKOUT_ON_UNLOCKED_ENTITY);
915 actionException.setDescription(errorDescription);
917 case VersioningErrorCodes.EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER:
918 actionException.setErrorCode(ACTION_EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER);
919 actionException.setDescription(errorDescription.replace("edit", "updat"));
921 case VersioningErrorCodes.CHECKIN_ON_ENTITY_LOCKED_BY_OTHER_USER:
922 actionException.setErrorCode(ACTION_CHECKIN_ON_ENTITY_LOCKED_BY_OTHER_USER);
923 actionException.setDescription(errorDescription);
925 case VersioningErrorCodes.UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER:
926 actionException.setErrorCode(ACTION_UNDO_CHECKOUT_ON_ENTITY_LOCKED_BY_OTHER_USER);
927 actionException.setDescription(errorDescription);
929 case VersioningErrorCodes.EDIT_ON_UNLOCKED_ENTITY:
930 actionException.setErrorCode(ACTION_UPDATE_ON_UNLOCKED_ENTITY);
931 actionException.setDescription(errorDescription.replace("edit", "update"));
933 case VersioningErrorCodes.DELETE_ON_LOCKED_ENTITY:
934 actionException.setErrorCode(ACTION_DELETE_ON_LOCKED_ENTITY_CODE);
935 actionException.setDescription(errorDescription);
938 actionException.setErrorCode(ACTION_INTERNAL_SERVER_ERR_CODE);
939 actionException.setDescription(exception.getMessage());
942 //Todo - Uncomment only if class to be added in ERROR Log
943 /*actionErrorLogProcessor(CategoryLogLevel.ERROR, actionException.getErrorCode(),
944 actionException.getDescription());
947 "exit formAndThrowException with ActionException =" + actionException.getErrorCode()
948 + " " + actionException.getDescription());
949 throw actionException;
953 * Validates an action object for business layer validations before an update operation.
955 * @param action Action object to be validated
956 * @param activeVersion Active version of the actoin object
958 private void validateActions(Action action, Version activeVersion) {
960 //Set version if not already available in input request
961 //If version set in input compare it with version from DB
962 if (StringUtils.isEmpty(action.getVersion())) {
963 action.setVersion(activeVersion.toString());
965 if (!activeVersion.equals(Version.valueOf(action.getVersion()))) {
966 throw new ActionException(ACTION_UPDATE_INVALID_VERSION,
967 String.format(ACTION_REQUESTED_VERSION_INVALID, action.getVersion()));
970 String invariantUuId = action.getActionInvariantUuId();
971 Version version = Version.valueOf(action.getVersion());
972 Action existingAction = getActions(invariantUuId, version);
973 if (existingAction == null || existingAction.getActionInvariantUuId() == null) {
974 throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST);
976 List<String> invalidParameters = new LinkedList<>();
977 //Prevent update of name, version and id fields
978 if (!existingAction.getName().equals(action.getName())) {
979 throw new ActionException(ACTION_UPDATE_NOT_ALLOWED_CODE_NAME,
980 ACTION_UPDATE_NOT_ALLOWED_FOR_NAME);
982 if (!StringUtils.isEmpty(action.getActionUuId())
983 && !existingAction.getActionUuId().equals(action.getActionUuId())) {
984 invalidParameters.add(UNIQUE_ID);
986 if (action.getStatus() != null && (existingAction.getStatus() != action.getStatus())) {
987 invalidParameters.add(STATUS);
990 if (!invalidParameters.isEmpty()) {
991 throw new ActionException(ACTION_UPDATE_NOT_ALLOWED_CODE,
992 String.format(ACTION_UPDATE_PARAM_INVALID, StringUtils.join(invalidParameters, ", ")));
994 action.setActionUuId(existingAction.getActionUuId());
995 } catch (IllegalArgumentException iae) {
996 String message = iae.getMessage();
997 if (message == VERSION_STRING_VIOLATION_MSG) {
998 throw new ActionException(ACTION_UPDATE_NOT_ALLOWED_CODE, message);
1006 * Get an action version entity object.
1008 * @param invariantUuId Invariant UUID of the action
1009 * @param version Version of the action
1010 * @return {@link ActionEntity} object of the action version
1012 private ActionEntity getActionsEntityByVersion(String invariantUuId, Version version) {
1014 "entering getActionsEntityByVersion with invariantUUID= " + invariantUuId + " and version"
1016 ActionEntity entity = null;
1017 if (version != null) {
1018 actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_VERSION, TARGET_ENTITY_DB);
1019 entity = actionDao.get(
1020 new ActionEntity(invariantUuId != null ? invariantUuId.toUpperCase() : null, version));
1021 actionLogPostProcessor(StatusCode.COMPLETE);
1025 "exit getActionsEntityByVersion with invariantUuId= " + invariantUuId + " and version"
1031 * Get an action version object.
1033 * @param invariantUuId Invariant UUID of the action
1034 * @param version Version of the action
1035 * @return {@link Action} object of the action version
1037 private Action getActions(String invariantUuId, Version version) {
1038 ActionEntity actionEntity =
1039 getActionsEntityByVersion(invariantUuId != null ? invariantUuId.toUpperCase() : null,
1041 return actionEntity != null ? actionEntity.toDto() : new Action();
1045 * Create and set the Unique ID in for an action version row.
1047 * @param invariantUuId Invariant UUID of the action
1048 * @param version Version of the action
1049 * @param status Status of the action
1050 * @param user AT&T id of the user sending the request
1051 * @return {@link ActionEntity} object of the action version
1053 private ActionEntity updateUniqueIdForVersion(String invariantUuId, Version version,
1054 String status, String user) {
1056 "entering updateUniqueIdForVersion to update action with invariantUuId= " + invariantUuId
1057 + " with version,status and user as ::" + version + " " + status + " " + user);
1058 //generate UUID AND update for newly created entity row
1059 ActionEntity actionEntity = getActionsEntityByVersion(invariantUuId, version);
1060 if (actionEntity != null) {
1061 log.debug("Found action to be updated");
1062 String data = actionEntity.getData();
1063 String uniqueId = CommonMethods.nextUuId();
1064 Map<String, String> dataMap = JsonUtil.json2Object(data, LinkedHashMap.class);
1065 dataMap.put(ActionConstants.UNIQUE_ID, uniqueId);
1066 dataMap.put(ActionConstants.VERSION, version.toString());
1067 dataMap.put(ActionConstants.STATUS, status);
1068 data = JsonUtil.object2Json(dataMap);
1070 actionEntity.setData(data);
1071 actionEntity.setActionUuId(uniqueId);
1072 actionEntity.setStatus(status);
1073 actionEntity.setUser(user);
1074 actionEntity.setTimestamp(getCurrentTimeStampUtc());
1075 actionLogPreProcessor(ActionSubOperation.UPDATE_ACTION, TARGET_ENTITY_DB);
1076 actionDao.update(actionEntity);
1077 actionLogPostProcessor(StatusCode.COMPLETE);
1082 "exit updateUniqueIdForVersion to update action with invariantUUID= " + invariantUuId);
1083 return actionEntity;
1087 * Set the status for an action version row.
1089 * @param invariantUuId Invariant UUID of the action
1090 * @param version Version of the action
1091 * @param status Status of the action
1092 * @param user AT&T id of the user sending the request
1093 * @return {@link ActionEntity} object of the action version
1095 private ActionEntity updateStatusForVersion(String invariantUuId, Version version, String status,
1098 "entering updateStatusForVersion with invariantUuId= " + invariantUuId + " and version"
1099 + version + " for updating status " + status + " by user " + user);
1100 ActionEntity actionEntity = getActionsEntityByVersion(invariantUuId, version);
1101 if (actionEntity != null) {
1102 String data = actionEntity.getData();
1103 Map<String, String> dataMap = JsonUtil.json2Object(data, LinkedHashMap.class);
1104 dataMap.put(ActionConstants.STATUS, status);
1105 data = JsonUtil.object2Json(dataMap);
1106 actionEntity.setData(data);
1107 actionEntity.setStatus(status);
1108 actionEntity.setUser(user);
1109 actionEntity.setTimestamp(getCurrentTimeStampUtc());
1110 actionLogPreProcessor(ActionSubOperation.UPDATE_ACTION, TARGET_ENTITY_DB);
1111 actionDao.update(actionEntity);
1112 actionLogPostProcessor(StatusCode.COMPLETE);
1115 log.debug("exit updateStatusForVersion with invariantUuId= " + invariantUuId + " and version"
1116 + version + " for updating status " + status + " by user " + user);
1117 return actionEntity;
1122 * Gets an artifact from the action artifact metadata by artifact name.
1124 * @param actionArtifactList Action's existing artifact list
1125 * @param artifactFilterType Search criteria for artifact in action artifact metadata
1126 * @param artifactFilterValue Value of Search parameter
1127 * @return Artifact metadata object if artifact is present in action and null otherwise
1129 private ActionArtifact getArtifactMetadataFromAction(List<ActionArtifact> actionArtifactList,
1130 String artifactFilterType,
1131 String artifactFilterValue) {
1132 ActionArtifact artifact = null;
1133 if (actionArtifactList != null && !actionArtifactList.isEmpty()) {
1134 for (ActionArtifact entry : actionArtifactList) {
1135 switch (artifactFilterType) {
1136 case ARTIFACT_METADATA_ATTR_UUID:
1137 String artifactUuId = entry.getArtifactUuId();
1138 if (artifactUuId != null && artifactUuId.equals(artifactFilterValue)) {
1143 case ARTIFACT_METADATA_ATTR_NAME:
1144 String existingArtifactName = entry.getArtifactName().toLowerCase();
1145 if (existingArtifactName.equals(artifactFilterValue.toLowerCase())) {
1158 * Method to update the artifact metadata in the data attribute of action table.
1160 * @param action Action to which artifact is uploaded
1161 * @param updatedArtifact updated artifact object
1163 private void updateArtifactMetadataInActionData(Action action, ActionArtifact updatedArtifact) {
1164 for (ActionArtifact entry : action.getArtifacts()) {
1165 if (entry.getArtifactUuId().equals(updatedArtifact.getArtifactUuId())) {
1166 entry.setArtifactLabel(updatedArtifact.getArtifactLabel());
1167 entry.setArtifactCategory(updatedArtifact.getArtifactCategory());
1168 entry.setArtifactDescription(updatedArtifact.getArtifactDescription());
1169 entry.setArtifactProtection(updatedArtifact.getArtifactProtection());
1170 entry.setTimestamp(updatedArtifact.getTimestamp());
1174 String data = action.getData();
1175 Map<String, Object> map = JsonUtil.json2Object(data, LinkedHashMap.class);
1176 map.put(ActionConstants.ARTIFACTS, action.getArtifacts());
1177 String updatedActionData = JsonUtil.object2Json(map);
1178 action.setData(updatedActionData);
1179 action.setTimestamp(updatedArtifact.getTimestamp());
1180 actionDao.updateAction(action);