List of usage examples for java.lang String toString
public String toString()
From source file:com.phonty.improved.Register.java
private String parse(String response) { String value = ""; try {// w ww .j a va 2 s . c o m JSONObject jsonObject = new JSONObject(response.toString()); value = jsonObject.getString("status"); } catch (Exception e) { e.printStackTrace(); } STATUS = value; return value; }
From source file:com.haythem.integration.CustomSerializerDeserializer.java
private int parseOrderNumber(InputStream inputStream) throws IOException { String value = parseString(inputStream, ORDER_NUMBER_LENGTH); return Integer.valueOf(value.toString()); }
From source file:com.googlecode.lineblog.websocket.v2.TokenManage.java
public String[] getTokenUsers() { int len = us.size();//? String[] list = new String[len]; int i = 0;//from w w w . j av a 2 s. c o m for (String s : us.keySet()) { list[i] = s.toString(); i++; if (i >= len) break; } return list; }
From source file:com.amazonaws.services.cloudtrail.processinglibrary.serializer.DefaultSourceSerializer.java
/** * This method may modify original sqsMessage's attributes. */// w w w.ja v a 2 s. co m @Override public CloudTrailSource getSource(Message sqsMessage) throws IOException { List<CloudTrailLog> cloudTrailLogs = new ArrayList<>(); List<String> objectKeys = new ArrayList<String>(); String bucketName = null; String accountId = null; String messageText = this.mapper.readTree(sqsMessage.getBody()).get(MESSAGE).textValue(); JsonNode messageNode = this.mapper.readTree(messageText); // parse message body Iterator<String> it = messageNode.fieldNames(); while (it.hasNext()) { String key = it.next(); String value = messageNode.path(key).textValue(); if (S3_BUCKET.equals(key)) { bucketName = value; } else if (S3_OBJECT_KEY.equals(key)) { objectKeys = this.mapper.readValue(messageNode.get(S3_OBJECT_KEY).traverse(), new TypeReference<List<String>>() { }); } else { // rest of attributes from message body will be added to SQS message's attributes. sqsMessage.addAttributesEntry(key, value); } } for (String objectKey : objectKeys) { accountId = accountId == null ? LibraryUtils.extractAccountIdFromObjectKey(objectKey.toString()) : accountId; cloudTrailLogs.add(new CloudTrailLog(bucketName, objectKey)); } //set accountId as message attribute sqsMessage.addAttributesEntry(SourceAttributeKeys.ACCOUNT_ID.getAttributeKey(), accountId); return new SQSBasedSource(sqsMessage, cloudTrailLogs); }
From source file:com.jaspersoft.jasperserver.ps.OAuth.OAuthAccessTokenValidator.java
private String checkAuthenticationToken(Object ssoToken) { if (ssoToken == null) throw new AuthenticationServiceException("No SSO information available"); //cast auth token correctly OAuthAuthenticationToken mytoken = (OAuthAuthenticationToken) ssoToken; //get and check for sessiondata from token and throw exception if not available String ticket = (String) mytoken.getAccessToken(); if (ticket == null || "".equals(ticket.toString().trim())) throw new AuthenticationServiceException("No SSO authtoken"); String username = (String) mytoken.getPrincipal(); //get and check for u from token and throw exception if not available if (username == null || "".equals(username.toString().trim())) { log.debug("No username passed"); throw new AuthenticationServiceException("No username passed"); }//from w w w . j a v a 2 s .c om return ticket; }
From source file:org.venice.beachfront.bfapi.services.GeoServerProxyService.java
public ResponseEntity<byte[]> proxyRequest(HttpServletRequest request) throws MalformedURLException, IOException, URISyntaxException, UserException { String requestPath = request.getRequestURI(); // Form the complete URI by piecing together the GeoServer URL with the API proxy request parameters URI requestUri = new URI(geoserverUrl.getProtocol(), null, geoserverUrl.getHost(), geoserverUrl.getPort(), requestPath, request.getQueryString(), null); // Double encoding takes place here. First, in the REST Request delivered to API by the client. Second, in the // translation to the URI object. Decode both of these steps to get the real, completely decoded request to // GeoServer. String decodedUrl = URLDecoder.decode(requestUri.toString(), "UTF-8"); decodedUrl = URLDecoder.decode(decodedUrl.toString(), "UTF-8"); piazzaLogger.log(String.format("Proxying request to GET GeoServer at URI %s", decodedUrl), Severity.INFORMATIONAL); try {//from w w w. ja va 2 s .c om ResponseEntity<byte[]> response = restTemplate.exchange(decodedUrl, HttpMethod.GET, requestHeaders, byte[].class); return response; } catch (HttpClientErrorException | HttpServerErrorException exception) { piazzaLogger.log(String.format("Received GeoServer error response, code=%d, length=%d, for URI %s", exception.getStatusCode().value(), exception.getResponseBodyAsString().length(), decodedUrl), Severity.ERROR); if (exception.getStatusCode().equals(HttpStatus.UNAUTHORIZED) || exception.getStatusCode().equals(HttpStatus.FORBIDDEN)) { throw new UserException("Bad Authentication with GeoServer", exception, exception.getResponseBodyAsString(), HttpStatus.BAD_REQUEST); } throw new UserException("Upstream GeoServer error", exception, exception.getResponseBodyAsString(), exception.getStatusCode()); } }
From source file:cc.recommenders.io.IoUtilsTest.java
@Test public void randomFileIsSubfolderOfTmp() throws IOException { String actual = sut.getRandomTempFile(); String expected = File.createTempFile(IoUtils.TEMP_PREFIX, "").getAbsolutePath(); int len = expected.toString().indexOf(IoUtils.TEMP_PREFIX); String actual2 = actual.substring(0, len); String expected2 = expected.substring(0, len); assertEquals(expected2, actual2);/*from w ww .j av a2s .co m*/ }
From source file:eu.stratosphere.pact.test.pactPrograms.MergeOnlyJoinITCase.java
private String[] splitInputString(String inputString, char splitChar, int noSplits) { String splitString = inputString.toString(); String[] splits = new String[noSplits]; int partitionSize = (splitString.length() / noSplits) - 2; // split data file and copy parts for (int i = 0; i < noSplits - 1; i++) { int cutPos = splitString.indexOf(splitChar, (partitionSize < splitString.length() ? partitionSize : (splitString.length() - 1))); if (cutPos != -1) { splits[i] = splitString.substring(0, cutPos) + "\n"; splitString = splitString.substring(cutPos + 1); } else {// w w w.ja va2 s. c om splits[i] = ""; } } splits[noSplits - 1] = splitString; return splits; }
From source file:genepi.db.JdbcDataAccessObject.java
public int update(String sql, Object[] params) throws SQLException { return runner.update(sql.toString(), params); }
From source file:genepi.db.JdbcDataAccessObject.java
public int[] batch(String sql, Object[][] params) throws SQLException { return runner.batch(sql.toString(), params); }