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 * @return List of role attribute objects; empty list if none are found.
106 * @throws PortalAPIException
107 * If an unexpected error occurs while processing the request.
109 public List<EcompRole> getAvailableRoles() throws PortalAPIException;
112 * Updates roles for the user with the specified loginId to the list of
113 * roles provided as the second argument. After this operation, the should
114 * have ONLY the roles provided in the list above. For example, if user had
115 * roles r1, r2 and r3; and a call was made to pushUserRole with a list
116 * containing only roles r3 and r4, this method should leave the user with
117 * roles r3 and r4 since those were the ONLY roles provided in second
118 * argument. If any error occurs, the method should throw PortalApiException
119 * with an appropriate message. The FW library will catch the exception and
120 * send an appropriate response to Portal.
123 * EcompUser ID to be updated.
125 * List of role attribute objects
126 * @throws PortalAPIException
127 * If any error occurs while processing the request.
129 public void pushUserRole(String loginId, List<EcompRole> roles) throws PortalAPIException;
132 * Gets and returns a list of roles for the user with the specified loginId.
133 * If any error occurs, the method should throw PortalApiException with an
134 * appropriate message. The FW library will catch the exception and send an
135 * appropriate response to Portal.
138 * @return List of model objects; empty if no roles are found.
139 * @throws PortalAPIException
140 * If any error occurs while processing the request; e.g., user
143 public List<EcompRole> getUserRoles(String loginId) throws PortalAPIException;
145 // Security Interface
148 * Should return true if the call should be allowed and false if not.
149 * Currently Portal sends two headers of username and password in each
150 * request which the app should check. If match, return true; else return
151 * false. If any error occurs, the method should throw PortalApiException
152 * with an appropriate message. The FW library will catch the exception and
153 * send an appropriate response to Portal.
156 * @return true if the request contains appropriate credentials, else false.
157 * @throws PortalAPIException
158 * If an unexpected error occurs while processing the request.
160 public boolean isAppAuthenticated(HttpServletRequest request) throws PortalAPIException;
163 * Gets and returns the userId for the logged-in user based on the request.
164 * If any error occurs, the method should throw PortalApiException with an
165 * appropriate message. The FW library will catch the exception and send an
166 * appropriate response to Portal.
169 * @return true if the request contains appropriate credentials, else false.
170 * @throws PortalAPIException
171 * If an unexpected error occurs while processing the request.
173 public String getUserId(HttpServletRequest request) throws PortalAPIException;