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.gw.mapper;
\r
25 import org.onap.aaf.cadi.util.Vars;
\r
27 import gw.v1_0.Error;
\r
28 import gw.v1_0.InRequest;
\r
31 public class Mapper_1_0 implements Mapper<InRequest,Out,Error> {
\r
34 public Class<?> getClass(API api) {
\r
36 case IN_REQ: return InRequest.class;
\r
37 case OUT: return Out.class;
\r
38 case ERROR: return Error.class;
\r
39 case VOID: return Void.class;
\r
44 @SuppressWarnings("unchecked")
\r
46 public <A> A newInstance(API api) {
\r
48 case IN_REQ: return (A) new InRequest();
\r
49 case OUT: return (A) new Out();
\r
50 case ERROR: return (A)new Error();
\r
51 case VOID: return null;
\r
56 ////////////// Mapping Functions /////////////
\r
58 public gw.v1_0.Error errorFromMessage(StringBuilder holder, String msgID, String text,String... var) {
\r
59 Error err = new Error();
\r
60 err.setMessageId(msgID);
\r
61 // AT&T Restful Error Format requires numbers "%" placements
\r
62 err.setText(Vars.convert(holder, text, var));
\r
63 for(String s : var) {
\r
64 err.getVariables().add(s);
\r