2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 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====================================================
22 package org.onap.aaf.auth.service.api;
24 import static org.onap.aaf.auth.rserv.HttpMethods.GET;
25 import static org.onap.aaf.auth.rserv.HttpMethods.PUT;
27 import javax.servlet.http.HttpServletRequest;
28 import javax.servlet.http.HttpServletResponse;
30 import org.eclipse.jetty.http.HttpStatus;
31 import org.onap.aaf.auth.env.AuthzTrans;
32 import org.onap.aaf.auth.layer.Result;
33 import org.onap.aaf.auth.service.AAF_Service;
34 import org.onap.aaf.auth.service.Code;
35 import org.onap.aaf.auth.service.facade.AuthzFacade;
36 import org.onap.aaf.auth.service.mapper.Mapper.API;
38 public class API_Approval {
39 // Hide Public Constructor
40 private API_Approval() {}
42 public static void init(AAF_Service authzAPI, AuthzFacade facade) throws Exception {
45 * Get Approvals by User
47 authzAPI.route(GET, "/authz/approval/user/:user",API.APPROVALS,
48 new Code(facade,"Get Approvals by User", true) {
50 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
51 Result<Void> r = context.getApprovalsByUser(trans, resp, pathParam(req,"user"));
53 resp.setStatus(HttpStatus.OK_200);
55 context.error(trans,resp,r);
61 * Get Approvals by Ticket
63 authzAPI.route(GET, "/authz/approval/ticket/:ticket",API.APPROVALS,new Code(facade,"Get Approvals by Ticket ", true) {
65 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
66 Result<Void> r = context.getApprovalsByTicket(trans, resp, pathParam(req,"ticket"));
68 resp.setStatus(HttpStatus.OK_200);
70 context.error(trans,resp,r);
76 * Get Approvals by Approver
78 authzAPI.route(GET, "/authz/approval/approver/:approver",API.APPROVALS,new Code(facade,"Get Approvals by Approver", true) {
80 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
81 Result<Void> r = context.getApprovalsByApprover(trans, resp, pathParam(req,"approver"));
83 resp.setStatus(HttpStatus.OK_200);
85 context.error(trans,resp,r);
94 authzAPI.route(PUT, "/authz/approval",API.APPROVALS,new Code(facade,"Update approvals", true) {
96 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
97 Result<Void> r = context.updateApproval(trans, req, resp);
99 resp.setStatus(HttpStatus.OK_200);
101 context.error(trans,resp,r);