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.sdc.be.servlets;
23 import io.swagger.annotations.ApiOperation;
24 import io.swagger.annotations.ApiParam;
25 import io.swagger.annotations.ApiResponse;
26 import io.swagger.annotations.ApiResponses;
27 import javax.servlet.http.HttpServletRequest;
29 import javax.ws.rs.core.Context;
30 import javax.ws.rs.core.MediaType;
31 import javax.ws.rs.core.Response;
32 import org.openecomp.sdc.be.dao.api.ActionStatus;
33 import org.openecomp.sdc.common.api.Constants;
34 import org.openecomp.sdc.exception.ResponseFormat;
35 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory;
38 import com.jcabi.aspects.Loggable;
40 import javax.servlet.http.HttpServletRequest;
42 import javax.ws.rs.core.Context;
43 import javax.ws.rs.core.MediaType;
44 import javax.ws.rs.core.Response;
46 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
47 public class RequirementsServlet extends BeGenericServlet {
49 private static final Logger log = LoggerFactory.getLogger(RequirementsServlet.class);
52 @Path("resources/{resourceId}/requirements/{requirementId}")
53 @Consumes(MediaType.APPLICATION_JSON)
54 @Produces(MediaType.APPLICATION_JSON)
55 @ApiOperation(value = "Update Resource Requirement", httpMethod = "PUT", notes = "Returns updated requirement", response = Response.class)
56 @ApiResponses(value = { @ApiResponse(code = 200, message = "Resource requirement updated"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 400, message = "Invalid content / Missing content") })
57 public Response updateRequirement(@ApiParam(value = "resource id to update with new requirement", required = true) @PathParam("resourceId") final String resourceId,
58 @ApiParam(value = "requirement id to update", required = true) @PathParam("requirementId") final String requirementId, @ApiParam(value = "Resource property to update", required = true) String requirementData,
59 @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
61 // Convert RequirementDefinition from JSON
62 // TODO: it's going to be another object, probably. This is placeholder
63 // for sake of JSON validation
64 // RequirementDefinition requirementDefinition;
65 ResponseFormat responseFormat;
67 // TODO pass real entity
68 return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), null);
69 } catch (Exception e) {
70 log.debug("Unexpected error: ", e);
71 responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
72 return buildErrorResponse(responseFormat);