Java Code Examples for org.restlet.data.Form

The following examples show how to use org.restlet.data.Form. These examples are extracted from open source projects. 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 Project: springboot-shiro-cas-mybatis   Source File: TicketResource.java    License: MIT License 6 votes vote down vote up
/**
 * Obtain credentials from the request.
 *
 * @return the credential
 */
protected Credential obtainCredentials() {
    final UsernamePasswordCredential c = new UsernamePasswordCredential();
    final WebRequestDataBinder binder = new WebRequestDataBinder(c);
    final RestletWebRequest webRequest = new RestletWebRequest(getRequest());

    final Form form = new Form(getRequest().getEntity());
    logFormRequest(form);

    if (!form.isEmpty()) {
        binder.bind(webRequest);
        return c;
    }
    LOGGER.trace("Failed to bind the request to credentials. Resulting form is empty");
    return null;
}
 
Example 2
Source Project: open-rmbt   Source File: ChoicesResource.java    License: Apache License 2.0 6 votes vote down vote up
@Get("json")
public String request(final String entity) throws JSONException
{
    QueryParser qp = new QueryParser();
    Form parameters = getRequest().getResourceRef().getQueryAsForm();
    qp.parseQuery(parameters);
    
    List<String> fields = Arrays.asList(new String[]{"country_geoip"});
 
    final JSONObject answer = new JSONObject();
    final JSONArray countries = new JSONArray(queryDB("upper(msim.country)", "t.mobile_network_id", "mccmnc2name msim ON msim.uid", qp));
    final JSONArray provider = new JSONArray(queryDB("mprov.name", "t.mobile_provider_id", "provider mprov ON mprov.uid", qp));
    final JSONArray providerN = new JSONArray(queryDB("prov.name", "t.provider_id", "provider prov ON prov.uid", qp));
    
    
    
    answer.put("country_mobile", countries);
    answer.put("provider_mobile", provider);
    answer.put("provider", providerN);
    
    return answer.toString();
}
 
Example 3
Source Project: cas4.0.x-server-wechat   Source File: TicketResource.java    License: Apache License 2.0 6 votes vote down vote up
private void logFormRequest(final Form form) {
    if (LOGGER.isDebugEnabled()) {
        final Set<String> pairs = new HashSet<String>();
        for (final String name : form.getNames()) {
            final StringBuilder builder = new StringBuilder();
            builder.append(name);
            builder.append(": ");
            if (!"password".equalsIgnoreCase(name)) {
                builder.append(form.getValues(name));
            } else {
                builder.append("*****");
            }
            pairs.add(builder.toString());
        }
        LOGGER.debug(StringUtils.join(pairs, ", "));
    }
}
 
Example 4
Source Project: ipst   Source File: ITeslaStatsResource.java    License: Mozilla Public License 2.0 6 votes vote down vote up
@Get("csv")
public Object getRepresentation() {

    if (ds == null) {
        getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
        return null;
    }

    if (!ds.getStatus().isInitialized()) {
        getResponse().setStatus(Status.SUCCESS_ACCEPTED);
        return "Initializing...";
    }

    Form queryForm = getRequest().getOriginalRef().getQueryAsForm();
    char delimiter = queryForm.getFirstValue("delimiter", ",").charAt(0);

    return new CsvRepresentation(getStats(), true, delimiter);
}
 
Example 5
Source Project: ipst   Source File: ITeslaDataResource.java    License: Mozilla Public License 2.0 6 votes vote down vote up
@Override
protected ColumnDescriptor[] subsetColumns(ColumnDescriptor[] columns, Form queryForm) {
    ColumnDescriptor[] cols = super.subsetColumns(columns, queryForm);

    for (int i=0;i<cols.length;i++) {
        ColumnDescriptor cd = cols[i];
        if (cd.getName().endsWith("_PP") && !(cd instanceof FunctionalColumn)) {
            cols[i] = new StrictlyPositive(cd.getName().substring(0, cd.getName().length()-1));
        } else if (cd.getName().endsWith("_PN") && !(cd instanceof FunctionalColumn)) {
            cols[i] = new StrictlyNegative(cd.getName().substring(0, cd.getName().length()-1));
        } else if (cd.getName().endsWith("_IP") && !(cd instanceof FunctionalColumn)) {
            cols[i] = new CurrentPowerRatio(cd.getName().substring(0, cd.getName().length()-3));
        }
    }

    return cols;
}
 
Example 6
Source Project: DeviceConnect-Android   Source File: FormUtils.java    License: MIT License 6 votes vote down vote up
/**
 * Parses a post into a given form.
 * 
 * @param form
 *            The target form.
 * @param post
 *            The posted form.
 * @param decode
 *            Indicates if the parameters should be decoded.
 */
public static void parse(Form form, Representation post, boolean decode) {
    if (post != null) {
        if (post.isAvailable()) {
            FormReader fr = null;

            try {
                fr = new FormReader(post, decode);
            } catch (IOException ioe) {
                Context.getCurrentLogger().log(Level.WARNING,
                        "Unable to create a form reader. Parsing aborted.",
                        ioe);
            }

            if (fr != null) {
                fr.addParameters(form);
            }
        } else {
            Context.getCurrentLogger()
                    .log(Level.FINE,
                            "The form wasn't changed as the given representation isn't available.");
        }
    }
}
 
Example 7
Source Project: DeviceConnect-Android   Source File: FormReader.java    License: MIT License 6 votes vote down vote up
/**
 * Reads all the parameters.
 * 
 * @return The form read.
 * @throws IOException
 *             If the parameters could not be read.
 */
public Form read() throws IOException {
    Form result = new Form();

    if (this.stream != null) {
        Parameter param = readNextParameter();

        while (param != null) {
            result.add(param);
            param = readNextParameter();
        }

        this.stream.close();
    }

    return result;
}
 
Example 8
Source Project: DeviceConnect-Android   Source File: AccessTokenServerResource.java    License: MIT License 6 votes vote down vote up
/**
     * Handles the {@link Post} request. The client MUST use the HTTP "POST"
     * method when making access token requests. (3.2. Token Endpoint)
     * 
     * @param input
     *            HTML form formated token request per oauth-v2 spec.
     * @return JSON response with token or error.<br>
     * 			※Local OAuth ではResultRepresentation型のポインタを返す。<br>
     * 			getResult()=trueならアクセストークンが含まれている。アクセストークンはgetText()で取得する。<br>
     * 			getResult()=falseならエラー。アクセストークンは取得できない。<br>
     */
    public static Representation requestToken(Representation input)
            throws OAuthException, JSONException {
        getLogger().fine("Grant request");
        final Form params = new Form(input);

        final GrantType grantType = getGrantType(params);
        switch (grantType) {
        case authorization_code:
            getLogger().info("Authorization Code Grant");
            return doAuthCodeFlow(params);
//        case password:
//        	getLogger().info("Resource Owner Password Credentials Grant");
//            return doPasswordFlow(params);
//        case client_credentials:
//        	getLogger().info("Client Credentials Grantt");
//            return doClientFlow(params);
//        case refresh_token:
//        	getLogger().info("Refreshing an Access Token");
//            return doRefreshFlow(params);
        default:
            getLogger().warning("Unsupported flow: " + grantType);
            throw new OAuthException(OAuthError.unsupported_grant_type,
                    "Flow not supported", null);
        }
    }
 
Example 9
Source Project: DeviceConnect-Android   Source File: OAuthServerResource.java    License: MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example 10
Source Project: FoxBPM   Source File: FlowGraphicPositionResource.java    License: Apache License 2.0 6 votes vote down vote up
@Get
public DataResult getPositionInfor() {
	Form query = getQuery();
	String processDefinitionId = getQueryParameter("processDefinitionId", query);
	if (StringUtil.isEmpty(processDefinitionId)) {
		throw new FoxbpmPluginException("流程定义唯一编号为空", "Rest服务");
	}
	ProcessEngine processEngine = FoxBpmUtil.getProcessEngine();
	ModelService modelService = processEngine.getModelService();
	Map<String, Map<String, Object>> positionInfor = modelService.getFlowGraphicsElementPositionById(processDefinitionId);
	Map<String, Object> resultData = new HashMap<String, Object>();
	resultData.put("positionInfor", positionInfor);
	DataResult result = new DataResult();
	result.setData(resultData);
	return result;
	
}
 
Example 11
Source Project: FoxBPM   Source File: AbstractRestResource.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 初始化分页处理
 */
protected void initPage() {
	Form queryForm = getQuery();
	Set<String> queryNames = queryForm.getNames();
	if (queryNames.contains(RestConstants.PAGE_START)) {
		if (queryNames.contains(RestConstants.PAGE_LENGTH)) {
			pageSize = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_LENGTH, queryForm));
		}
		pageIndex = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_START, queryForm)) / pageSize + 1;
	}
	
	if (queryNames.contains(RestConstants.PAGE_INDEX)) {
		pageIndex = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_INDEX, queryForm));
	}
	if (queryNames.contains(RestConstants.PAGE_SIZE)) {
		pageSize = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_SIZE, queryForm));
	}
}
 
Example 12
Source Project: FoxBPM   Source File: RequestUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static Date getDate(Form form, String name) {
	Date value = null;
	if (form.getValues(name) != null) {

		String input = form.getValues(name);

		// this is zero time so we need to add that TZ indicator for
		if (input.endsWith("Z")) {
			input = input.substring(0, input.length() - 1) + "GMT-00:00";
		} else {
			int inset = 6;

			String s0 = input.substring(0, input.length() - inset);
			String s1 = input.substring(input.length() - inset, input.length());

			input = s0 + "GMT" + s1;
		}

		try {
			value = longDateFormat.parse(input);
		} catch (Exception e) {
			throw new FoxbpmPluginException("Failed to parse date " + input,"Rest服务");
		}
	}
	return value;
}
 
Example 13
Source Project: FoxBPM   Source File: AbstractRestResource.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 初始化分页处理
 */
protected void initPage() {
	Form queryForm = getQuery();
	Set<String> queryNames = queryForm.getNames();
	if (queryNames.contains(RestConstants.PAGE_START)) {
		if (queryNames.contains(RestConstants.PAGE_LENGTH)) {
			pageSize = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_LENGTH, queryForm));
		}
		pageIndex = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_START, queryForm)) / pageSize + 1;
	}
	
	if (queryNames.contains(RestConstants.PAGE_INDEX)) {
		pageIndex = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_INDEX, queryForm));
	}
	if (queryNames.contains(RestConstants.PAGE_SIZE)) {
		pageSize = StringUtil.getInt(getQueryParameter(RestConstants.PAGE_SIZE, queryForm));
	}
}
 
Example 14
Source Project: helix   Source File: JsonParameters.java    License: Apache License 2.0 6 votes vote down vote up
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);
  }
}
 
Example 15
Source Project: cas4.0.x-server-wechat   Source File: TicketResource.java    License: Apache License 2.0 5 votes vote down vote up
protected Credential obtainCredentials() {
    final UsernamePasswordCredential c = new UsernamePasswordCredential();
    final WebRequestDataBinder binder = new WebRequestDataBinder(c);
    final RestletWebRequest webRequest = new RestletWebRequest(getRequest());

    logFormRequest(new Form(getRequest().getEntity()));
    binder.bind(webRequest);

    return c;
}
 
Example 16
Source Project: ipst   Source File: IteslaDataListResource.java    License: Mozilla Public License 2.0 5 votes vote down vote up
@Post("form:html")
public Object postCimDirectory(Form queryForm) throws IOException {

    if (queryForm == null)
        queryForm = getRequest().getOriginalRef().getQueryAsForm();

    if (dataId == null || storeId == null) {
        throw new IllegalArgumentException("Missing datasource or store id");
    } else {

        ITeslaDatastore store = (ITeslaDatastore) getApplication().getDataService().getDataStore(storeId);
        if (store == null) {
            getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
            return "Datastore does not exist: " + storeId;
        }

        ITeslaDatasource ds = store.getDataSource(dataId);
        if (ds == null) {
            ds = store.createDataSource(dataId);
        }
        boolean parallel = queryForm.getFirstValue("parallel") != null
                ? Boolean.valueOf(queryForm.getFirstValue("parallel")) : true;
        CimHistoImporter importer = new CimHistoImporter(ds);
        importer.addCim(new File(queryForm.getFirstValue("dir")), parallel);

        ds.persistState();
    }

    return null;
}
 
Example 17
Source Project: ipst   Source File: ITeslaRules.java    License: Mozilla Public License 2.0 5 votes vote down vote up
@Get("json")
public Object getRepresentation() throws Exception{

    Form queryForm = getRequest().getOriginalRef().getQueryAsForm();
    String workflowId = queryForm.getFirstValue("workflowId", true, null);
    String startStr = queryForm.getFirstValue("start", "0");
    String countStr = queryForm.getFirstValue("count", "50");

    Map<String, Object> query = new HashMap();
    if (algoType != null) query.put("algoType", algoType);
    if (contingencyId != null) query.put("contingencyId", contingencyId);
    if (indexType != null) query.put("indexType", indexType);
    if (workflowId != null) query.put("workflowId", workflowId);

    Dataset set = datasource.getData(query,
            Integer.parseInt(startStr),
            Integer.parseInt(countStr),
            ColumnDescriptor.getDescriptorsForNames("algoType", "contingencyId", "indexType", "workflowId", "quality", "treeSize", "criticality", "tree"));
    Iterator<Collection> it = set.getRowIterator();

    JSONArray result = new JSONArray();

    while (it.hasNext()) {
        Object[] values = it.next().toArray();
        JSONObject ruleObj = new JSONObject();
        ruleObj.put("algoType", values[0]);
        ruleObj.put("contingencyId", values[1]);
        ruleObj.put("indexType", values[2]);
        ruleObj.put("workflowId", values[3]);
        ruleObj.put("quality", values[4]);
        ruleObj.put("treeSize", values[5]);
        ruleObj.put("criticality", values[6]);
        ruleObj.put("tree", new JSONObject((String)values[7]));
        result.put(ruleObj);
    }

    return result;
}
 
Example 18
Source Project: ipst   Source File: ITeslaRules.java    License: Mozilla Public License 2.0 5 votes vote down vote up
@Get("cond")
public String getTreeConditions() throws Exception{

    Form queryForm = getRequest().getOriginalRef().getQueryAsForm();
    String workflowId = queryForm.getFirstValue("workflowId", true, null);

    Map<String, Object> query = new HashMap();
    if (algoType != null) query.put("algoType", algoType);
    if (contingencyId != null) query.put("contingencyId", contingencyId);
    if (indexType != null) query.put("indexType", indexType);
    if (workflowId != null) query.put("workflowId", workflowId);

    Dataset set = datasource.getData(query,
            0,
            -1,
            ColumnDescriptor.getDescriptorsForNames("tree"));
    Iterator<Collection> it = set.getRowIterator();

    StringBuffer conditions = new StringBuffer();

    while (it.hasNext()) {
        Object[] values = it.next().toArray();
        JSONObject jsonTreeDescr = new JSONObject((String)values[0]);

        processJsonTree(jsonTreeDescr, conditions);
    }

    return conditions.toString();
}
 
Example 19
Source Project: uReplicator   Source File: AdminRestletResource.java    License: Apache License 2.0 5 votes vote down vote up
@Delete
public Representation delete() {
  final String opt = (String) getRequest().getAttributes().get("opt");
  JSONObject responseJson = new JSONObject();
  if ("worker_number_override".equalsIgnoreCase(opt)) {
    Form queryParams = getRequest().getResourceRef().getQueryAsForm();
    String routeString = queryParams.getFirstValue("route", true);
    if (StringUtils.isEmpty(routeString)) {
      getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
      responseJson.put("status", Status.CLIENT_ERROR_BAD_REQUEST.getCode());
      responseJson.put("message", String.format("missing parameter route"));
    } else {
      if (_helixMirrorMakerManager.getRouteWorkerOverride().containsKey(routeString)) {
        _helixMirrorMakerManager.updateRouteWorkerOverride(routeString, -1);
        responseJson.put("worker_number_override", _helixMirrorMakerManager.getRouteWorkerOverride());
        responseJson.put("status", Status.SUCCESS_OK.getCode());
      } else {
        responseJson.put("message", String.format("route override not exists"));
        responseJson.put("status", Status.SUCCESS_OK.getCode());
      }
    }
  } else {
    LOGGER.info("No valid input!");
    responseJson.put("opt", "No valid input!");
  }
  return new StringRepresentation(responseJson.toJSONString());
}
 
Example 20
Source Project: geowave   Source File: RequestParametersFormTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void instantiationSuccessfulWithForm() throws Exception {
  final Map<String, String> testKVP = new HashMap<>();

  final Form form = mockedForm(testKVP);

  classUnderTest = new RequestParametersForm(form);
}
 
Example 21
/**
 * Get request parameter "response_type".
 * 
 * @param params
 * @return
 * @throws OAuthException
 */
protected static ResponseType[] getResponseType(Form params) throws OAuthException {
    String responseType = params.getFirstValue(RESPONSE_TYPE);
    if (responseType == null || responseType.isEmpty()) {
        throw new OAuthException(OAuthError.invalid_request,
                "No response_type parameter found.", null);
    }
    /*
     * Extension response types MAY contain a space-delimited (%x20) list of
     * values (3.1.1. Response Type)
     */
    String[] typesString = Scopes.parseScope(responseType); // The same
                                                            // format as
                                                            // scope.
    ResponseType[] types = new ResponseType[typesString.length];

    for (int i = 0; i < typesString.length; i++) {
        try {
            ResponseType type = Enum.valueOf(ResponseType.class,
                    typesString[i]);
            getLogger().fine("Found flow - " + type);
            types[i] = type;
        } catch (IllegalArgumentException iae) {
            throw new OAuthException(OAuthError.unsupported_response_type,
                    "Unsupported flow", null);
        }
    }

    return types;
}
 
Example 22
Source Project: geowave   Source File: RequestParametersForm.java    License: Apache License 2.0 5 votes vote down vote up
public RequestParametersForm(final Form form) {
  super();
  for (final String key : form.getNames()) {
    // For each parameter in the form, add the parameter name and value
    // to the Map<String, Object>.
    keyValuePairs.put(key, form.getFirst(key).getValue());
  }
}
 
Example 23
Source Project: DeviceConnect-Android   Source File: AccessTokenServerResource.java    License: MIT License 5 votes vote down vote up
/**
 * Get request parameter "code".
 * 
 * @param params
 * @return
 * @throws OAuthException
 */
protected static String getCode(Form params) throws OAuthException {
    String code = params.getFirstValue(CODE);
    if (code == null || code.isEmpty()) {
        throw new OAuthException(OAuthError.invalid_request,
                "Mandatory parameter code is missing", null);
    }
    return code;
}
 
Example 24
Source Project: DeviceConnect-Android   Source File: AccessTokenServerResource.java    License: MIT License 5 votes vote down vote up
/**
 * Get request parameter "redirect_uri".
 * 
 * @param params
 * @return
 * @throws OAuthException
 */
protected static String getRedirectURI(Form params) throws OAuthException {
    String redirUri = params.getFirstValue(REDIR_URI);
    if (redirUri == null || redirUri.isEmpty()) {
        throw new OAuthException(OAuthError.invalid_request,
                "Mandatory parameter redirect_uri is missing", null);
    }
    return redirUri;
}
 
Example 25
Source Project: DeviceConnect-Android   Source File: AccessTokenServerResource.java    License: MIT License 5 votes vote down vote up
protected static String getApplicationName(Form params) throws OAuthException {
    String base64ApplicationName = params.getFirstValue(APPLICATION_NAME);
    String applicationName = new String(Base64.decode(base64ApplicationName, Base64.URL_SAFE|Base64.NO_WRAP));
    if (applicationName == null || applicationName.isEmpty()) {
        throw new OAuthException(OAuthError.invalid_request,
                "Mandatory parameter application_name is missing", null);
    }
    return applicationName;
}
 
Example 26
Source Project: DeviceConnect-Android   Source File: OAuthServerResource.java    License: MIT License 5 votes vote down vote up
/**
 * Get request parameter "scope".
 * 
 * @param params
 * @return
 * @throws OAuthException
 */
protected static String[] getScope(Form params) throws OAuthException {
    String scope = params.getFirstValue(SCOPE);
    if (scope == null || scope.isEmpty()) {
        
    	/*
要求するときにクライアントがスコープパラメータを省略した場合は 
承認、認可サーバーは処理しなければならないのどちらか 
事前に定義されたデフォルト値を使用して要求するか、要求を失敗 
無効な範囲を示す...(ドラフト-IETF-OAuthの-V2-303.3。)
    	 */
    	/*
         * If the client omits the scope parameter when requesting
         * authorization, the authorization server MUST either process the
         * request using a pre-defined default value, or fail the request
         * indicating an invalid scope... (draft-ietf-oauth-v2-30 3.3.)
         */
        Object defaultScope = getResourceContext().getAttributes().get(
                PARAMETER_DEFAULT_SCOPE);
        if (defaultScope == null || defaultScope.toString().isEmpty()) {
            throw new OAuthException(OAuthError.invalid_scope,
                    "Scope has not provided.", null);
        }
        scope = defaultScope.toString();
    }
    return Scopes.parseScope(scope);
}
 
Example 27
@Get("json")
public Map<String, List<String>> retrieve() {
    IFloodlightProviderService floodlightProvider =
            (IFloodlightProviderService)getContext().getAttributes().
                get(IFloodlightProviderService.class.getCanonicalName());
    ITopologyService topology =
            (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 (Long dpid: floodlightProvider.getAllSwitchDpids()) {
        Long clusterDpid =
                (openflowDomain
                 ? topology.getOpenflowDomainId(dpid)
                 :topology.getL2DomainId(dpid));
        List<String> switchesInCluster = switchClusterMap.get(HexString.toHexString(clusterDpid));
        if (switchesInCluster != null) {
            switchesInCluster.add(HexString.toHexString(dpid));
        } else {
            List<String> l = new ArrayList<String>();
            l.add(HexString.toHexString(dpid));
            switchClusterMap.put(HexString.toHexString(clusterDpid), l);
        }
    }
    return switchClusterMap;
}
 
Example 28
Source Project: attic-polygene-java   Source File: ContextResource.java    License: Apache License 2.0 5 votes vote down vote up
private String getValue( String name, Form queryAsForm, Form entityAsForm )
{
    String value = queryAsForm.getFirstValue( name );
    if( value == null )
    {
        value = entityAsForm.getFirstValue( name );
    }
    return value;
}
 
Example 29
Source Project: attic-polygene-java   Source File: DefaultRequestReader.java    License: Apache License 2.0 5 votes vote down vote up
private String getValue( String name, Form queryAsForm, Form entityAsForm )
{
    String value = queryAsForm.getFirstValue( name );
    if( value == null )
    {
        value = entityAsForm.getFirstValue( name );
    }
    return value;
}
 
Example 30
Source Project: attic-polygene-java   Source File: SPARQLResource.java    License: Apache License 2.0 5 votes vote down vote up
private Value parseValueParam( Repository repository, Form form, String parameterName )
    throws ResourceException
{
    String paramValue = form.getFirstValue( parameterName );
    try
    {
        return Protocol.decodeValue( paramValue, repository.getValueFactory() );
    }
    catch( IllegalArgumentException e )
    {
        throw new ResourceException( Status.CLIENT_ERROR_BAD_REQUEST, "Invalid value for parameter '" + parameterName + "': "
                                                                      + paramValue );
    }
}