aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/api
diff options
context:
space:
mode:
authorTomasz Golabek <tomasz.golabek@nokia.com>2019-06-11 13:41:48 +0200
committerOren Kleks <orenkle@amdocs.com>2019-06-16 08:40:58 +0000
commitb836d3492984e8c751f00b200d24eb07da792c75 (patch)
tree5633e0863101d032dd5398530abdcf85c29dcc88 /openecomp-be/api
parentd6bd31bf81c1eb8e4f3a6b349d021f5533f03b03 (diff)
BeanUtils upgrade to 1.9.x
Transitive dependency to beanutils 1.8.3 removed. Refactor of existing usage of beanutils proposed. Change-Id: I6614a5794979225376338c778b25f71911ae9c50 Issue-ID: SDC-2269 Signed-off-by: Tomasz Golabek <tomasz.golabek@nokia.com>
Diffstat (limited to 'openecomp-be/api')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java51
1 files changed, 28 insertions, 23 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
index 4978b3fb34..5cf6f40c37 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
@@ -12,14 +12,15 @@
* 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=========================================================
+ * Modifications copyright (c) 2019 Nokia
+ * ================================================================================
*/
package org.openecomp.sdcrests.vsp.rest.services;
-import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
-import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.sdc.activitylog.ActivityLogManager;
import org.openecomp.sdc.activitylog.ActivityLogManagerFactory;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
@@ -56,7 +57,6 @@ import javax.inject.Named;
import javax.ws.rs.core.Response;
import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -125,7 +125,7 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate
@Override
public Response get(String vspId, String versionId, String user) throws IOException {
Optional<Pair<String, byte[]>> zipFile = candidateManager.get(vspId, new Version(versionId));
- String fileName = null;
+ String fileName;
if (zipFile.isPresent()) {
fileName = "Candidate." + zipFile.get().getLeft();
} else {
@@ -147,14 +147,13 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate
}
@Override
- public Response abort(String vspId, String versionId) throws Exception {
+ public Response abort(String vspId, String versionId) {
candidateManager.abort(vspId, new Version(versionId));
return Response.ok().build();
}
@Override
- public Response process(String vspId, String versionId, String user)
- throws InvocationTargetException, IllegalAccessException {
+ public Response process(String vspId, String versionId, String user) {
Version version = new Version(versionId);
OrchestrationTemplateActionResponse response = candidateManager.process(vspId, version);
@@ -162,27 +161,17 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate
activityLogManager.logActivity(new ActivityLogEntity(vspId, version,
ActivityType.Upload_Network_Package, user, true, "", ""));
- OrchestrationTemplateActionResponseDto responseDto =
- new OrchestrationTemplateActionResponseDto();
- BeanUtils.copyProperties(responseDto, response);
+ OrchestrationTemplateActionResponseDto responseDto = copyOrchestrationTemplateActionResponseToDto(response);
return Response.ok(responseDto).build();
}
@Override
public Response updateFilesDataStructure(
- String vspId, String versionId, FileDataStructureDto fileDataStructureDto, String user)
- throws Exception {
+ String vspId, String versionId, FileDataStructureDto fileDataStructureDto, String user) {
+
+ FilesDataStructure fileDataStructure = copyFilesDataStructureDtoToFilesDataStructure(fileDataStructureDto);
- FilesDataStructure fileDataStructure = new FilesDataStructure();
- try {
- BeanUtils.copyProperties(fileDataStructure, fileDataStructureDto);
- } catch (IllegalAccessException | InvocationTargetException exception) {
- String errorWithParameters = ErrorMessagesFormatBuilder
- .getErrorWithParameters(Messages.MAPPING_OBJECTS_FAILURE.getErrorMessage(),
- fileDataStructureDto.toString(), fileDataStructure.toString());
- throw new OrchestrationTemplateCandidateException(errorWithParameters, exception);
- }
ValidationResponse response = candidateManager
.updateFilesDataStructure(vspId, new Version(versionId), fileDataStructure);
@@ -195,8 +184,7 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate
}
@Override
- public Response getFilesDataStructure(String vspId, String versionId, String user)
- throws Exception {
+ public Response getFilesDataStructure(String vspId, String versionId, String user) {
Optional<FilesDataStructure> filesDataStructure =
candidateManager.getFilesDataStructure(vspId, new Version(versionId));
if (!filesDataStructure.isPresent()) {
@@ -211,4 +199,21 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate
return Response.ok(fileDataStructureDto).build();
}
+ private OrchestrationTemplateActionResponseDto copyOrchestrationTemplateActionResponseToDto(OrchestrationTemplateActionResponse response){
+ OrchestrationTemplateActionResponseDto result = new OrchestrationTemplateActionResponseDto();
+ result.setErrors(response.getErrors());
+ result.setFileNames(response.getFileNames());
+ result.setStatus(response.getStatus());
+ return result;
+ }
+
+ private FilesDataStructure copyFilesDataStructureDtoToFilesDataStructure(FileDataStructureDto fileDataStructureDto){
+ FilesDataStructure filesDataStructure = new FilesDataStructure();
+ filesDataStructure.setArtifacts(fileDataStructureDto.getArtifacts());
+ filesDataStructure.setModules(fileDataStructureDto.getModules());
+ filesDataStructure.setNested(fileDataStructureDto.getNested());
+ filesDataStructure.setUnassigned(fileDataStructureDto.getUnassigned());
+ return filesDataStructure;
+ }
+
}