public void acceptRepresentation(Representation entity) throws ResourceException { if (appCtx == null) { throw new ResourceException(404); } // copy op? Form form = getRequest().getEntityAsForm(); beanPath = form.getFirstValue("beanPath"); String newVal = form.getFirstValue("newVal"); if(newVal!=null) { int i = beanPath.indexOf("."); String beanName = i<0?beanPath:beanPath.substring(0,i); Object namedBean = appCtx.getBean(beanName); BeanWrapperImpl bwrap = new BeanWrapperImpl(namedBean); String propPath = beanPath.substring(i+1); Object coercedVal = bwrap.convertIfNecessary(newVal, bwrap.getPropertyValue(propPath).getClass()); bwrap.setPropertyValue(propPath, coercedVal); } Reference ref = getRequest().getResourceRef(); ref.setPath(getBeansRefPath()); ref.addSegment(beanPath); getResponse().redirectSeeOther(ref); }
/** * Adds a segment at the end of the path. If the current path doesn't end * with a slash character, one is inserted before the new segment value. The * value is automatically encoded if necessary. * * @param value * The segment value to add. * @return The updated reference. * @see Reference#addSegment(String) */ public Reference addSegment(String value) { return getReference().addSegment(value); }
public CaX509ProfileUriBuilder x509Profile() { return new CaX509ProfileUriBuilder( root.clone().addSegment( "x509Profile" ), null, null ); }
public CaX509UriBuilder x509() { return new CaX509UriBuilder( root.clone().addSegment( "x509" ), null, null ); }
public CaToolsUriBuilder tools() { return new CaToolsUriBuilder( root.clone().addSegment( "tools" ), null, null ); }
public CaEscrowedKeyPairUriBuilder escrowedKeyPair() { return new CaEscrowedKeyPairUriBuilder( root.clone().addSegment( "escrow" ), null, null ); }
public CaCaUriBuilder ca() { return new CaCaUriBuilder( root.clone().addSegment( "ca" ), null, null ); }
public CaCryptoStoreUriBuilder cryptoStore() { return new CaCryptoStoreUriBuilder( root.clone().addSegment( "cryptostore" ), null, null ); }
@Override public void write( Writer buf ) throws IOException { PrintWriter out = new PrintWriter( buf ); out.println( "<html><head><title>All entities</title></head><body><h1>All entities</h1><ul>" ); query.forEach( entity -> out.println( "<li><a href=\"" + getRequest().getResourceRef().clone().addSegment( entity.identity() + ".html" ) + "\">" + entity.identity() + "</a></li>" ) ); out.println( "</ul></body></html>" ); } };
public final String build() { if ( "factory".equals( special ) ) { return baseRef.clone().addSegment( "factory" ).toString(); } if ( Strings.isEmpty( identity ) ) { if ( !Strings.isEmpty( special ) ) { return baseRef.clone().addSegment( special ).toString(); } return baseRef.toString(); } if ( Strings.isEmpty( special ) ) { return baseRef.clone().addSegment( identity ).toString(); } return baseRef.clone().addSegment( identity ).addSegment( special ).toString(); }
@Get("json") public List<CarRepresentation> all() { List<io.github.cdelmas.spike.common.domain.Car> cars = carRepository.all(); getResponse().getHeaders().add("total-count", String.valueOf(cars.size())); return cars.stream().map(c -> { CarRepresentation carRepresentation = new CarRepresentation(c); carRepresentation.addLink(Link.self(new Reference(getReference()).addSegment(String.valueOf(c.getId())).toString())); return carRepresentation; }).collect(toList()); }
@Post("json") public void createCar(io.github.cdelmas.spike.common.domain.Car car) { carRepository.save(car); setLocationRef(getReference().addSegment(String.valueOf(car.getId()))); setStatus(Status.SUCCESS_CREATED); }
cr.addSegment("apis").addSegment(""); logger.info("Create a new connector"); cr.post(definitionRepresentation, MediaType.APPLICATION_JSON); } else if (createNewVersion) { cr.addSegment("apis").addSegment(cellId) .addSegment("versions").addSegment(""); logger.info("Create a new version of the cell " + cellId); cr.post(definitionRepresentation, MediaType.APPLICATION_JSON); } else if (updateCell) { cr.addSegment("apis").addSegment(cellId) .addSegment("versions").addSegment(cellVersion); logger.info("Update version " + cellVersion + " of cell " + cellId + " with strategy " + updateStrategy);
public void acceptRepresentation(Representation entity) throws ResourceException { if (appCtx == null) { throw new ResourceException(404); } // copy op? Form form = getRequest().getEntityAsForm(); beanPath = form.getFirstValue("beanPath"); String newVal = form.getFirstValue("newVal"); if(newVal!=null) { int i = beanPath.indexOf("."); String beanName = i<0?beanPath:beanPath.substring(0,i); Object namedBean = appCtx.getBean(beanName); BeanWrapperImpl bwrap = new BeanWrapperImpl(namedBean); String propPath = beanPath.substring(i+1); Object coercedVal = bwrap.convertIfNecessary(newVal, bwrap.getPropertyValue(propPath).getClass()); bwrap.setPropertyValue(propPath, coercedVal); } Reference ref = getRequest().getResourceRef(); ref.setPath(getBeansRefPath()); ref.addSegment(beanPath); getResponse().redirectSeeOther(ref); }
private Representation representAtom() throws ResourceException { try { Feed feed = new Feed(); feed.setTitle( new Text( MediaType.TEXT_PLAIN, "All entities" ) ); List<Entry> entries = feed.getEntries(); entityFinder.findEntities( EntityComposite.class, null, null, null, null, Collections.emptyMap() ) .forEach( entityReference -> { Entry entry = new Entry(); entry.setTitle( new Text( MediaType.TEXT_PLAIN, entityReference.toString() ) ); Link link = new Link(); link.setHref( getRequest().getResourceRef().clone() .addSegment( entityReference.identity().toString() ) ); entry.getLinks().add( link ); entries.add( entry ); } ); return feed; } catch( Exception e ) { throw new ResourceException( e ); } }
ref.setHostDomain(hostDomain); if (route instanceof TemplateRoute) { ref.addSegment(((TemplateRoute) route) .getTemplate().getPattern());
ref.setHostDomain(hostDomain); if (route instanceof TemplateRoute) { ref.addSegment(((TemplateRoute) route) .getTemplate().getPattern());
ref.setHostDomain(hostDomain); if (route instanceof TemplateRoute) { ref.addSegment(((TemplateRoute) route) .getTemplate().getPattern());
ref.setHostDomain(hostDomain); if (route instanceof TemplateRoute) { ref.addSegment(((TemplateRoute) route) .getTemplate().getPattern());
ref.setHostDomain(hostDomain); if (route instanceof TemplateRoute) { ref.addSegment(((TemplateRoute) route) .getTemplate().getPattern());