1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * Copyright © 2017 Amdocs
\r
7 * * ===========================================================================
\r
8 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * * you may not use this file except in compliance with the License.
\r
10 * * You may obtain a copy of the License at
\r
12 * * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * * Unless required by applicable law or agreed to in writing, software
\r
15 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * * See the License for the specific language governing permissions and
\r
18 * * limitations under the License.
\r
19 * * ============LICENSE_END====================================================
\r
21 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
23 ******************************************************************************/
\r
24 package com.att.authz.service.api;
\r
26 import static com.att.cssa.rserv.HttpMethods.GET;
\r
27 import static com.att.cssa.rserv.HttpMethods.PUT;
\r
29 import javax.servlet.http.HttpServletRequest;
\r
30 import javax.servlet.http.HttpServletResponse;
\r
32 import com.att.aft.dme2.internal.jetty.http.HttpStatus;
\r
33 import com.att.authz.env.AuthzTrans;
\r
34 import com.att.authz.facade.AuthzFacade;
\r
35 import com.att.authz.layer.Result;
\r
36 import com.att.authz.service.AuthAPI;
\r
37 import com.att.authz.service.Code;
\r
38 import com.att.authz.service.mapper.Mapper.API;
\r
40 public class API_Approval {
\r
41 // Hide Public Constructor
\r
42 private API_Approval() {}
\r
44 public static void init(AuthAPI authzAPI, AuthzFacade facade) throws Exception {
\r
47 * Get Approvals by User
\r
49 authzAPI.route(GET, "/authz/approval/user/:user",API.APPROVALS,
\r
50 new Code(facade,"Get Approvals by User", true) {
\r
52 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
\r
53 Result<Void> r = context.getApprovalsByUser(trans, resp, pathParam(req,"user"));
\r
55 resp.setStatus(HttpStatus.OK_200);
\r
57 context.error(trans,resp,r);
\r
63 * Get Approvals by Ticket
\r
65 authzAPI.route(GET, "/authz/approval/ticket/:ticket",API.VOID,new Code(facade,"Get Approvals by Ticket ", true) {
\r
67 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
\r
68 Result<Void> r = context.getApprovalsByTicket(trans, resp, pathParam(req,"ticket"));
\r
70 resp.setStatus(HttpStatus.OK_200);
\r
72 context.error(trans,resp,r);
\r
78 * Get Approvals by Approver
\r
80 authzAPI.route(GET, "/authz/approval/approver/:approver",API.APPROVALS,new Code(facade,"Get Approvals by Approver", true) {
\r
82 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
\r
83 Result<Void> r = context.getApprovalsByApprover(trans, resp, pathParam(req,"approver"));
\r
85 resp.setStatus(HttpStatus.OK_200);
\r
87 context.error(trans,resp,r);
\r
94 * Update an approval
\r
96 authzAPI.route(PUT, "/authz/approval",API.APPROVALS,new Code(facade,"Update approvals", true) {
\r
98 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
\r
99 Result<Void> r = context.updateApproval(trans, req, resp);
\r
101 resp.setStatus(HttpStatus.OK_200);
\r
103 context.error(trans,resp,r);
\r