Java Code Examples for javax.ws.rs.core.PathSegment#getPath()
The following examples show how to use
javax.ws.rs.core.PathSegment#getPath() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UriBuilderImpl.java From cxf with Apache License 2.0 | 6 votes |
private String buildPath() { StringBuilder sb = new StringBuilder(); Iterator<PathSegment> iter = paths.iterator(); while (iter.hasNext()) { PathSegment ps = iter.next(); String p = ps.getPath(); if (p.length() != 0 || !iter.hasNext()) { p = URITemplate.createExactTemplate(p).encodeLiteralCharacters(false); if (sb.length() == 0 && leadingSlash) { sb.append('/'); } else if (!p.startsWith("/") && sb.length() > 0) { sb.append('/'); } sb.append(p); if (iter.hasNext()) { buildMatrix(sb, ps.getMatrixParameters()); } } } buildMatrix(sb, matrix); return sb.toString(); }
Example 2
Source File: SynchronousResources.java From servicetalk with Apache License 2.0 | 5 votes |
@Produces(TEXT_PLAIN) @Path("/matrix/{pathSegment:ps}/params") @GET public String objectsByCategory(@PathParam("pathSegment") final PathSegment pathSegment, @MatrixParam("mp") final List<String> matrixParams) { final MultivaluedMap<String, String> matrixParameters = pathSegment.getMatrixParameters(); final String categorySegmentPath = pathSegment.getPath(); return "GOT: " + matrixParameters.keySet().stream().map(k -> k + "=" + matrixParameters.get(k).stream().collect(joining(","))).collect(joining(",")) + " & " + categorySegmentPath + " & " + matrixParams.stream().collect(joining(",")); }
Example 3
Source File: ParameterScanTests.java From smallrye-open-api with Apache License 2.0 | 5 votes |
@GET @Path("seg1") @Produces(MediaType.TEXT_PLAIN) @Parameter(name = "segments", description = "Test", style = ParameterStyle.MATRIX, in = ParameterIn.PATH) public String echo(@PathParam("segments") PathSegment segmentsMatrix) { return segmentsMatrix.getPath(); }
Example 4
Source File: CarResource.java From resteasy-examples with Apache License 2.0 | 5 votes |
@GET @Path("/matrix/{make}/{model}/{year}") @Produces("text/plain") public String getFromMatrixParam(@PathParam("make") String make, @PathParam("model") PathSegment car, @MatrixParam("color") Color color, @PathParam("year") String year) { return "A " + color + " " + year + " " + make + " " + car.getPath(); }
Example 5
Source File: CarResource.java From resteasy-examples with Apache License 2.0 | 5 votes |
@GET @Path("/segment/{make}/{model}/{year}") @Produces("text/plain") public String getFromPathSegment(@PathParam("make") String make, @PathParam("model") PathSegment car, @PathParam("year") String year) { String carColor = car.getMatrixParameters().getFirst("color"); return "A " + carColor + " " + year + " " + make + " " + car.getPath(); }
Example 6
Source File: CarResource.java From resteasy-examples with Apache License 2.0 | 5 votes |
@GET @Path("/segments/{make}/{model : .+}/year/{year}") @Produces("text/plain") public String getFromMultipleSegments(@PathParam("make") String make, @PathParam("model") List<PathSegment> car, @PathParam("year") String year) { String output = "A " + year + " " + make; for (PathSegment segment : car) { output += " " + segment.getPath(); } return output; }
Example 7
Source File: CarResource.java From resteasy-examples with Apache License 2.0 | 5 votes |
@GET @Path("/uriinfo/{make}/{model}/{year}") @Produces("text/plain") public String getFromUriInfo(@Context UriInfo info) { String make = info.getPathParameters().getFirst("make"); String year = info.getPathParameters().getFirst("year"); PathSegment model = info.getPathSegments().get(3); String color = model.getMatrixParameters().getFirst("color"); return "A " + color + " " + year + " " + make + " " + model.getPath(); }
Example 8
Source File: PathSegmentNumberFilter.java From codenvy with Eclipse Public License 1.0 | 5 votes |
@Override public boolean shouldSkip(HttpServletRequest request) { List<PathSegment> pathSegments = UriComponent.parsePathSegments(request.getRequestURI(), false); int notEmptyPathSergments = 0; for (PathSegment pathSegment : pathSegments) { if (pathSegment.getPath() != null && !pathSegment.getPath().isEmpty()) { notEmptyPathSergments++; } } return notEmptyPathSergments == segmentNumber; }
Example 9
Source File: CatalogWebService.java From olat with Apache License 2.0 | 5 votes |
private Long getCatalogEntryKeyFromPath(final List<PathSegment> path) { final PathSegment lastPath = path.get(path.size() - 1); Long key = null; try { key = new Long(lastPath.getPath()); } catch (final NumberFormatException e) { key = null; } return key; }
Example 10
Source File: CatalogWebService.java From olat with Apache License 2.0 | 5 votes |
private Long getCatalogEntryKeyFromPath(final List<PathSegment> path) { final PathSegment lastPath = path.get(path.size() - 1); Long key = null; try { key = new Long(lastPath.getPath()); } catch (final NumberFormatException e) { key = null; } return key; }
Example 11
Source File: NotifiersResource.java From usergrid with Apache License 2.0 | 5 votes |
@Override @Path("{itemName}") public AbstractContextResource addNameParameter(@Context UriInfo ui, @PathParam("itemName") PathSegment itemName) throws Exception { if (logger.isTraceEnabled()) { logger.trace("NotifiersResource.addNameParameter"); logger.trace("Current segment is {}", itemName.getPath()); } if (itemName.getPath().startsWith("{")) { Query query = Query.fromJsonString(itemName.getPath()); if (query != null) { addParameter(getServiceParameters(), query); } addMatrixParams(getServiceParameters(), ui, itemName); return getSubResource(ServiceResource.class); } addParameter(getServiceParameters(), itemName.getPath()); addMatrixParams(getServiceParameters(), ui, itemName); Identifier id = Identifier.from(itemName.getPath()); if (id == null) { throw new IllegalArgumentException( "Not a valid Notifier identifier: " + itemName.getPath()); } return getSubResource(NotifierResource.class).init(id); }
Example 12
Source File: UsersResource.java From usergrid with Apache License 2.0 | 5 votes |
@Override @Path("{itemName}") public AbstractContextResource addNameParameter( @Context UriInfo ui, @PathParam("itemName") PathSegment itemName) throws Exception { if(logger.isTraceEnabled()){ logger.trace( "ServiceResource.addNameParameter" ); logger.trace( "Current segment is {}", itemName.getPath() ); } if ( itemName.getPath().startsWith( "{" ) ) { Query query = Query.fromJsonString( itemName.getPath() ); if ( query != null ) { addParameter( getServiceParameters(), query ); } addMatrixParams( getServiceParameters(), ui, itemName ); return getSubResource( ServiceResource.class ); } addParameter( getServiceParameters(), itemName.getPath() ); addMatrixParams( getServiceParameters(), ui, itemName ); String forceString = ui.getQueryParameters().getFirst("force"); Identifier id; if (forceString != null && "email".equals(forceString.toLowerCase())) { id = Identifier.fromEmail(itemName.getPath().toLowerCase()); } else if (forceString != null && "name".equals(forceString.toLowerCase())) { id = Identifier.fromName(itemName.getPath().toLowerCase()); } else { id = Identifier.from(itemName.getPath()); } if ( id == null ) { throw new IllegalArgumentException( "Not a valid user identifier: " + itemName.getPath() ); } return getSubResource( UserResource.class ).init( id ); }
Example 13
Source File: PreProcessFilter.java From secure-data-service with Apache License 2.0 | 4 votes |
private void injectObligations(ContainerRequest request) { // Create obligations SLIPrincipal prince = SecurityUtil.getSLIPrincipal(); if (request.getPathSegments().size() > 3) { // not applied on two parters String base = request.getPathSegments().get(1).getPath(); String assoc = request.getPathSegments().get(3).getPath(); if (CONTEXTERS.contains(base)) { LOG.info("Skipping date-based obligation injection because association {} is base level URI", base); return; } if(base.equals(ResourceNames.PROGRAMS) || base.equals(ResourceNames.COHORTS)) { if(assoc.equals(ResourceNames.STAFF_PROGRAM_ASSOCIATIONS) || assoc.equals(ResourceNames.STAFF_COHORT_ASSOCIATIONS)) { prince.setStudentAccessFlag(false); } } if(SecurityUtil.isStudent()) { List<NeutralQuery> oblong = construct("endDate"); for(String entity : DATE_RESTRICTED_ENTITIES) { prince.addObligation(entity, oblong); } } for (PathSegment seg : request.getPathSegments()) { String resourceName = seg.getPath(); if (ResourceNames.STUDENTS.equals(resourceName)) { // once student is encountered, // no more obligations break; } if (CONTEXTERS.contains(resourceName) && !request.getQueryParameters().containsKey("showAll")) { if (ResourceNames.STUDENT_SCHOOL_ASSOCIATIONS.equals(resourceName)) { prince.addObligation(resourceName.replaceAll("s$", ""), construct("exitWithdrawDate")); } else { prince.addObligation(resourceName.replaceAll("s$", ""), construct("endDate")); } LOG.info("Injected a date-based obligation on association: {}", resourceName); } } } }