public String getBeansRefPath() { Reference ref = getRequest().getResourceRef(); String path = ref.getPath(); int i = path.indexOf("/beans/"); if(i>0) { return path.substring(0,i+"/beans/".length()); } if(!path.endsWith("/")) { path += "/"; } return path; }
/** * Returns the optionnally decoded path component. * * @param decode * Indicates if the result should be decoded using the * {@link #decode(String)} method. * @return The optionnally decoded path component. * @see #getPath() */ public String getPath(boolean decode) { return decode ? decode(getPath()) : getPath(); }
/** * Returns the optionnally decoded path component. If not path is available * it returns null. * * @param decode * Indicates if the result should be decoded using the {@link #decode(String)} method. * @return The optionnally decoded path component. * @see #getPath() */ public String getPath(boolean decode) { return decode ? decode(getPath()) : getPath(); }
/** * Returns the optionnally decoded path component. If not path is available * it returns null. * * @param decode * Indicates if the result should be decoded using the * {@link #decode(String)} method. * @return The optionnally decoded path component. * @see #getPath() */ public String getPath(boolean decode) { return decode ? decode(getPath()) : getPath(); }
private String getIdentityPath( Reference ref ) { String path = ref.getPath(); if( !path.endsWith( "/" ) ) { path = path.substring( 0, path.lastIndexOf( '/' ) + 1 ); } return path; }
public String getBeansRefPath() { Reference ref = getRequest().getResourceRef(); String path = ref.getPath(); int i = path.indexOf("/beans/"); if(i>0) { return path.substring(0,i+"/beans/".length()); } if(!path.endsWith("/")) { path += "/"; } return path; }
public CaUriResolver( Reference rootRef, String uri ) { NullArgumentException.ensureNotNull( "rootRef", rootRef ); NullArgumentException.ensureNotEmpty( "uri", uri ); String interestingPath = new Reference( uri ).getPath().replaceAll( "^" + rootRef.getPath() + "/", "" ); String[] splitted = interestingPath.split( "/" ); if ( splitted.length != 2 ) { throw new IllegalArgumentException( "Unable to resolve URI: " + uri ); } clazz = resolveClass( splitted[0] ); identity = splitted[1]; }
/** * Sets the last segment of the path. If no path is available, then it * creates one and adds a slash in front of the given last segmetn. <br> * Note that no URI decoding is done by this method. * * @param lastSegment * The last segment of a hierarchical path. */ public void setLastSegment(String lastSegment) { final String path = getPath(); final int lastSlashIndex = path.lastIndexOf('/'); if (lastSlashIndex != -1) { setPath(path.substring(0, lastSlashIndex + 1) + lastSegment); } else { setPath('/' + lastSegment); } }
@Override public void write( Writer writer ) throws IOException { PrintWriter out = new PrintWriter( writer ); out.println( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<rdf:RDF\n" + "\txmlns=\"urn:polygene:\"\n" + "\txmlns:polygene=\"http://polygene.apache.org/rdf/model/1.0/\"\n" + "\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" + "\txmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\">" ); query.forEach( qualifiedIdentity -> out.println( "<polygene:entity rdf:about=\"" + getRequest().getResourceRef().getPath() + "/" + qualifiedIdentity.identity() + ".rdf\"/>" ) ); out.println( "</rdf:RDF>" ); } };
private Reference updateBaseRefPath( Reference reference ) { if ( reference.getBaseRef().getPath() == null ) { reference.getBaseRef().setPath( "/" ); } else if ( !reference.getBaseRef().getPath().endsWith( "/" ) ) { reference.getBaseRef().setPath( reference.getBaseRef().getPath() + "/" ); } return reference; }
/** * Constructor. * * @param request * The Restlet request to wrap. * @param core * The Solr core. */ public SolrRestletQueryRequest(Request request, SolrCore core) { super(core, new SolrRestletParams(request)); getContext().put("path", request.getResourceRef().getPath()); ArrayList<ContentStream> _streams = new ArrayList<ContentStream>(1); _streams.add(new SolrRepresentationContentStream(request.getEntity())); setContentStreams(_streams); }
@Override public Reference getContextRoot(Request request) { Reference result = null; if (globalRestApiSettings.isEnabled() && globalRestApiSettings.isForceBaseUrl() && StringUtils.isNotEmpty(globalRestApiSettings.getBaseUrl())) { result = new Reference(globalRestApiSettings.getBaseUrl()); } else { // TODO: NEXUS-6045 hack, Restlet app root is now "/service/local", so going up 2 levels! result = request.getRootRef().getParentRef().getParentRef(); } // fix for when restlet is at webapp root if (StringUtils.isEmpty(result.getPath())) { result.setPath("/"); } return result; }
protected RepositoryTargetResource getNexusToRestResource(Target target, Request request) { RepositoryTargetResource resource = new RepositoryTargetResource(); resource.setId(target.getId()); resource.setName(target.getName()); resource.setResourceURI(request.getResourceRef().getPath()); resource.setContentClass(target.getContentClass().getId()); List<String> patterns = new ArrayList<String>(target.getPatternTexts()); for (String pattern : patterns) { resource.addPattern(pattern); } return resource; }
protected RepositoryTargetResource getNexusToRestResource( Target target, Request request ) { RepositoryTargetResource resource = new RepositoryTargetResource(); resource.setId( target.getId() ); resource.setName( target.getName() ); resource.setResourceURI( request.getResourceRef().getPath() ); resource.setContentClass( target.getContentClass().getId() ); List<String> patterns = new ArrayList<String>( target.getPatternTexts() ); for ( String pattern : patterns ) { resource.addPattern( pattern ); } return resource; }
/** * @param ref * @param b * @return * @throws IllegalArgumentException */ private UriBuilder fillUriBuilder(Reference ref, final UriBuilder b) throws IllegalArgumentException { b.scheme(ref.getScheme(false)); b.userInfo(ref.getUserInfo(false)); b.host(ref.getHostDomain(false)); b.port(ref.getHostPort()); b.path(ref.getPath(false)); b.replaceQuery(ref.getQuery(false)); b.fragment(ref.getFragment(false)); return b; }