1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * ===========================================================================
\r
7 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * * you may not use this file except in compliance with the License.
\r
9 * * You may obtain a copy of the License at
\r
11 * * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * * Unless required by applicable law or agreed to in writing, software
\r
14 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * * See the License for the specific language governing permissions and
\r
17 * * limitations under the License.
\r
18 * * ============LICENSE_END====================================================
\r
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 ******************************************************************************/
\r
23 package org.onap.aaf.authz.cm.api;
\r
25 import javax.servlet.http.HttpServletRequest;
\r
26 import javax.servlet.http.HttpServletResponse;
\r
28 import org.onap.aaf.authz.cm.mapper.Mapper.API;
\r
29 import org.onap.aaf.authz.cm.service.CertManAPI;
\r
30 import org.onap.aaf.authz.cm.service.Code;
\r
31 import org.onap.aaf.authz.env.AuthzTrans;
\r
32 import org.onap.aaf.authz.layer.Result;
\r
33 import org.onap.aaf.cssa.rserv.HttpMethods;
\r
35 import com.att.aft.dme2.internal.jetty.http.HttpStatus;
\r
38 * API Deployment Artifact Apis.. using Redirect for mechanism
\r
42 public class API_Artifact {
\r
43 private static final String GET_ARTIFACTS = "Get Artifacts";
\r
46 * Normal Init level APIs
\r
52 public static void init(final CertManAPI cmAPI) throws Exception {
\r
53 cmAPI.route(HttpMethods.POST, "/cert/artifacts", API.ARTIFACTS, new Code(cmAPI,"Create Artifacts") {
\r
55 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
\r
56 Result<Void> r = context.createArtifacts(trans, req, resp);
\r
58 resp.setStatus(HttpStatus.CREATED_201);
\r
60 context.error(trans,resp,r);
\r
65 cmAPI.route(HttpMethods.GET, "/cert/artifacts/:mechid/:machine", API.ARTIFACTS, new Code(cmAPI,GET_ARTIFACTS) {
\r
67 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
\r
69 Result<Void> r = context.readArtifacts(trans, resp, pathParam(req,":mechid"), pathParam(req,":machine"));
\r
71 resp.setStatus(HttpStatus.CREATED_201);
\r
73 context.error(trans,resp,r);
\r
78 cmAPI.route(HttpMethods.GET, "/cert/artifacts", API.ARTIFACTS, new Code(cmAPI,GET_ARTIFACTS) {
\r
80 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
\r
81 Result<Void> r = context.readArtifacts(trans, req, resp);
\r
83 resp.setStatus(HttpStatus.CREATED_201);
\r
85 context.error(trans,resp,r);
\r
90 cmAPI.route(HttpMethods.PUT, "/cert/artifacts", API.ARTIFACTS, new Code(cmAPI,"Update Artifacts") {
\r
92 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
\r
93 Result<Void> r = context.updateArtifacts(trans, req, resp);
\r
95 resp.setStatus(HttpStatus.OK_200);
\r
97 context.error(trans,resp,r);
\r
102 cmAPI.route(HttpMethods.DELETE, "/cert/artifacts/:mechid/:machine", API.VOID, new Code(cmAPI,"Delete Artifacts") {
\r
104 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
\r
105 Result<Void> r = context.deleteArtifacts(trans, resp,
\r
106 pathParam(req, ":mechid"), pathParam(req,":machine"));
\r
108 resp.setStatus(HttpStatus.OK_200);
\r
110 context.error(trans,resp,r);
\r
116 cmAPI.route(HttpMethods.DELETE, "/cert/artifacts", API.VOID, new Code(cmAPI,"Delete Artifacts") {
\r
118 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
\r
119 Result<Void> r = context.deleteArtifacts(trans, req, resp);
\r
121 resp.setStatus(HttpStatus.OK_200);
\r
123 context.error(trans,resp,r);
\r