2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdcrests.vsp.rest.services;
23 import org.apache.cxf.jaxrs.ext.multipart.Attachment;
24 import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
25 import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MibUploadStatus;
26 import org.openecomp.sdcrests.vendorsoftwareproducts.types.MibUploadStatusDto;
27 import org.openecomp.sdcrests.vsp.rest.ComponentUploads;
28 import org.openecomp.sdcrests.vsp.rest.mapping.MapMibUploadStatusToDto;
30 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.context.annotation.Scope;
32 import org.springframework.stereotype.Service;
33 import org.springframework.validation.annotation.Validated;
35 import java.io.InputStream;
36 import javax.inject.Named;
37 import javax.ws.rs.core.Response;
40 @Service("componentUploads")
41 @Scope(value = "prototype")
43 public class ComponentUploadsImpl implements ComponentUploads {
45 private VendorSoftwareProductManager vendorSoftwareProductManager;
48 public Response uploadTrapMibFile(Attachment attachment, String vspId, String componentId,
50 vendorSoftwareProductManager.uploadComponentMib(attachment.getObject(InputStream.class),
51 attachment.getContentDisposition().getParameter("filename"), vspId, componentId, true,
53 return Response.ok().build();
57 public Response deleteTrapMibFile(String vspId, String componentId, String user) {
58 vendorSoftwareProductManager.deleteComponentMib(vspId, componentId, true, user);
59 return Response.ok().build();
63 public Response uploadPollMibFile(Attachment attachment, String vspId, String componentId,
65 vendorSoftwareProductManager.uploadComponentMib(attachment.getObject(InputStream.class),
66 attachment.getContentDisposition().getParameter("filename"), vspId, componentId, false,
68 return Response.ok().build();
72 public Response deletePollMibFile(String vspId, String componentId, String user) {
73 vendorSoftwareProductManager.deleteComponentMib(vspId, componentId, false, user);
74 return Response.ok().build();
78 public Response list(String vspId, String componentId, String user) {
79 MibUploadStatus response =
80 vendorSoftwareProductManager.listMibFilenames(vspId, componentId, user);
82 MibUploadStatusDto returnEntity =
83 new MapMibUploadStatusToDto().applyMapping(response, MibUploadStatusDto.class);
84 return Response.status(Response.Status.OK).entity(returnEntity).build();