@POST @Path("{botId}") @ApiResponse(code = 200, responseHeaders = { @ResponseHeader(name = "location", response = URI.class) }, message = "returns location of the exported ZIP file to be downloaded") Response exportBot(@PathParam("botId") String botId, @ApiParam(name = "botVersion", required = true, format = "integer", example = "1") @QueryParam("botVersion") @DefaultValue("1") Integer botVersion); }
@ApiOperation(value = "Return the configuration icon file in png format", tags = "icon", responseHeaders = { @ResponseHeader(name = HEADER_TALEND_COMPONENT_SERVER_ERROR, description = ERROR_HEADER_DESC, response = Boolean.class) }) @GET @Path("icon/{id}") @Produces({ APPLICATION_JSON, APPLICATION_OCTET_STREAM }) public CompletionStage<byte[]> getConfigurationIconById(@PathParam("id") final String id, @Context final HttpServletRequest request) { return componentClient.getFamilyIconById(id, placeholderProviderFactory.newProvider(request)); }
@POST @Path("persistence/save/{formId}") @ApiOperation(value = "Saves a configuration based on a form identifier.", response = EntityRef.class, produces = "application/json", tags = { "form", "ui spec", "configurations", "datastore", "dataset", "persistence" }, responseHeaders = @ResponseHeader(name = HEADER_TALEND_COMPONENT_SERVER_ERROR, description = ERROR_HEADER_DESC, response = Boolean.class)) public CompletionStage<EntityRef> postConfigurationFromFormId(@Context final HttpServletRequest request, @PathParam("formId") final String formId, final JsonObject payload) { return doSave(request, getLang(request), payload, formId); }
@POST @Consumes("application/zip") @ApiImplicitParam(type = "body", paramType = "body", required = true) @ApiResponse(code = 200, responseHeaders = { @ResponseHeader(name = "location", response = URI.class) }, message = "returns reference to the newly created (imported) bot") void importBot(InputStream zippedBotConfigFiles, @Suspended AsyncResponse response); }
@ResponseHeaders({@ResponseHeader(name = "h1", response = String.class), @ResponseHeader(name = "h2", response = String.class)}) @RequestMapping(path = "/responseEntity", method = RequestMethod.POST) public ResponseEntity<Date> responseEntity(InvocationContext c1, @RequestAttribute("date") Date date) { HttpHeaders headers = new HttpHeaders(); headers.add("h1", "h1v " + c1.getContext().toString()); InvocationContext c2 = ContextUtils.getInvocationContext(); headers.add("h2", "h2v " + c2.getContext().toString()); return new ResponseEntity<Date>(date, headers, HttpStatus.ACCEPTED); }
@RequestMapping(value = "/{accessId}", method = RequestMethod.DELETE) @ApiOperation(value ="Delete bank access", notes= "Deletes the bank access with the given id, also deletes all associated credentials, accounts and bookings. Returns the location url for loading the updated user data object.") @ApiResponses({ @ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, responseHeaders={@ResponseHeader(name="location", description="Url for loading the updated user data file")}, message = "Bank access with provided id successfuly deleted"), @ApiResponse(code = HttpServletResponse.SC_GONE, responseHeaders={@ResponseHeader(name="location", description="Url for loading the updated user data file")}, message = "Bank access with provided id is gone"), @ApiResponse(code = HttpServletResponse.SC_UNAUTHORIZED, message = ErrorConstants.ERR_HTTP_CODE_UNAUTHENTICATED_DOC, response = MultibankingError.class), @ApiResponse(code = HttpServletResponse.SC_PRECONDITION_FAILED, message = UserNotFoundException.RENDERED_MESSAGE_KEY, response = MultibankingError.class) }) public HttpEntity<Void> deleteBankAccess( @ApiParam(name = "accessId", required=true, value = "The identifier of the bank access to delete.", example="3c149076-13c4-4190-ace3-e30bf8f61526") @PathVariable String accessId) { if (bankAccessService.deleteBankAccess(accessId)) { LOGGER.debug("Bank Access [{}] deleted.", accessId); return new ResponseEntity<Void>(userDataLocationHeader(), HttpStatus.NO_CONTENT); } else { return new ResponseEntity<Void>(HttpStatus.GONE); } } }
@RequestMapping(value = "/{accessId}", method = RequestMethod.DELETE) @ApiOperation(value ="Delete bank access", notes= "Deletes the bank access with the given id, also deletes all associated credentials, accounts and bookings. Returns the location url for loading the updated user data object.") @ApiResponses({ @ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, responseHeaders={@ResponseHeader(name="location", description="Url for loading the updated user data file")}, message = "Bank access with provided id successfuly deleted"), @ApiResponse(code = HttpServletResponse.SC_GONE, responseHeaders={@ResponseHeader(name="location", description="Url for loading the updated user data file")}, message = "Bank access with provided id is gone"), @ApiResponse(code = HttpServletResponse.SC_UNAUTHORIZED, message = ErrorConstants.ERR_HTTP_CODE_UNAUTHENTICATED_DOC, response = MultibankingError.class), @ApiResponse(code = HttpServletResponse.SC_PRECONDITION_FAILED, message = UserNotFoundException.RENDERED_MESSAGE_KEY, response = MultibankingError.class) }) public HttpEntity<Void> deleteBankAccess( @ApiParam(name = "accessId", required=true, value = "The identifier of the bank access to delete.", example="3c149076-13c4-4190-ace3-e30bf8f61526") @PathVariable String accessId) { if (bankAccessService.deleteBankAccess(accessId)) { LOGGER.debug("Bank Access [{}] deleted.", accessId); return new ResponseEntity<Void>(userDataLocationHeader(), HttpStatus.NO_CONTENT); } else { return new ResponseEntity<Void>(HttpStatus.GONE); } } }
@RequestMapping(method = RequestMethod.POST, consumes=MediaType.APPLICATION_JSON_UTF8_VALUE) @ApiOperation(value="Create bank access", notes = "Creates and adds a new bank access to the list of bank accesses of this user. Returns the location url for loading the updated user data object.") @ApiResponses(value = { @ApiResponse(code = HttpServletResponse.SC_CREATED, responseHeaders={@ResponseHeader(name="location", description="Url for loading the updated user data file")}, message = "Provided bank access successfuly created. Reload user data object."), @ApiResponse(code = HttpServletResponse.SC_UNAUTHORIZED, message = ErrorConstants.ERR_HTTP_CODE_UNAUTHENTICATED_DOC, response = MultibankingError.class), @ApiResponse(code = HttpServletResponse.SC_PRECONDITION_FAILED, message = UserNotFoundException.RENDERED_MESSAGE_KEY, response = MultibankingError.class), @ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = InvalidBankAccessException.MESSAGE_DOC, response = MultibankingError.class), @ApiResponse(code = HttpServletResponse.SC_CONFLICT, message = BankAccessAlreadyExistException.MESSAGE_DOC, response = MultibankingError.class), @ApiResponse(code = HttpServletResponse.SC_BAD_REQUEST, message = ErrorConstants.ERR_HTTP_CODE_BAD_REQUEST_DOC, response = MultibankingError.class) }) public HttpEntity<Void> createBankaccess(@ApiParam(name = "bankAccess", required=true, value = "The bank access data containing (Bank Code, Bank name, Bank login, PIN") @RequestBody(required = true) BankAccessEntity bankAccess) { bankAccessService.createBankAccess(bankAccess); // Trigger Perform Services operations. LOGGER.debug("Bank access created for " + userId()); return new ResponseEntity<>(userDataLocationHeader(), HttpStatus.CREATED); }
@RequestMapping(method = RequestMethod.POST, consumes=MediaType.APPLICATION_JSON_UTF8_VALUE) @ApiOperation(value="Create bank access", notes = "Creates and adds a new bank access to the list of bank accesses of this user. Returns the location url for loading the updated user data object.") @ApiResponses(value = { @ApiResponse(code = HttpServletResponse.SC_CREATED, responseHeaders={@ResponseHeader(name="location", description="Url for loading the updated user data file")}, message = "Provided bank access successfuly created. Reload user data object."), @ApiResponse(code = HttpServletResponse.SC_UNAUTHORIZED, message = ErrorConstants.ERR_HTTP_CODE_UNAUTHENTICATED_DOC, response = MultibankingError.class), @ApiResponse(code = HttpServletResponse.SC_PRECONDITION_FAILED, message = UserNotFoundException.RENDERED_MESSAGE_KEY, response = MultibankingError.class), @ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = InvalidBankAccessException.MESSAGE_DOC, response = MultibankingError.class), @ApiResponse(code = HttpServletResponse.SC_CONFLICT, message = BankAccessAlreadyExistException.MESSAGE_DOC, response = MultibankingError.class), @ApiResponse(code = HttpServletResponse.SC_BAD_REQUEST, message = ErrorConstants.ERR_HTTP_CODE_BAD_REQUEST_DOC, response = MultibankingError.class) }) public HttpEntity<Void> createBankaccess(@ApiParam(name = "bankAccess", required=true, value = "The bank access data containing (Bank Code, Bank name, Bank login, PIN") @RequestBody(required = true) BankAccessEntity bankAccess) { bankAccessService.createBankAccess(bankAccess); // Trigger Perform Services operations. LOGGER.debug("Bank access created for " + userId()); return new ResponseEntity<>(userDataLocationHeader(), HttpStatus.CREATED); }
@ApiOperation(value = "This endpoint execute an action required by a form.", notes = "configuration types has action that can be executed using this endpoint", tags = { "action", "configurations" }, produces = APPLICATION_JSON, consumes = APPLICATION_JSON, responseContainer = "Map", responseHeaders = { @ResponseHeader(name = ErrorProcessor.Constants.HEADER_TALEND_COMPONENT_SERVER_ERROR, description = ERROR_HEADER_DESC, response = Boolean.class) }) @ApiResponses({ @ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "This response is returned when no action is found", response = ProxyErrorPayload.class), @ApiResponse(code = SC_BAD_REQUEST, message = "This response is returned when the action is null", response = ProxyErrorPayload.class), @ApiResponse(code = 520, message = "This response is returned when the action raise an unhandled error", response = ProxyErrorPayload.class) }) @POST @Path("execute") public CompletionStage<Map<String, Object>> execute(@QueryParam("family") final String family, @QueryParam("type") final String type, @QueryParam("action") final String action, @QueryParam("language") final String lang, @Context final HttpServletRequest request, final Map<String, Object> params) { return service .createStage(family, type, action, new UiSpecContext(ofNullable(lang).orElse("en"), placeholderProviderFactory.newProvider(request)), params); } }
@POST @Consumes(MediaType.APPLICATION_JSON) @ApiOperation(value = "Creates a rule.") @Produces(MediaType.APPLICATION_JSON) @ApiResponses(value = { @ApiResponse(code = 201, message = "Created", responseHeaders = @ResponseHeader(name = "Location", description = "Newly created Rule", response = String.class)), @ApiResponse(code = 409, message = "Creation of the rule is refused. Rule with the same UID already exists."), @ApiResponse(code = 400, message = "Creation of the rule is refused. Missing required parameter.") }) public Response create(@ApiParam(value = "rule data", required = true) RuleDTO rule) throws IOException { try { final Rule newRule = ruleRegistry.add(RuleDTOMapper.map(rule)); return Response.status(Status.CREATED) .header("Location", "rules/" + URLEncoder.encode(newRule.getUID(), "UTF-8")).build(); } catch (IllegalArgumentException e) { String errMessage = "Creation of the rule is refused: " + e.getMessage(); logger.warn("{}", errMessage); return JSONResponse.createErrorResponse(Status.CONFLICT, errMessage); } catch (RuntimeException e) { String errMessage = "Creation of the rule is refused: " + e.getMessage(); logger.warn("{}", errMessage); return JSONResponse.createErrorResponse(Status.BAD_REQUEST, errMessage); } }
@GetMapping(produces = { MediaType.APPLICATION_JSON_VALUE }) @ApiOperation(value = "Password Grant", notes = "Implements the oauth2 Pasword grant type. Works only if server is configured to accept password grant") @ApiResponses(value = { @ApiResponse(code = 200, message = "Ok", response = TokenResponse.class), @ApiResponse(code = 400, message = "Bad request", responseHeaders = @ResponseHeader(name = "error", description = "invalid request")) }) public ResponseEntity<Object> passwordGrant( @ApiParam(name = "grant_type", value = "Indicates that a token exchange is being performed.", required = true, allowMultiple = false, example = "password", defaultValue = "password") @RequestParam("grant_type") String grant_type, @ApiParam(name = "resource", value = "Indicates the physical location of the target service or resource where the client intends to use the requested security token. This enables the authorization server to apply policy as appropriate for the target, such as determining the type and content of the token to be issued or if and how the token is to be encrypted.", required = false, allowMultiple = true, example = "http://localhost:8080/multibanking-service") @RequestParam(name = "resource", required = false) String[] resources, @ApiParam(name = "audience", value = "The logical name of the target service where the client intends to use the requested security token. This serves a purpose similar to the resource parameter, but with the client providing a logical name rather than a physical location.", required = false, allowMultiple = true, example = "http://localhost:8080/multibanking-service") @RequestParam(name = "audience", required = false) String[] audiences, @ApiParam(name = "scope", value = "A list of space-delimited, case-sensitive strings that allow the client to specify the desired scope of the requested security token in the context of the service or resource where the token will be used.", required = false, allowMultiple = false, example = "user banking") @RequestParam(name = "scope", required = false) String scope, @ApiParam(name = "username", value = "The resource owner username..", required = true, allowMultiple = false, example = "max.musterman") @RequestParam("username") String username, @ApiParam(name = "password", value = "The resource owner password.", required = true, allowMultiple = false, example = "SamplePassword") @RequestParam("password") String password) { try { TokenResponse tokenResponse = passwordGrantService.passwordGrant(grant_type, resources, audiences, ResponseUtils.getIssuer(servletRequest), scope, username, password); return ResponseEntity.ok(tokenResponse); } catch (InvalidParameterException e) { return ResponseUtils.invalidParam(e.getMessage()); } catch (MissingParameterException e) { return ResponseUtils.missingParam(e.getMessage()); } } }
message = "Redirect to IDP logout page", responseHeaders = { @ResponseHeader( name = "Location", response = String.class, description = "Url to IDP's logout page" ), @ResponseHeader( name = "Set-Cookie", response = String.class, description = TokenConstants.ACCESS_TOKEN_COOKIE_NAME + "=null; Path=/; Secure; HttpOnly; Max-Age=0" ), @ResponseHeader(
@ApiOperation(value = "Return all the available root configuration (Data store like) from the component server", notes = "Every configuration has an icon. " + "In the response an icon key is returned. this icon key can be one of the bundled icons or a custom one. " + "The consumer of this endpoint will need to check if the icon key is in the icons bundle " + "otherwise the icon need to be gathered using the `familyId` from this endpoint `configurations/{id}/icon`", response = Nodes.class, tags = { "configurations", "datastore" }, produces = "application/json", responseHeaders = { @ResponseHeader(name = HEADER_TALEND_COMPONENT_SERVER_ERROR, description = ERROR_HEADER_DESC, response = Boolean.class) }) @GET public CompletionStage<Nodes> getRootConfig(@Context final HttpServletRequest request) { final String language = getLang(request); final Function<String, String> placeholderProvider = placeholderProviderFactory.newProvider(request); return findRoots(new HttpRequestContext(language, placeholderProvider, request)); }
@ApiOperation(value = "Return a form description ( Ui Spec ) without a specific configuration ", response = Nodes.class, produces = "application/json", tags = { "form", "ui spec", "configurations", "datastore", "dataset" }, responseHeaders = { @ResponseHeader(name = HEADER_TALEND_COMPONENT_SERVER_ERROR, description = ERROR_HEADER_DESC, response = Boolean.class) }) @GET @Path("form/initial/{type}") public CompletionStage<UiNode> getInitialForm(@PathParam("type") final String type, @Context final HttpServletRequest request) { if (type == null || type.isEmpty()) { throw new WebApplicationException(Response .status(Response.Status.BAD_REQUEST) .entity(new ProxyErrorPayload(ProxyErrorDictionary.BAD_CONFIGURATION_TYPE.name(), "No configuration type passed")) .type(APPLICATION_JSON_TYPE) .build()); } final String language = getLang(request); final Function<String, String> placeholderProvider = placeholderProviderFactory.newProvider(request); return toUiSpecAndMetadata(language, placeholderProvider, CompletableFuture .completedFuture(new ConfigTypeNode(type, 0, null, type, type, type, emptySet(), new ArrayList<>(), new ArrayList<>())), true); }
@POST @Path("persistence/save-from-type/{type}") @ApiOperation( value = "Saves a configuration based on a type. Concretely it is the same as `/persistence/save/{formId}` " + "but the `formId` is contained into the payload itself and marked in the metadata as such.", response = EntityRef.class, produces = "application/json", tags = { "form", "ui spec", "configurations", "datastore", "dataset", "persistence" }, responseHeaders = @ResponseHeader(name = HEADER_TALEND_COMPONENT_SERVER_ERROR, description = ERROR_HEADER_DESC, response = Boolean.class)) public CompletionStage<EntityRef> postConfigurationFromType(@Context final HttpServletRequest request, @PathParam("type") final String type, final JsonObject payload) { final String lang = getLang(request); final String formId = modelEnricherService .findEnclosedFormId(type, lang, payload) .orElseThrow(() -> new WebApplicationException(Response .status(Response.Status.BAD_REQUEST) .entity(new ProxyErrorPayload(ProxyErrorDictionary.NO_CONFIGURATION_TYPE.name(), "No form identifier found in the form properties")) .build())); return doSave(request, lang, payload, formId); }
@ApiResponse(code = 200, response = User.class, message = "") @ResponseHeaders({@ResponseHeader(name = "h1", response = String.class), @ResponseHeader(name = "h2", response = String.class)}) @RequestMapping(path = "/cseResponse", method = RequestMethod.GET) public Response cseResponse(InvocationContext c1) { Response response = Response.createSuccess(Status.ACCEPTED, new User()); Headers headers = response.getHeaders(); headers.addHeader("h1", "h1v " + c1.getContext().toString()); InvocationContext c2 = ContextUtils.getInvocationContext(); headers.addHeader("h2", "h2v " + c2.getContext().toString()); return response; }
@POST @Path("upgrade/latest") @ApiOperation("Triggers a migration of Cassandra schema to the latest available") @ApiResponses({ @ApiResponse(code = HttpStatus.CREATED_201, message = "The taskId of the given scheduled task", response = TaskIdDto.class, responseHeaders = { @ResponseHeader(name = "Location", description = "URL of the resource associated with the scheduled task") }), @ApiResponse(code = HttpStatus.CONFLICT_409, message = "Migration can not be done") }) public Object upgradeToLatest(Response response) { try { Migration migration = cassandraMigrationService.upgradeToLastVersion(); TaskId taskId = taskManager.submit(migration); return TaskIdDto.respond(response, taskId); } catch (IllegalStateException e) { LOGGER.info(MIGRATION_REQUEST_CAN_NOT_BE_DONE, e); throw ErrorResponder.builder() .statusCode(HttpStatus.CONFLICT_409) .type(ErrorType.WRONG_STATE) .message(MIGRATION_REQUEST_CAN_NOT_BE_DONE) .cause(e) .haltError(); } }
@ApiOperation(value = "Return a form description ( Ui Spec ) of a specific configuration ", response = UiNode.class, tags = { "form", "ui spec", "configurations", "datastore", "dataset" }, produces = "application/json", responseHeaders = { @ResponseHeader(name = HEADER_TALEND_COMPONENT_SERVER_ERROR, description = ERROR_HEADER_DESC, response = Boolean.class) }) @GET @Path("form/{id}") public CompletionStage<UiNode> getForm(@PathParam("id") final String id, @Context final HttpServletRequest request) { final String lang = getLang(request); final Function<String, String> placeholderProvider = placeholderProviderFactory.newProvider(request); final HttpRequestContext requestContext = new HttpRequestContext(lang, placeholderProvider, request); return onFindByIdEvent .fireAsync(new OnFindById(requestContext, id), notificationOptions) .thenCompose(event -> event .getFormId() .thenCompose(formId -> toUiSpecAndMetadata(lang, placeholderProvider, configurationClient.getDetails(lang, formId, placeholderProvider), false) .thenCompose(uiNode -> event.getProperties().thenApply(props -> { uiNode.getUi().setProperties(props); return uiNode; })))); }
@ApiOperation(value = "Update a configuration.", response = EntityRef.class, produces = "application/json", tags = { "form", "ui spec", "configurations", "datastore", "dataset", "persistence" }, responseHeaders = @ResponseHeader(name = HEADER_TALEND_COMPONENT_SERVER_ERROR, description = ERROR_HEADER_DESC, response = Boolean.class)) public CompletionStage<EntityRef> putConfiguration(@Context final HttpServletRequest request,