45bc9d0f05dcbea58efe1b2ca6cf33f7c4807c67
[aaf/authz.git] / auth / auth-service / src / main / java / org / onap / aaf / auth / service / api / API_Multi.java
1 /**
2  * ============LICENSE_START====================================================
3  * org.onap.aaf
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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====================================================
19  *
20  */
21
22 package org.onap.aaf.auth.service.api;
23
24 import static org.onap.aaf.auth.layer.Result.OK;
25 import static org.onap.aaf.auth.rserv.HttpMethods.POST;
26
27 import javax.servlet.http.HttpServletRequest;
28 import javax.servlet.http.HttpServletResponse;
29
30 import org.eclipse.jetty.http.HttpStatus;
31 import org.onap.aaf.auth.dao.cass.Status;
32 import org.onap.aaf.auth.env.AuthzTrans;
33 import org.onap.aaf.auth.layer.Result;
34 import org.onap.aaf.auth.service.AAF_Service;
35 import org.onap.aaf.auth.service.Code;
36 import org.onap.aaf.auth.service.facade.AuthzFacade;
37 import org.onap.aaf.auth.service.mapper.Mapper.API;
38
39 public class API_Multi {
40
41     public static void init(AAF_Service authzAPI, AuthzFacade facade) throws Exception {
42     
43         authzAPI.route(POST,"/authz/multi",API.VOID, new Code(facade,"Multiple Request API",true) {
44             @Override
45             public void handle(
46                 AuthzTrans trans,
47                 HttpServletRequest req, 
48                 HttpServletResponse resp) throws Exception {
49                 Result<Void> r = context.addResponsibilityForNS(trans, resp, pathParam(req,":ns"), pathParam(req,":id"));
50                     switch(r.status) {
51                         case OK:
52                             resp.setStatus(HttpStatus.CREATED_201); 
53                             break;
54                         case Status.ACC_Future:
55                             resp.setStatus(HttpStatus.ACCEPTED_202); 
56                             break;
57                         default:
58                             context.error(trans,resp,r);
59                     }
60                 }
61             }
62         );
63     }
64
65 }