public Response listResourceVersions( String typeName, String schemaName, String uriBase, String name, UriInfo uri) { Iterator<org.cristalise.kernel.lookup.Path> iter = Gateway.getLookup().search(new DomainPath("/desc/" + typeName), name); if (!iter.hasNext()) throw ItemUtils.createWebAppException(schemaName + " not found", Response.Status.NOT_FOUND); try { ItemProxy item = Gateway.getProxyManager().getProxy(iter.next()); return toJSON( enumerate( item, ClusterStorage.VIEWPOINT + "/" + schemaName, "/" + uriBase + "/" + name, uri)); } catch (ObjectNotFoundException e) { throw ItemUtils.createWebAppException( schemaName + " has no versions", Response.Status.NOT_FOUND); } }
public Response getResource(String typeName, String schemaName, String name, Integer version) { Iterator<org.cristalise.kernel.lookup.Path> iter = Gateway.getLookup().search(new DomainPath("/desc/" + typeName), name); if (!iter.hasNext()) throw ItemUtils.createWebAppException(schemaName + " not found", Response.Status.NOT_FOUND); try { ItemProxy item = Gateway.getProxyManager().getProxy(iter.next()); Viewpoint view = item.getViewpoint(schemaName, String.valueOf(version)); return getOutcomeResponse(view.getOutcome(), view.getEvent(), false); } catch (ObjectNotFoundException e) { throw ItemUtils.createWebAppException( schemaName + " v" + version + " does not exist", Response.Status.NOT_FOUND); } catch (PersistencyException e) { Logger.error(e); throw ItemUtils.createWebAppException("Database error"); } catch (InvalidDataException e) { throw ItemUtils.createWebAppException( schemaName + " v" + version + " doesn't point to any data", Response.Status.NOT_FOUND); } }
@GET @Path("{name}/version/{version}") public Response getCollectionVersion( @PathParam("uuid") String uuid, @PathParam("name") String collName, @PathParam("version") String collVersion, @CookieParam(COOKIENAME) Cookie authCookie, @Context UriInfo uri) { checkAuthCookie(authCookie); ItemProxy item = getProxy(uuid); try { return toJSON( makeCollectionData( item.getCollection( collName, collVersion.equals("last") ? null : Integer.valueOf(collVersion)), uri)); } catch (ObjectNotFoundException e) { throw ItemUtils.createWebAppException(e.getMessage(), Response.Status.NOT_FOUND); } catch (NumberFormatException e) { throw ItemUtils.createWebAppException(e.getMessage(), Response.Status.NOT_FOUND); } }
@GET @Path("{name}") @Produces(MediaType.APPLICATION_JSON) public Response getLastCollection( @PathParam("uuid") String uuid, @PathParam("name") String collName, @CookieParam(COOKIENAME) Cookie authCookie, @Context UriInfo uri) { checkAuthCookie(authCookie); ItemProxy item = getProxy(uuid); try { return toJSON(makeCollectionData(item.getCollection(collName), uri)); } catch (ObjectNotFoundException e) { throw ItemUtils.createWebAppException(e.getMessage(), Response.Status.NOT_FOUND); } }