/** * Returns the wrapped representation's identifier. * * @return The wrapped representation's identifier. * @see ContentStream#getSourceInfo() */ public String getSourceInfo() { if (representation.getLocationRef() != null) return representation.getLocationRef().toString(); return null; }
public int compare(Representation rep0, Representation rep1) { boolean bRep0Null = (rep0.getLocationRef() == null); boolean bRep1Null = (rep1.getLocationRef() == null); if (bRep0Null && bRep1Null) { return 0; } if (bRep0Null) { return -1; } if (bRep1Null) { return 1; } return rep0.getLocationRef().getLastSegment() .compareTo(rep1.getLocationRef().getLastSegment()); } };
@Override public Reference getLocationRef() { return getWrappedRepresentation().getLocationRef(); }
/** * Returns a SAX source. * * @param xmlRepresentation * The XML representation to wrap. * @return A SAX source. * @throws IOException */ public static javax.xml.transform.sax.SAXSource getSaxSource( Representation xmlRepresentation) throws IOException { javax.xml.transform.sax.SAXSource result = null; if (xmlRepresentation != null) { result = new javax.xml.transform.sax.SAXSource(new InputSource( xmlRepresentation.getStream())); if (xmlRepresentation.getLocationRef() != null) { result.setSystemId(xmlRepresentation.getLocationRef() .getTargetRef().toString()); } } return result; }
/** * Constructor. * * @param xmlRepresentation * A source XML representation to parse. * @throws IOException */ public SaxRepresentation(Representation xmlRepresentation) { super((xmlRepresentation == null) ? null : xmlRepresentation .getMediaType()); try { if (xmlRepresentation instanceof XmlRepresentation) { this.source = new InputSource(xmlRepresentation.getStream()); } else { this.source = new InputSource(xmlRepresentation.getStream()); } if (xmlRepresentation.getCharacterSet()!= null) { this.source.setEncoding(xmlRepresentation.getCharacterSet().getName()); } if (xmlRepresentation.getLocationRef() != null) { this.source.setSystemId(xmlRepresentation.getLocationRef() .getTargetRef().toString()); } } catch (IOException ioe) { ioe.printStackTrace(); } }
if (representation.getLocationRef() != null) { result.setSystemId(representation.getLocationRef().getTargetRef() .toString());
if (xmlRepresentation.getLocationRef() != null) { this.source.setSystemId(xmlRepresentation.getLocationRef() .getTargetRef().toString());
/** * Adds the entity headers based on the {@link Representation} to the {@link Series} when a 304 (Not Modified) * status is returned. * * @param entity * The source entity {@link Representation}. * @param headers * The target headers {@link Series}. */ public static void addNotModifiedEntityHeaders(Representation entity, Series<Header> headers) { if (entity != null) { if (entity.getTag() != null) { addHeader(HEADER_ETAG, TagWriter.write(entity.getTag()), headers); } if (entity.getLocationRef() != null) { addHeader(HEADER_CONTENT_LOCATION, entity.getLocationRef().getTargetRef().toString(), headers); } } }
getTransformSheet().getStream()); if (getTransformSheet().getLocationRef() != null) { transformSource.setSystemId(getTransformSheet() .getLocationRef().getTargetRef().toString());
/** * Returns a FreeMarker template from a representation and a configuration. * * @param config * The FreeMarker configuration. * @param templateRepresentation * The template representation. * @return The template or null if not found. */ public static Template getTemplate(Configuration config, Representation templateRepresentation) { try { // Instantiate the template with the character set of the template // representation if it has been set, otherwise use UTF-8. if (templateRepresentation.getCharacterSet() != null) { return new Template("template", templateRepresentation.getReader(), config, templateRepresentation.getCharacterSet().getName()); } return new Template("template", templateRepresentation.getReader(), config, CharacterSet.UTF_8.getName()); } catch (IOException e) { Context.getCurrentLogger().warning( "Unable to get the template from the representation " + templateRepresentation.getLocationRef() + ". Error message: " + e.getMessage()); return null; } }
/** * 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); } } }
/** * 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()); } }
this.uniqueReference = contextResponse.getEntity().getLocationRef(); return new ReferenceList(Arrays.asList(contextResponse.getEntity().getLocationRef()));
try { Representation r = itemsResource.post(getRepresentation(item)); itemResource = new ClientResource(r.getLocationRef()); } catch (ResourceException e) { System.out.println("Error status: " + e.getStatus());
addHeader(HEADER_CONTENT_LANGUAGE, LanguageWriter.write(entity.getLanguages()), headers); if (entity.getLocationRef() != null) { addHeader(HEADER_CONTENT_LOCATION, entity.getLocationRef().getTargetRef().toString(), headers);
Representation r = itemsResource.post(getRepresentation(item)); if (itemsResource.getStatus().isSuccess()) { itemResource = new ClientResource(r.getLocationRef());