@Override public void acceptRepresentation(Representation entity) throws ResourceException { Form form = getRequest().getEntityAsForm(); chosenEngine = form.getFirstValue("engine"); String script = form.getFirstValue("script"); if(StringUtils.isBlank(script)) { script=""; } ScriptEngine eng = MANAGER.getEngineByName(chosenEngine); scriptingConsole.bind("scriptResource", this); scriptingConsole.execute(eng, script); scriptingConsole.unbind("scriptResource"); //TODO: log script, results somewhere; job log INFO? getResponse().setEntity(represent()); }
List<Variant> variants = super.getVariants(); Form f = getRequest().getResourceRef().getQueryAsForm(); String format = f.getFirstValue("format"); if("textedit".equals(format)) { if(variants.isEmpty()) { FileRepresentation)v, this, f.getFirstValue("pos"), f.getFirstValue("lines"), f.getFirstValue("reverse"))); };
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); }
String copyTo = form.getFirstValue("copyTo"); if (copyTo != null) { copyJob(copyTo, "on".equals(form.getFirstValue("asProfile"))); return; String action = form.getFirstValue("action"); if ("launch".equals(action)) { String selectedCheckpoint = form.getFirstValue("checkpoint"); if (StringUtils.isNotEmpty(selectedCheckpoint)) { cj.getCheckpointService().setRecoveryCheckpointByName(
@Override public void acceptRepresentation(Representation entity) throws ResourceException { Form form = getRequest().getEntityAsForm(); String action = form.getFirstValue("action"); if("rescan".equals(action)) { getEngine().findJobConfigs(); } else if ("add".equals(action)) { String path = form.getFirstValue("addpath"); if (path==null) { Flash.addFlash(getResponse(), "Cannot add <i>null</i> path", String path = form.getFirstValue("createpath"); if (path==null) { if(!"on".equals(form.getFirstValue("im_sure"))) { Flash.addFlash( getResponse(), if(!"on".equals(form.getFirstValue("ignore__"+entry.getKey()))) { Flash.addFlash( getResponse(),
String newContents = form.getFirstValue("contents"); EditRepresentation er; try {
@Get public String foo() { Form queryParams = getReference().getQueryAsForm(); String f = queryParams.getFirstValue("f"); return f; }
private String getValue( String name, Form queryAsForm, Form entityAsForm ) { String value = queryAsForm.getFirstValue( name ); if( value == null ) { value = entityAsForm.getFirstValue( name ); } return value; } }
private String getValue( String name, Form queryAsForm, Form entityAsForm ) { String value = queryAsForm.getFirstValue( name ); if( value == null ) { value = entityAsForm.getFirstValue( name ); } return value; } }
@Post public void someMethod(Representation entity){ final Form form = new Form(entity); String name = form.getFirstValue("name")); }
public static OAuthException toOAuthException(Form params) { OAuthError error = Enum.valueOf(OAuthError.class, params.getFirstValue(OAuthResourceDefs.ERROR)); OAuthException ex = new OAuthException(error); ex.description = params.getFirstValue(OAuthResourceDefs.ERROR_DESC); ex.errorUri = params.getFirstValue(OAuthResourceDefs.ERROR_URI); return ex; }
public static FacebookTokenResponse parseResponse(Form result) { FacebookTokenResponse token = new FacebookTokenResponse(); token.accessToken = result.getFirstValue(ACCESS_TOKEN); token.expirePeriod = Integer.parseInt(result .getFirstValue("expires")); return token; }
protected HashMap<String,String> bindingsFromForm(Form params) { HashMap<String,String> bindings = new HashMap<String,String> (); for (String key : params.getNames()) { Matcher matcher = xmlnsRE.matcher(key); if (matcher.matches()) { bindings.put(matcher.group(1), params.getFirstValue(key)); } } return bindings; }
/** * Reads parameter from the form returned {@link #getForm()}. * */ @Override public String get(String param) { return getForm().getFirstValue(param); }
protected HashMap<String,String> convertFormStrings(Form params) { HashMap<String,String> converted = new HashMap<String,String>(); for (String key : params.getNames()) { Matcher matcher = xmlnsRE.matcher(key); if (matcher.matches()) { // nop } else { converted.put(key, params.getFirstValue(key)); } } return converted; }
private void validateState(Request request, Form params) throws Exception { String sessionId = request.getCookies().getFirstValue("_state"); String state = (String) getContext().getAttributes().get(sessionId); if (state != null && state.equals(params.getFirstValue(STATE))) { return; } // CSRF detected throw new Exception("The state does not match."); }
@Override public Object get(Context context, Request request, Response response, Variant variant) throws ResourceException { Form form = request.getResourceRef().getQueryAsForm(); int requestedStatus = Integer.parseInt(form.getFirstValue("status")); throw new ResourceException(requestedStatus); } }
/** * Update the underlying user according to the given representation. */ @Put public void storeUser(Representation entity) throws ResourceException { Form form = new Form(entity); this.user.setFirstName(form.getFirstValue("firstName")); this.user.setLastName(form.getFirstValue("lastName")); this.user.setImage(form.getFirstValue("image")); getObjectsFacade().updateUser(this.user); getResponse().redirectSeeOther(getRequest().getResourceRef()); }
protected final String getQueryParamValue( String key, String defaultValue ) { String value = getRequest().getResourceRef().getQueryAsForm().getFirstValue( key ); if ( Strings.isEmpty( value ) ) { value = defaultValue; } return value; }
@Override public Token requestToken(OAuthParameters parameters) throws OAuthException { // Graph API MUST use body method. setupBodyClientCredentials(parameters); Representation input = parameters.toRepresentation(); // Unlike RFC6749, Facebook token parameters are included in www-form. Form result = new Form(post(input)); if (result.getFirstValue(ERROR) != null) { throw OAuthException.toOAuthException(result); } return FacebookTokenResponse.parseResponse(result); }