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 com.att.authz.service.api;
\r
25 import static com.att.cssa.rserv.HttpMethods.GET;
\r
26 import static com.att.cssa.rserv.HttpMethods.PUT;
\r
28 import javax.servlet.http.HttpServletRequest;
\r
29 import javax.servlet.http.HttpServletResponse;
\r
31 import com.att.aft.dme2.internal.jetty.http.HttpStatus;
\r
32 import com.att.authz.env.AuthzTrans;
\r
33 import com.att.authz.facade.AuthzFacade;
\r
34 import com.att.authz.layer.Result;
\r
35 import com.att.authz.service.AuthAPI;
\r
36 import com.att.authz.service.Code;
\r
37 import com.att.authz.service.mapper.Mapper.API;
\r
39 public class API_Approval {
\r
40 // Hide Public Constructor
\r
41 private API_Approval() {}
\r
43 public static void init(AuthAPI authzAPI, AuthzFacade facade) throws Exception {
\r
46 * Get Approvals by User
\r
48 authzAPI.route(GET, "/authz/approval/user/:user",API.APPROVALS,
\r
49 new Code(facade,"Get Approvals by User", true) {
\r
51 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
\r
52 Result<Void> r = context.getApprovalsByUser(trans, resp, pathParam(req,"user"));
\r
54 resp.setStatus(HttpStatus.OK_200);
\r
56 context.error(trans,resp,r);
\r
62 * Get Approvals by Ticket
\r
64 authzAPI.route(GET, "/authz/approval/ticket/:ticket",API.VOID,new Code(facade,"Get Approvals by Ticket ", true) {
\r
66 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
\r
67 Result<Void> r = context.getApprovalsByTicket(trans, resp, pathParam(req,"ticket"));
\r
69 resp.setStatus(HttpStatus.OK_200);
\r
71 context.error(trans,resp,r);
\r
77 * Get Approvals by Approver
\r
79 authzAPI.route(GET, "/authz/approval/approver/:approver",API.APPROVALS,new Code(facade,"Get Approvals by Approver", true) {
\r
81 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
\r
82 Result<Void> r = context.getApprovalsByApprover(trans, resp, pathParam(req,"approver"));
\r
84 resp.setStatus(HttpStatus.OK_200);
\r
86 context.error(trans,resp,r);
\r
93 * Update an approval
\r
95 authzAPI.route(PUT, "/authz/approval",API.APPROVALS,new Code(facade,"Update approvals", true) {
\r
97 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
\r
98 Result<Void> r = context.updateApproval(trans, req, resp);
\r
100 resp.setStatus(HttpStatus.OK_200);
\r
102 context.error(trans,resp,r);
\r