当前位置: 首页>>代码示例>>Java>>正文


Java Form.getFirstValue方法代码示例

本文整理汇总了Java中org.restlet.data.Form.getFirstValue方法的典型用法代码示例。如果您正苦于以下问题:Java Form.getFirstValue方法的具体用法?Java Form.getFirstValue怎么用?Java Form.getFirstValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.restlet.data.Form的用法示例。


在下文中一共展示了Form.getFirstValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: postFormData

import org.restlet.data.Form; //导入方法依赖的package包/类
@Post
public void postFormData(final Representation entity) {
    ExtensionTokenManager tokenManager = getTokenManager();
    if (tokenManager.authenticationRequired()) {
        getResponse().setStatus(Status.CLIENT_ERROR_UNAUTHORIZED);
    } else {
        Form form = new Form(entity);
        final String emailAddress = form.getFirstValue(FORM_INPUT_EMAIL_ADDRESS);
        if (StringUtils.isNotBlank(emailAddress)) {
            TestEmailNotifier testNotifier = (TestEmailNotifier) getContext().getAttributes()
                    .get(EmailExtensionConstants.CONTEXT_ATTRIBUTE_KEY_TEST_NOTIFIER);
            testNotifier.setEmailAddress(emailAddress);
            testNotifier.run();
            testNotifier.setEmailAddress("");
        }
    }
}
 
开发者ID:blackducksoftware,项目名称:hub-email-extension,代码行数:18,代码来源:EmailTestServerResource.java

示例2: getGrantType

import org.restlet.data.Form; //导入方法依赖的package包/类
/**
 * Get request parameter "grant_type".
 * 
 * @param params
 * @return
 * @throws OAuthException
 */
protected static GrantType getGrantType(Form params) throws OAuthException {
    String typeString = params.getFirstValue(GRANT_TYPE);
    getLogger().info("Type: " + typeString);
    try {
        GrantType type = Enum.valueOf(GrantType.class, typeString);
        getLogger().fine("Found flow - " + type);
        return type;
    } catch (IllegalArgumentException iae) {
        throw new OAuthException(OAuthError.unsupported_grant_type,
                "Unsupported flow", null);
    } catch (NullPointerException npe) {
        throw new OAuthException(OAuthError.invalid_request,
                "No grant_type parameter found.", null);
    }
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:23,代码来源:AccessTokenServerResource.java

示例3: getClient

import org.restlet.data.Form; //导入方法依赖的package包/类
/**
 * Get request parameter "client_id".
 * 
 * @param params
 * @return
 * @throws OAuthException
 */
protected static Client getClient(Form params) throws OAuthException {
    // check clientId:
    String clientId = params.getFirstValue(CLIENT_ID);
    if (clientId == null || clientId.isEmpty()) {
        getLogger().warning("Could not find client ID");
        throw new OAuthException(OAuthError.invalid_request,
                "No client_id parameter found.", null);
    }
    Client client = clients.findById(clientId);
    getLogger().fine("Client = " + client);
    if (client == null) {
    	getLogger().warning("Need to register the client : " + clientId);
        throw new OAuthException(OAuthError.invalid_request,
                "Need to register the client : " + clientId, null);
    }

    return client;
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:26,代码来源:OAuthServerResource.java

示例4: open4Apple

import org.restlet.data.Form; //导入方法依赖的package包/类
/** 
 * @Title: open4Apple 
 * @Description:打开苹果客户端推送
 * @param @return
 * @return String
 * @throws 
 * @author Martin
 * @date 2015年4月8日 下午3:53:41
 * @version V1.0
*/ 
@Get
public String open4Apple() {
	try {
		//获取查询参数
		Form form = getRequest().getResourceRef().getQueryAsForm() ;
		String token= form.getFirstValue("token");
		if(StringUtil.isEmpty(token)){
			return JsonUtils.getError("token参数值为null", false);
		}
		List<AppleTokenEntity> appleTokenEntity = commonDao.findByProperty(AppleTokenEntity.class, "token", token);
		if(appleTokenEntity!=null&&appleTokenEntity.size()>0){
			return JsonUtils.getError("数据库已有该token记录", false);
		}else{
			AppleTokenEntity appleToken=new AppleTokenEntity();
			appleToken.setToken(token);
			//添加操作
			commonDao.save(appleToken);
		}
		return JsonUtils.getOK("", false);
	} catch (Exception e) {
		return JsonUtils.getError(e.getMessage(), false);
	}
}
 
开发者ID:Martin404,项目名称:jmsRestful,代码行数:34,代码来源:PNSOpenResource.java

示例5: JsonParameters

import org.restlet.data.Form; //导入方法依赖的package包/类
public JsonParameters(Form form) throws Exception {
  // get parameters in String format
  String jsonPayload = form.getFirstValue(JSON_PARAMETERS, true);
  if (jsonPayload == null || jsonPayload.isEmpty()) {
    _parameterMap = Collections.emptyMap();
  } else {
    _parameterMap = ClusterRepresentationUtil.JsonToMap(jsonPayload);
  }

  // get extra parameters in ZNRecord format
  ObjectMapper mapper = new ObjectMapper();
  String newIdealStateString = form.getFirstValue(NEW_IDEAL_STATE, true);

  if (newIdealStateString != null) {
    ZNRecord newIdealState =
        mapper.readValue(new StringReader(newIdealStateString), ZNRecord.class);
    _extraParameterMap.put(NEW_IDEAL_STATE, newIdealState);
  }

  String newStateModelString = form.getFirstValue(NEW_STATE_MODEL_DEF, true);
  if (newStateModelString != null) {
    ZNRecord newStateModel =
        mapper.readValue(new StringReader(newStateModelString), ZNRecord.class);
    _extraParameterMap.put(NEW_STATE_MODEL_DEF, newStateModel);
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:27,代码来源:JsonParameters.java

示例6: post

import org.restlet.data.Form; //导入方法依赖的package包/类
public Representation post(Representation entity) {
   Form form = new Form(entity);
   String submit = form.getFirstValue("submit");
   String cancel = form.getFirstValue("cancel");
   String update = form.getFirstValue("update");
   if (submit==null) {
      submit = "Upload";
   }
   if (cancel==null) {
      cancel = "Cancel";
   }
   UploadApplication app = (UploadApplication)getContext().getAttributes().get("upload.app");
   UploadProgress progress = app.newUpload("true".equals(update),submit,cancel);
   getResponse().setStatus(Status.SUCCESS_CREATED);
   getResponse().setLocationRef(new Reference(getRequest().getResourceRef().getParentRef().toString()+progress.id+"/"));
   return new StringRepresentation("<context id='"+progress.id+"'/>",MediaType.APPLICATION_XML);
}
 
开发者ID:alexmilowski,项目名称:xproclet,代码行数:18,代码来源:UploadApplication.java

示例7: post

import org.restlet.data.Form; //导入方法依赖的package包/类
public Representation post(Representation rep) {
   Reference service = getReferenceAttribute(getRequest(),"auth-service",confService);
   if (service==null) {
      getResponse().setStatus(Status.SERVER_ERROR_SERVICE_UNAVAILABLE);
      return null;
   }
   getLogger().info("Using service "+service);
   final Form form = new Form(rep);
   String username = form.getFirstValue("username");
   String domain = form.getFirstValue("domain");
   String email = username;
   if (domain!=null && domain.length()>0 && email.indexOf('@')<0) {
      email += "@"+domain;
   }
   String password = form.getFirstValue("password");
   Identity user = idManager.get(email);
   if (user==null) {
      getLogger().info("Unknown user "+email);
      actor.unauthorized();
      return null;
   }
   login(getContext().createChildContext(),service,loginApp,loginType,username,password,email,form,actor);
   return null;
}
 
开发者ID:alexmilowski,项目名称:xproclet,代码行数:25,代码来源:LoginAction.java

示例8: updateUserPrefsViaPOST

import org.restlet.data.Form; //导入方法依赖的package包/类
/**
 * <p>Forwards POST requests (coming from Ajax or web browsers) to the PUT
 * handler for user pref changes.<p>
 * @param method the HTTP method to forward to (must be "put")
 * @param dashboardId ID of the dashboard hosting the gadget
 * @param gadgetId ID of the gadget to update the prefs for
 * @param request the request object (used for providing the locale)
 * @param formParams the container for the form parameters
 * @return a {@code Response} with details on the request's success or
 * failure
 */
@Post()
@AnonymousAllowed
public void updateUserPrefsViaPOST() {
    Request request = getRequest();
    Map<String, Object> attrs = getRequestAttributes();
    DashboardId dashboardId = DashboardId.valueOf(attrs.get("dashboardId"));
    GadgetId gadgetId = GadgetId.valueOf(attrs.get("gadgetId"));
    Form form = request.getEntityAsForm();
    String method = form.getFirstValue("method");
    if (method.equals("put")) {
        updateUserPrefs(dashboardId, gadgetId, form);
    } else {
        getResponse().setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
    }
}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:27,代码来源:PrefsResource.java

示例9: QueryRequest

import org.restlet.data.Form; //导入方法依赖的package包/类
public QueryRequest(Request request) {
    Form form = request.getResourceRef().getQueryAsForm();
    query = form.getFirstValue("query");
    if (form.getFirstValue("start") != null)
        start = Integer.parseInt(form.getFirstValue("start"));
    if (form.getFirstValue("limit") != null)
        limit = Integer.parseInt(form.getFirstValue("limit"));
    if (form.getFirstValue("filter") != null) {

        JSONArray ar = JSONArray.fromObject(form.getFirstValue("filter"));
        Filter[] fs = new Filter[ar.size()];
        int x = 0;
        for (@SuppressWarnings("unchecked")
        Iterator<JSONObject> i = ar.iterator(); i.hasNext();) {
            JSONObject jsonObject = i.next();
            Filter f = (Filter) JSONObject.toBean(jsonObject, Filter.class);
            fs[x++] = f;
        }
        filters = fs;
    }
    sortProperty = form.getFirstValue("sort");
    sortDirection = form.getFirstValue("dir");
}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:24,代码来源:QueryRequest.java

示例10: checkValidClaimsInToken

import org.restlet.data.Form; //导入方法依赖的package包/类
private static boolean checkValidClaimsInToken(Cookie cookie, String signature) {

		Map<String, String> claimsInToken = com.sixsq.slipstream.auth.TokenChecker.claimsInToken(signature);

		logger.info("checkValidClaimsInToken, signature = " + signature);

		boolean invalidClaims = claimsInToken == null || claimsInToken.isEmpty();

		if(invalidClaims) {
			logger.severe("Invalid claims for " + cookie);
			return false;
		}

		Form form = new Form(cookie.getValue());
		String usernameInCookie = form.getFirstValue(COOKIE_IDENTIFIER);
		String runIdInCookie = form.getFirstValue(COOKIE_RUN_ID);

		boolean cookieAndClaimsMatch =
				usernameInCookie!=null && usernameInCookie.equals(claimsInToken.get(COOKIE_IDENTIFIER)) &&
				runIdInCookie!=null && runIdInCookie.equals(claimsInToken.get(COOKIE_RUN_ID));

		return !invalidClaims && cookieAndClaimsMatch;
	}
 
开发者ID:slipstream,项目名称:SlipStreamServer,代码行数:24,代码来源:CookieUtils.java

示例11: setKeepRunning

import org.restlet.data.Form; //导入方法依赖的package包/类
private void setKeepRunning(Run run, Form form) throws ValidationException {
	String keepRunning = form.getFirstValue(KEEP_RUNNING_KEY, null);
	if (keepRunning != null) {
		List<String> keepRunningOptions = UserParameter.getKeepRunningOptions();

		if (! keepRunningOptions.contains(keepRunning)) {
			throw new ValidationException("Value of " + KEEP_RUNNING_KEY + " should be one of the following: "
					+ keepRunningOptions.toString());
		}

		String key = RunParameter.constructKey(ExecutionControlUserParametersFactory.CATEGORY,
				UserParameter.KEY_KEEP_RUNNING);

		RunParameter rp = run.getParameter(key);
		if (rp != null) {
			rp.setValue(keepRunning);
		}
	}
}
 
开发者ID:slipstream,项目名称:SlipStreamServer,代码行数:20,代码来源:RunListResource.java

示例12: fromRequest

import org.restlet.data.Form; //导入方法依赖的package包/类
/**
 * // Get parameters for processing? None currently, but may be:
 * // - lower case tagging or filtering
 * // - coordinate parsing on|off
 * //
 * // Get parameters for formatting. JSON, HTML, mainly.
 * // Output represents filters + format.
 * //
 * 
 * @param inputs
 * @return
 */
private RequestParameters fromRequest(Form inputs) {
    RequestParameters job = new RequestParameters();
    String list = inputs.getValues("features");
    Set<String> features = new HashSet<>();
    job.tag_coordinates = true;
    job.tag_countries = true;
    job.tag_places = true;

    if (isNotBlank(list)) {
        features.addAll(TextUtils.string2list(list.toLowerCase(), ","));

        job.output_coordinates = features.contains("coordinates");
        job.output_countries = features.contains("countries");
        job.output_places = features.contains("places");
    }

    String fmt = inputs.getFirstValue("format");
    if (fmt != null) {
        job.format = fmt;
    }

    return job;
}
 
开发者ID:OpenSextant,项目名称:Xponents,代码行数:36,代码来源:TaggerResource.java

示例13: request

import org.restlet.data.Form; //导入方法依赖的package包/类
@Get("json")
public String request(final String entity) {
    int verboseLevel = 0;
    addAllowOrigin();

    //routing should be in a way in which open_test_uuid is always set
    String openUUID = getRequest().getAttributes().get("open_test_uuid").toString();


    final Form getParameters = getRequest().getResourceRef().getQueryAsForm();
    //allow sender + verbose
    for (String name : getParameters.getNames()) {
        if (name.equals("verbose")) {
            try {
                verboseLevel = Integer.parseInt(getParameters.getFirstValue("verbose"));
            } catch (NumberFormatException ex) {
                Logger.getGlobal().info("invalid non-numberic verbosity level");
            }
        } else if (name.equals("sender") || name.equals("?sender")) { //allow for ?sender; used by some users due to error in old documentation
            //ignore for now
            final String sender_id;
            if (name.equals("sender"))
                sender_id = "sender " + getParameters.getFirstValue("sender");
            else
                sender_id = "sender " + getParameters.getFirstValue("?sender");
        }
    }

    return getSingleOpenTest(openUUID, verboseLevel);

}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:32,代码来源:OpenTestResource.java

示例14: retrieve

import org.restlet.data.Form; //导入方法依赖的package包/类
@Get("json")
public Map<String, List<String>> retrieve() {
    IOFSwitchService switchService =
            (IOFSwitchService) getContext().getAttributes().
                get(IOFSwitchService.class.getCanonicalName());
    ITopologyService topologyService =
            (ITopologyService) getContext().getAttributes().
                get(ITopologyService.class.getCanonicalName());

    Form form = getQuery();
    String queryType = form.getFirstValue("type", true);
    boolean openflowDomain = true;
    if (queryType != null && "l2".equals(queryType)) {
        openflowDomain = false;
    }

    Map<String, List<String>> switchClusterMap = new HashMap<String, List<String>>();
    for (DatapathId dpid: switchService.getAllSwitchDpids()) {
        DatapathId clusterDpid =
                (openflowDomain
                 ? topologyService.getOpenflowDomainId(dpid)
                 :topologyService.getOpenflowDomainId(dpid));
        List<String> switchesInCluster = switchClusterMap.get(clusterDpid.toString());
        if (switchesInCluster != null) {
            switchesInCluster.add(dpid.toString());
        } else {
            List<String> l = new ArrayList<String>();
            l.add(dpid.toString());
            switchClusterMap.put(clusterDpid.toString(), l);
        }
    }
    return switchClusterMap;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:34,代码来源:SwitchClustersResource.java

示例15: retrieve

import org.restlet.data.Form; //导入方法依赖的package包/类
@Get("json")
public Map<String, List<String>> retrieve() {
    IOFSwitchService switchService =
            (IOFSwitchService) getContext().getAttributes().
                get(IOFSwitchService.class.getCanonicalName());
    ITopologyService topologyService =
            (ITopologyService) getContext().getAttributes().
                get(ITopologyService.class.getCanonicalName());

    Form form = getQuery();
    String queryType = form.getFirstValue("type", true);
    boolean openflowDomain = true;
    if (queryType != null && "l2".equals(queryType)) {
        openflowDomain = false;
    }

    Map<String, List<String>> switchClusterMap = new HashMap<String, List<String>>();
    for (DatapathId dpid: switchService.getAllSwitchDpids()) {
        DatapathId clusterDpid =
                (openflowDomain
                 ? topologyService.getOpenflowDomainId(dpid)
                 :topologyService.getL2DomainId(dpid));
        List<String> switchesInCluster = switchClusterMap.get(clusterDpid.toString());
        if (switchesInCluster != null) {
            switchesInCluster.add(dpid.toString());
        } else {
            List<String> l = new ArrayList<String>();
            l.add(dpid.toString());
            switchClusterMap.put(clusterDpid.toString(), l);
        }
    }
    return switchClusterMap;
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:34,代码来源:SwitchClustersResource.java


注:本文中的org.restlet.data.Form.getFirstValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。