use of org.killbill.billing.jaxrs.json.CatalogJson 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();
}
use of org.killbill.billing.jaxrs.json.CatalogJson in project killbill by killbill.
the class CatalogResource method getCatalogJson.
@TimedResource
@GET
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve the catalog as JSON", responseContainer = "List", response = CatalogJson.class)
@ApiResponses(value = {})
public Response getCatalogJson(@QueryParam(QUERY_REQUESTED_DT) final String requestedDate, @QueryParam(QUERY_ACCOUNT_ID) final UUID accountId, @javax.ws.rs.core.Context final HttpServletRequest request) throws Exception {
final TenantContext tenantContext = accountId != null ? context.createTenantContextWithAccountId(accountId, request) : context.createTenantContextNoAccountId(request);
final DateTime catalogDateVersion = requestedDate != null ? DATE_TIME_FORMATTER.parseDateTime(requestedDate).toDateTime(DateTimeZone.UTC) : null;
final VersionedCatalog catalog = catalogUserApi.getCatalog(catalogName, tenantContext);
final Collection<CatalogJson> result = new ArrayList<CatalogJson>();
if (catalogDateVersion == null) {
for (final StaticCatalog v : catalog.getVersions()) {
result.add(new CatalogJson(v));
}
} else {
final StaticCatalog target = catalog.getVersion(catalogDateVersion.toDate());
result.add(new CatalogJson(target));
}
return Response.status(Status.OK).entity(result).build();
}
Aggregations