Search in sources :

Example 16 with TenantContext

use of org.killbill.billing.util.callcontext.TenantContext in project killbill by killbill.

the class SecurityResource method getCurrentUserPermissions.

@TimedResource
@GET
@Path("/permissions")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "List user permissions", response = String.class, responseContainer = "List")
@ApiResponses(value = {})
public Response getCurrentUserPermissions(@javax.ws.rs.core.Context final HttpServletRequest request) {
    // The getCurrentUserPermissions takes a TenantContext which is not used because permissions are cross tenants (at this point)
    final TenantContext nullTenantContext = null;
    final Set<Permission> permissions = securityApi.getCurrentUserPermissions(nullTenantContext);
    final List<String> json = ImmutableList.<String>copyOf(Iterables.<Permission, String>transform(permissions, Functions.toStringFunction()));
    return Response.status(Status.OK).entity(json).build();
}
Also used : Permission(org.killbill.billing.security.Permission) TenantContext(org.killbill.billing.util.callcontext.TenantContext) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 17 with TenantContext

use of org.killbill.billing.util.callcontext.TenantContext in project killbill by killbill.

the class BundleResource method getTags.

@TimedResource
@GET
@Path("/{bundleId:" + UUID_PATTERN + "}/" + TAGS)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve bundle tags", response = TagJson.class, responseContainer = "List")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid bundle id supplied"), @ApiResponse(code = 404, message = "Bundle not found") })
public Response getTags(@PathParam(ID_PARAM_NAME) final String bundleIdString, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @QueryParam(QUERY_INCLUDED_DELETED) @DefaultValue("false") final Boolean includedDeleted, @javax.ws.rs.core.Context final HttpServletRequest request) throws TagDefinitionApiException, SubscriptionApiException {
    final UUID bundleId = UUID.fromString(bundleIdString);
    final TenantContext tenantContext = context.createContext(request);
    final SubscriptionBundle bundle = subscriptionApi.getSubscriptionBundle(bundleId, context.createContext(request));
    return super.getTags(bundle.getAccountId(), bundleId, auditMode, includedDeleted, tenantContext);
}
Also used : SubscriptionBundle(org.killbill.billing.entitlement.api.SubscriptionBundle) TenantContext(org.killbill.billing.util.callcontext.TenantContext) UUID(java.util.UUID) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 18 with TenantContext

use of org.killbill.billing.util.callcontext.TenantContext in project killbill by killbill.

the class CatalogResource method getCatalogJson.

@TimedResource
@GET
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve the catalog as JSON", response = StaticCatalog.class)
@ApiResponses(value = {})
public Response getCatalogJson(@QueryParam(QUERY_REQUESTED_DT) final String requestedDate, @javax.ws.rs.core.Context final HttpServletRequest request) throws Exception {
    final TenantContext tenantContext = context.createContext(request);
    final DateTime catalogDateVersion = requestedDate != null ? DATE_TIME_FORMATTER.parseDateTime(requestedDate).toDateTime(DateTimeZone.UTC) : null;
    // Yack...
    final VersionedCatalog catalog = (VersionedCatalog) catalogUserApi.getCatalog(catalogName, tenantContext);
    final List<CatalogJson> result = new ArrayList<CatalogJson>();
    if (catalogDateVersion != null) {
        result.add(new CatalogJson(catalog, catalogDateVersion));
    } else {
        for (final StandaloneCatalog v : catalog.getVersions()) {
            result.add(new CatalogJson(catalog, new DateTime(v.getEffectiveDate())));
        }
    }
    return Response.status(Status.OK).entity(result).build();
}
Also used : VersionedCatalog(org.killbill.billing.catalog.VersionedCatalog) StandaloneCatalog(org.killbill.billing.catalog.StandaloneCatalog) ArrayList(java.util.ArrayList) TenantContext(org.killbill.billing.util.callcontext.TenantContext) CatalogJson(org.killbill.billing.jaxrs.json.CatalogJson) DateTime(org.joda.time.DateTime) TimedResource(org.killbill.commons.metrics.TimedResource) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 19 with TenantContext

use of org.killbill.billing.util.callcontext.TenantContext in project killbill by killbill.

the class CatalogResource method getAvailableAddons.

// Need to figure out dependency on StandaloneCatalog
//    @GET
//    @Path("/xsd")
//    @Produces(APPLICATION_XML)
//    public String getCatalogXsd() throws Exception
//    {
//        InputStream stream = XMLSchemaGenerator.xmlSchema(StandaloneCatalog.class);
//        StringWriter writer = new StringWriter();
//        IOUtils.copy(stream, writer);
//        String result = writer.toString();
//
//        return result;
//    }
@TimedResource
@GET
@Path("/availableAddons")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve available add-ons for a given product", response = PlanDetailJson.class, responseContainer = "List")
@ApiResponses(value = {})
public Response getAvailableAddons(@QueryParam("baseProductName") final String baseProductName, @Nullable @QueryParam("priceListName") final String priceListName, @javax.ws.rs.core.Context final HttpServletRequest request) throws CatalogApiException {
    final TenantContext tenantContext = context.createContext(request);
    final StaticCatalog catalog = catalogUserApi.getCurrentCatalog(catalogName, tenantContext);
    final List<Listing> listings = catalog.getAvailableAddOnListings(baseProductName, priceListName);
    final List<PlanDetailJson> details = new ArrayList<PlanDetailJson>();
    for (final Listing listing : listings) {
        details.add(new PlanDetailJson(listing));
    }
    return Response.status(Status.OK).entity(details).build();
}
Also used : PlanDetailJson(org.killbill.billing.jaxrs.json.PlanDetailJson) Listing(org.killbill.billing.catalog.api.Listing) ArrayList(java.util.ArrayList) TenantContext(org.killbill.billing.util.callcontext.TenantContext) StaticCatalog(org.killbill.billing.catalog.api.StaticCatalog) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 20 with TenantContext

use of org.killbill.billing.util.callcontext.TenantContext in project killbill by killbill.

the class CatalogResource method getAvailableBasePlans.

@TimedResource
@GET
@Path("/availableBasePlans")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve available base plans", response = PlanDetailJson.class, responseContainer = "List")
@ApiResponses(value = {})
public Response getAvailableBasePlans(@javax.ws.rs.core.Context final HttpServletRequest request) throws CatalogApiException {
    final TenantContext tenantContext = context.createContext(request);
    final StaticCatalog catalog = catalogUserApi.getCurrentCatalog(catalogName, tenantContext);
    final List<Listing> listings = catalog.getAvailableBasePlanListings();
    final List<PlanDetailJson> details = new ArrayList<PlanDetailJson>();
    for (final Listing listing : listings) {
        details.add(new PlanDetailJson(listing));
    }
    return Response.status(Status.OK).entity(details).build();
}
Also used : PlanDetailJson(org.killbill.billing.jaxrs.json.PlanDetailJson) Listing(org.killbill.billing.catalog.api.Listing) ArrayList(java.util.ArrayList) TenantContext(org.killbill.billing.util.callcontext.TenantContext) StaticCatalog(org.killbill.billing.catalog.api.StaticCatalog) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

TenantContext (org.killbill.billing.util.callcontext.TenantContext)69 ApiOperation (io.swagger.annotations.ApiOperation)58 ApiResponses (io.swagger.annotations.ApiResponses)58 Produces (javax.ws.rs.Produces)58 GET (javax.ws.rs.GET)57 TimedResource (org.killbill.commons.metrics.TimedResource)54 Path (javax.ws.rs.Path)51 AccountAuditLogs (org.killbill.billing.util.audit.AccountAuditLogs)31 UUID (java.util.UUID)30 Account (org.killbill.billing.account.api.Account)17 PluginProperty (org.killbill.billing.payment.api.PluginProperty)15 URI (java.net.URI)14 Payment (org.killbill.billing.payment.api.Payment)13 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)10 Invoice (org.killbill.billing.invoice.api.Invoice)9 ImmutableMap (com.google.common.collect.ImmutableMap)8 Map (java.util.Map)8 AtomicReference (java.util.concurrent.atomic.AtomicReference)8 List (java.util.List)7