2 * ===============LICENSE_START=======================================================
4 * ===================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
6 * ===================================================================================
7 * This Acumos software file is distributed by AT&T and Tech Mahindra
8 * under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * This file 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=========================================================
24 package org.acumos.federation.gateway.service;
28 import java.util.List;
30 import org.springframework.core.io.InputStreamResource;
32 import org.acumos.cds.domain.MLPArtifact;
33 import org.acumos.cds.domain.MLPSolution;
34 import org.acumos.cds.domain.MLPSolutionRevision;
35 import org.acumos.cds.transport.RestPageResponse;
38 * Handles access to the solutions catalog. The APIs of tis interface take a
39 * ServiceContext argument which determines the identity of the peer on bahalf
40 * of whom the call is executed. This information allows us to tailor the
41 * response according to a peer's granted access. It is the responsability of
42 * each implementation to ensure that the peer on whose behalf the service is
43 * executed only accesses solutions it was granted access to.
45 public interface CatalogService {
48 * API to be invoked by Peer Acumos to fetch the Catalog Solutions List.
51 * contains the selection criteria. Must match the available criteria
54 * the execution context.
56 * @return List of the Catalog Solutions for the selection criteria. An empty list is returned when no
57 * solutions satisfy the criteria.
58 * @throws ServiceException if an error is encoutered during processing
60 public List<MLPSolution> getSolutions(Map<String, ?> theSelector, ServiceContext theContext) throws ServiceException;
63 * Default interface for calls in behalf of the local Acumos service.
66 * contains the selection criteria. Must match the available criteria
68 * @return List of the Catalog Solutions for the selection criteria. An empty list is returned when no
69 * solutions satisfy the criteria.
70 * @throws ServiceException if an error is encoutered during processing
72 public default List<MLPSolution> getSolutions(Map<String, ?> theSelector) throws ServiceException {
73 return getSolutions(theSelector, selfService());
77 * Retrieve a solution's details from CDS.
79 * @param theSolutionId
80 * solution identifier (UUID).
82 * the execution context
83 * @return solution information. Will return null if the given solution id does not match an existing solution;
84 * @throws ServiceException if an error is encoutered during processing
86 public MLPSolution getSolution(String theSolutionId, ServiceContext theContext) throws ServiceException ;
89 * Default solution access interface for calls in behalf of the local Acumos
92 * @param theSolutionId
93 * solution identifier (UUID).
94 * @return solution information
95 * @throws ServiceException if an error is encoutered during processing
97 public default MLPSolution getSolution(String theSolutionId) throws ServiceException {
98 return getSolution(theSolutionId, selfService());
102 * Provides revision information given a solution identifier.
104 * @param theSolutionId
105 * identifier of the solution whose revisions are to be provided
107 * the execution context
108 * @return list of the solution revision for the specified solution Id. Will return an empty list if the
109 * given solution does not have revisions. Null is return if no solution with the given id exists.
110 * @throws ServiceException if an error is encoutered during processing
112 public List<MLPSolutionRevision> getSolutionRevisions(String theSolutionId, ServiceContext theContext) throws ServiceException ;
114 public default List<MLPSolutionRevision> getSolutionRevisions(String theSolutionId) throws ServiceException {
115 return getSolutionRevisions(theSolutionId, selfService());
119 * Access to a solution revision information.
121 * @param theSolutionId
122 * solution identifier (UUID).
123 * @param theRevisionId
124 * revision identifier (UUID).
126 * the execution context
127 * @return solution revision information
128 * @throws ServiceException if an error is encoutered during processing
130 public MLPSolutionRevision getSolutionRevision(String theSolutionId, String theRevisionId,
131 ServiceContext theContext) throws ServiceException ;
134 * Default solution revision access interface for calls in behalf of the local
137 * @param theSolutionId
138 * solution identifier (UUID).
139 * @param theRevisionId
140 * revision identifier (UUID).
141 * @return solution revision information
142 * @throws ServiceException if an error is encoutered during processing
144 public default MLPSolutionRevision getSolutionRevision(String theSolutionId, String theRevisionId) throws ServiceException {
145 return getSolutionRevision(theSolutionId, theRevisionId, selfService());
149 * Access the list of solution revision artifacts.
151 * @param theSolutionId
152 * solution identifier (UUID).
153 * @param theRevisionId
154 * revision identifier (UUID).
156 * the execution context
157 * @return list of the related artifacts. Null is returned if the solution id or the revision id do not indicate existing items.
158 * @throws ServiceException if an error is encoutered during processing
160 public List<MLPArtifact> getSolutionRevisionArtifacts(String theSolutionId, String theRevisionId,
161 ServiceContext theContext) throws ServiceException;
164 * Default solution revision access interface for calls in behalf of the local
167 * @param theSolutionId
168 * solution identifier (UUID).
169 * @param theRevisionId
170 * revision identifier (UUID).
171 * @return list of the related artifacts
172 * @throws ServiceException if an error is encoutered during processing
174 public default List<MLPArtifact> getSolutionRevisionArtifacts(String theSolutionId, String theRevisionId) throws ServiceException {
175 return getSolutionRevisionArtifacts(theSolutionId, theRevisionId, selfService());
179 * Retrieve artifact content.
181 * @param theArtifactId
182 * identifier of the acumos artifact whose content needs to be
185 * the execution context
186 * @return the artifact information
187 * @throws ServiceException if an error is encoutered during processing
189 public MLPArtifact getSolutionRevisionArtifact(String theArtifactId, ServiceContext theContext)
190 throws ServiceException;
193 * Retrieve artifact content.
195 * @param theArtifactId
196 * identifier of the acumos artifact whose content needs to be
198 * @return the artifact information
199 * @throws ServiceException if an error is encoutered during processing
201 public default MLPArtifact getSolutionRevisionArtifact(String theArtifactId) throws ServiceException {
202 return getSolutionRevisionArtifact(theArtifactId, selfService());
206 * This would belong as a static method of ServiceContext but ServicrCOntext are not beans so I cannot wire them to access the
207 * self bean; in here it exposes an implementation detail which is ugly ..
209 public ServiceContext selfService();