2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
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 * ================================================================================
20 package org.openecomp.portalsdk.core.onboarding.crossapi;
22 import java.util.List;
24 import javax.servlet.http.HttpServletRequest;
26 import org.openecomp.portalsdk.core.onboarding.exception.PortalAPIException;
27 import org.openecomp.portalsdk.core.restful.domain.EcompRole;
28 import org.openecomp.portalsdk.core.restful.domain.EcompUser;
31 * Defines the REST API Interface that an on-boarding application must implement
32 * to answer queries and accept updates from the ECOMP Portal about the
33 * application's users, roles and user-role assignments.
35 public interface IPortalRestAPIService {
37 // EcompUser Interface
40 * Creates a user with the specified details. If any error occurs, for
41 * example the user exists, the method should throw PortalApiException with
42 * an appropriate message. The FW library will catch the exception and send
43 * an appropriate response to Portal.
46 * Model object with attributes of user to be created.
47 * @throws PortalAPIException
48 * If any error occurs while processing the request; for
49 * example, user exists.
51 public void pushUser(EcompUser user) throws PortalAPIException;
54 * Updates details about the user with the specified loginId. For example,
55 * mark user as inactive. If any error occurs, the method should throw
56 * PortalApiException with an appropriate message. The FW library will catch
57 * the exception and send an appropriate response to Portal.
60 * EcompUser ID to be updated.
62 * Model object with attributes of user to be updated.
63 * @throws PortalAPIException
64 * If any error occurs while processing the request; for
65 * example, unknown user.
67 public void editUser(String loginId, EcompUser user) throws PortalAPIException;
70 * Gets and returns the user object with the specified loginId. If any error
71 * occurs, the method should throw PortalApiException with an appropriate
72 * message. The FW library will catch the exception and send an appropriate
76 * EcompUser ID to be fetched
77 * @return Model object with user attributes.
78 * @throws PortalAPIException
79 * If any error occurs while processing the request; for
80 * example, unknown user.
82 public EcompUser getUser(String loginId) throws PortalAPIException;
85 * Gets and returns a list of active users. If any error occurs, the method
86 * should throw PortalApiException with an appropriate message. The FW
87 * library will catch the exception and send an appropriate response to
90 * @return List of user attribute model objects; empty list if none are
92 * @throws PortalAPIException
93 * If any error occurs while processing the request.
95 public List<EcompUser> getUsers() throws PortalAPIException;
100 * Gets and returns a list of active roles. If any error occurs, the method
101 * should throw PortalApiException with an appropriate message. The FW
102 * library will catch the exception and send an appropriate response to
105 * @param requestedLoginId
106 * requested userloginId to fetch available roles
107 * @return List of role attribute objects; empty list if none are found.
108 * @throws PortalAPIException
109 * If an unexpected error occurs while processing the request.
111 public List<EcompRole> getAvailableRoles(String requestedLoginId) throws PortalAPIException;
114 * Updates roles for the user with the specified loginId to the list of
115 * roles provided as the second argument. After this operation, the should
116 * have ONLY the roles provided in the list above. For example, if user had
117 * roles r1, r2 and r3; and a call was made to pushUserRole with a list
118 * containing only roles r3 and r4, this method should leave the user with
119 * roles r3 and r4 since those were the ONLY roles provided in second
120 * argument. If any error occurs, the method should throw PortalApiException
121 * with an appropriate message. The FW library will catch the exception and
122 * send an appropriate response to Portal.
125 * EcompUser ID to be updated.
127 * List of role attribute objects
128 * @throws PortalAPIException
129 * If any error occurs while processing the request.
131 public void pushUserRole(String loginId, List<EcompRole> roles) throws PortalAPIException;
134 * Gets and returns a list of roles for the user with the specified loginId.
135 * If any error occurs, the method should throw PortalApiException with an
136 * appropriate message. The FW library will catch the exception and send an
137 * appropriate response to Portal.
140 * @return List of model objects; empty if no roles are found.
141 * @throws PortalAPIException
142 * If any error occurs while processing the request; e.g., user
145 public List<EcompRole> getUserRoles(String loginId) throws PortalAPIException;
147 // Security Interface
150 * Should return true if the call should be allowed and false if not.
151 * Currently Portal sends two headers of username and password in each
152 * request which the app should check. If match, return true; else return
153 * false. If any error occurs, the method should throw PortalApiException
154 * with an appropriate message. The FW library will catch the exception and
155 * send an appropriate response to Portal.
158 * @return true if the request contains appropriate credentials, else false.
159 * @throws PortalAPIException
160 * If an unexpected error occurs while processing the request.
162 public boolean isAppAuthenticated(HttpServletRequest request) throws PortalAPIException;
165 * Gets and returns the userId for the logged-in user based on the request.
166 * If any error occurs, the method should throw PortalApiException with an
167 * appropriate message. The FW library will catch the exception and send an
168 * appropriate response to Portal.
171 * @return true if the request contains appropriate credentials, else false.
172 * @throws PortalAPIException
173 * If an unexpected error occurs while processing the request.
175 public String getUserId(HttpServletRequest request) throws PortalAPIException;