use of io.swagger.annotations.ApiResponse in project indy by Commonjava.
the class SecurityResource method getKeycloakUiJson.
@ApiOperation("Retrieve the keycloak JSON configuration (for use by the UI)")
@ApiResponses({ @ApiResponse(code = 400, message = "Keycloak is disabled"), @ApiResponse(code = 200, message = "File retrieval successful") })
@Path("/keycloak.json")
@Produces("application/json")
@GET
public Response getKeycloakUiJson() {
logger.debug("Retrieving Keycloak UI JSON file...");
Response response = null;
try {
final String content = controller.getKeycloakUiJson();
if (content == null) {
response = Response.status(Status.BAD_REQUEST).entity(DISABLED_MESSAGE).header(ApplicationHeader.cache_control.key(), NO_CACHE).build();
} else {
response = Response.ok(content).header(ApplicationHeader.cache_control.key(), NO_CACHE).build();
}
} catch (final IndyWorkflowException e) {
logger.error(String.format("Failed to load client-side keycloak.json. Reason: %s", e.getMessage()), e);
response = formatResponse(e);
}
return response;
}
use of io.swagger.annotations.ApiResponse in project indy by Commonjava.
the class SecurityResource method getKeycloakInit.
@ApiOperation("Retrieve the keycloak init Javascript (for use by the UI)")
@ApiResponse(code = 200, message = "Always return 200 whether Keycloak is disabled or not")
@Path("/keycloak-init.js")
@Produces("text/javascript")
@GET
public Response getKeycloakInit() {
logger.debug("Retrieving Keycloak UI-init Javascript file...");
Response response = null;
try {
response = Response.ok(controller.getKeycloakInit()).header(ApplicationHeader.cache_control.key(), NO_CACHE).build();
} catch (final IndyWorkflowException e) {
logger.error(String.format("Failed to load keycloak-init.js. Reason: %s", e.getMessage()), e);
response = formatResponse(e);
}
return response;
}
use of io.swagger.annotations.ApiResponse in project indy by Commonjava.
the class SecurityResource method getKeycloakJs.
@ApiOperation("Retrieve the keycloak Javascript adapter (for use by the UI)")
@ApiResponses({ @ApiResponse(code = 200, message = "Keycloak is disabled, return a Javascript comment to this effect."), @ApiResponse(code = 307, message = "Redirect to keycloak server to load Javascript adapter.") })
@Path("/keycloak.js")
@Produces("text/javascript")
@GET
public Response getKeycloakJs() {
logger.debug("Retrieving Keycloak Javascript adapter...");
Response response = null;
try {
final String url = controller.getKeycloakJs();
if (url == null) {
response = Response.ok("/* " + DISABLED_MESSAGE + "; loading of keycloak.js blocked. */").header(ApplicationHeader.cache_control.key(), NO_CACHE).build();
} else {
response = Response.temporaryRedirect(new URI(url)).build();
}
} catch (final IndyWorkflowException | URISyntaxException e) {
logger.error(String.format("Failed to load keycloak.js. Reason: %s", e.getMessage()), e);
response = formatResponse(e);
}
return response;
}
use of io.swagger.annotations.ApiResponse in project che by eclipse.
the class WorkspaceService method updateProject.
@PUT
@Path("/{id}/project/{path:.*}")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Update the workspace project by replacing it with a new one", notes = "This operation can be performed only by the workspace owner")
@ApiResponses({ @ApiResponse(code = 200, message = "The project successfully updated"), @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"), @ApiResponse(code = 403, message = "The user does not have access to update the project"), @ApiResponse(code = 404, message = "The workspace or the project not found"), @ApiResponse(code = 500, message = "Internal server error occurred") })
public WorkspaceDto updateProject(@ApiParam("The workspace id") @PathParam("id") String id, @ApiParam("The path to the project") @PathParam("path") String path, @ApiParam(value = "The project update", required = true) ProjectConfigDto update) throws ServerException, BadRequestException, NotFoundException, ConflictException, ForbiddenException {
requiredNotNull(update, "Project config");
final WorkspaceImpl workspace = workspaceManager.getWorkspace(id);
final List<ProjectConfigImpl> projects = workspace.getConfig().getProjects();
final String normalizedPath = path.startsWith("/") ? path : '/' + path;
if (!projects.removeIf(project -> project.getPath().equals(normalizedPath))) {
throw new NotFoundException(format("Workspace '%s' doesn't contain project with path '%s'", id, normalizedPath));
}
projects.add(new ProjectConfigImpl(update));
validator.validateConfig(workspace.getConfig());
return linksInjector.injectLinks(asDto(workspaceManager.updateWorkspace(id, workspace)), getServiceContext());
}
use of io.swagger.annotations.ApiResponse in project killbill by killbill.
the class SubscriptionResource method cancelEntitlementPlan.
@TimedResource
@DELETE
@Path("/{subscriptionId:" + UUID_PATTERN + "}")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Cancel an entitlement plan")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid subscription id supplied"), @ApiResponse(code = 404, message = "Entitlement not found") })
public Response cancelEntitlementPlan(@PathParam("subscriptionId") final String subscriptionId, @QueryParam(QUERY_REQUESTED_DT) final String requestedDate, @QueryParam(QUERY_CALL_COMPLETION) @DefaultValue("false") final Boolean callCompletion, @QueryParam(QUERY_CALL_TIMEOUT) @DefaultValue("5") final long timeoutSec, @QueryParam(QUERY_ENTITLEMENT_POLICY) final String entitlementPolicyString, @QueryParam(QUERY_BILLING_POLICY) final String billingPolicyString, @QueryParam(QUERY_USE_REQUESTED_DATE_FOR_BILLING) @DefaultValue("false") final Boolean useRequestedDateForBilling, @QueryParam(QUERY_PLUGIN_PROPERTY) final List<String> pluginPropertiesString, @HeaderParam(HDR_CREATED_BY) final String createdBy, @HeaderParam(HDR_REASON) final String reason, @HeaderParam(HDR_COMMENT) final String comment, @javax.ws.rs.core.Context final UriInfo uriInfo, @javax.ws.rs.core.Context final HttpServletRequest request) throws EntitlementApiException, AccountApiException, SubscriptionApiException {
final CallContext callContext = context.createContext(createdBy, reason, comment, request);
final Iterable<PluginProperty> pluginProperties = extractPluginProperties(pluginPropertiesString);
final EntitlementCallCompletionCallback<Response> callback = new EntitlementCallCompletionCallback<Response>() {
private boolean isImmediateOp = true;
@Override
public Response doOperation(final CallContext ctx) throws EntitlementApiException, InterruptedException, TimeoutException, AccountApiException, SubscriptionApiException {
final UUID uuid = UUID.fromString(subscriptionId);
final Entitlement current = entitlementApi.getEntitlementForId(uuid, ctx);
final LocalDate inputLocalDate = toLocalDate(requestedDate);
final Entitlement newEntitlement;
if (billingPolicyString == null && entitlementPolicyString == null) {
newEntitlement = current.cancelEntitlementWithDate(inputLocalDate, useRequestedDateForBilling, pluginProperties, ctx);
} else if (billingPolicyString == null && entitlementPolicyString != null) {
final EntitlementActionPolicy entitlementPolicy = EntitlementActionPolicy.valueOf(entitlementPolicyString);
newEntitlement = current.cancelEntitlementWithPolicy(entitlementPolicy, pluginProperties, ctx);
} else if (billingPolicyString != null && entitlementPolicyString == null) {
final BillingActionPolicy billingPolicy = BillingActionPolicy.valueOf(billingPolicyString.toUpperCase());
newEntitlement = current.cancelEntitlementWithDateOverrideBillingPolicy(inputLocalDate, billingPolicy, pluginProperties, ctx);
} else {
final EntitlementActionPolicy entitlementPolicy = EntitlementActionPolicy.valueOf(entitlementPolicyString);
final BillingActionPolicy billingPolicy = BillingActionPolicy.valueOf(billingPolicyString.toUpperCase());
newEntitlement = current.cancelEntitlementWithPolicyOverrideBillingPolicy(entitlementPolicy, billingPolicy, pluginProperties, ctx);
}
final Subscription subscription = subscriptionApi.getSubscriptionForEntitlementId(newEntitlement.getId(), ctx);
final LocalDate nowInAccountTimeZone = new LocalDate(clock.getUTCNow(), subscription.getBillingEndDate().getChronology().getZone());
isImmediateOp = subscription.getBillingEndDate() != null && !subscription.getBillingEndDate().isAfter(nowInAccountTimeZone);
return Response.status(Status.OK).build();
}
@Override
public boolean isImmOperation() {
return isImmediateOp;
}
@Override
public Response doResponseOk(final Response operationResponse) {
return operationResponse;
}
};
final EntitlementCallCompletion<Response> callCompletionCreation = new EntitlementCallCompletion<Response>();
return callCompletionCreation.withSynchronization(callback, timeoutSec, callCompletion, callContext);
}
Aggregations