@Override public void setLocationRef(Reference location) { getWrappedRepresentation().setLocationRef(location); }
@Override public void setLocationRef(String locationUri) { getWrappedRepresentation().setLocationRef(locationUri); }
url.openStream(), metadataService.getDefaultMediaType()); output.setLocationRef(request.getResourceRef()); output.setModificationDate(modificationDate);
inputStream, metadataService.getDefaultMediaType()); output.setLocationRef(request.getResourceRef()); output.setModificationDate(modificationDate);
this.fileContent.setLocationRef(getRequest().getOriginalRef()); } else { this.fileContent.setLocationRef(getReference()); rep.setLocationRef(baseReference + filePath); } else { rep.setLocationRef(baseReference + "/" + filePath);
/** * If the response entity comes back with no identifier, automatically set * the request's resource reference's identifier. This is very useful to * resolve relative references in XSLT for example. */ @Override protected void afterHandle(Request request, Response response) { if ((response.getEntity() != null) && (response.getEntity().getLocationRef() == null)) { response.getEntity().setLocationRef( request.getResourceRef().getTargetRef().toString()); } }
/** * Handle POST requests: create a new item. */ @Post public Representation acceptItem(Representation entity) { Representation result = null; // Parse the given representation and retrieve pairs of // "name=value" tokens. Form form = new Form(entity); String itemName = form.getFirstValue("name"); String itemDescription = form.getFirstValue("description"); // Register the new item if one is not already registered. if (!getItems().containsKey(itemName) && getItems().putIfAbsent(itemName, new Item(itemName, itemDescription)) == null) { // Set the response's status and entity setStatus(Status.SUCCESS_CREATED); Representation rep = new StringRepresentation("Item created", MediaType.TEXT_PLAIN); // Indicates where is located the new resource. rep.setLocationRef(getRequest().getResourceRef().getIdentifier() + "/" + itemName); result = rep; } else { // Item is already registered. setStatus(Status.CLIENT_ERROR_NOT_FOUND); result = generateErrorRepresentation("Item " + itemName + " already exists.", "1"); } return result; }
/** * Handle POST requests: create a new item. */ @Post public Representation acceptItem(Representation entity) { Representation result = null; // Parse the given representation and retrieve pairs of // "name=value" tokens. Form form = new Form(entity); String itemName = form.getFirstValue("name"); String itemDescription = form.getFirstValue("description"); // Register the new item if one is not already registered. if (!getItems().containsKey(itemName) && getItems().putIfAbsent(itemName, new Item(itemName, itemDescription)) == null) { // Set the response's status and entity setStatus(Status.SUCCESS_CREATED); Representation rep = new StringRepresentation("Item created", MediaType.TEXT_PLAIN); // Indicates where is located the new resource. rep.setLocationRef(getRequest().getResourceRef().getIdentifier() + "/" + itemName); result = rep; } else { // Item is already registered. setStatus(Status.CLIENT_ERROR_NOT_FOUND); result = generateErrorRepresentation("Item " + itemName + " already exists.", "1"); } return result; }
/** * Redirects a given call to a target reference. In the default * implementation, the request HTTP headers, stored in the request's * attributes, are removed before dispatching. After dispatching, the * response HTTP headers are also removed to prevent conflicts with the main * call. * * @param targetRef * The target reference with URI variables resolved. * @param request * The request to handle. * @param response * The response to update. */ protected void outboundServerRedirect(Reference targetRef, Request request, Response response) { Restlet next = (getApplication() == null) ? null : getApplication() .getOutboundRoot(); if (next == null) { next = getContext().getClientDispatcher(); } serverRedirect(next, targetRef, request, response); if (response.getEntity() != null && !request.getResourceRef().getScheme() .equalsIgnoreCase(targetRef.getScheme())) { // Distinct protocol, this data cannot be exposed. response.getEntity().setLocationRef((Reference) null); } }
/** * Constructor from a variant. * * @param variant * The variant to copy. * @param modificationDate * The modification date. * @param tag * The tag. */ public Representation(Variant variant, Date modificationDate, Tag tag) { setCharacterSet(variant.getCharacterSet()); setEncodings(variant.getEncodings()); setLocationRef(variant.getLocationRef()); setLanguages(variant.getLanguages()); setMediaType(variant.getMediaType()); setModificationDate(modificationDate); setTag(tag); }
entityHeaderFound = true; } else if (HEADER_CONTENT_LOCATION.equalsIgnoreCase(header.getName())) { result.setLocationRef(header.getValue()); entityHeaderFound = true; } else if (HEADER_CONTENT_DISPOSITION.equalsIgnoreCase(header.getName())) {
/** * Rewrite the location of the response, and the Location of the entity, if * any. * * @param request * The request to handle. * @param response * The response to update. */ public void rewriteLocation(Request request, Response response) { if (response.getLocationRef() != null) { Reference locationRef = response.getLocationRef(); String newLocation = getLocation(locationRef, request); if (newLocation != null) { response.setLocationRef(newLocation); } } if (response.getEntity() != null && response.getEntity().getLocationRef() != null) { Reference locationRef = response.getEntity().getLocationRef(); String newLocation = getLocation(locationRef, request); if (newLocation != null) { response.getEntity().setLocationRef(newLocation); } } }
output.setLocationRef(request.getResourceRef()); Entity.updateMetadata(entity.getName(), output, true, getMetadataService()); getMetadataService().getDefaultMediaType(), getTimeToLive()); output.setLocationRef(request.getResourceRef()); Entity.updateMetadata(entity.getName(), output, true, getMetadataService()); response.setStatus(Status.CLIENT_ERROR_NOT_FOUND); } else { output.setLocationRef(request.getResourceRef()); response.setEntity(output); response.setStatus(Status.SUCCESS_OK);
metadataService.getDefaultMediaType(), getTimeToLive()); output.setLocationRef(request.getResourceRef()); Entity.updateMetadata(entity.getName(), output, true, getMetadataService());