List of usage examples for java.lang Long MAX_VALUE
long MAX_VALUE
To view the source code for java.lang Long MAX_VALUE.
Click Source Link
From source file:pl.psnc.synat.wrdz.zmd.download.adapters.HttpDownloadAdapter.java
@Override public String downloadFile(URI uri, String relativePath) throws DownloadAdapterException { String cachedFilePath = getResourceCachePath(relativePath); checkDestinationExistence(cachedFilePath); DefaultHttpClient httpclient = new DefaultHttpClient(); ReadableByteChannel rbc = null; FileOutputStream output = null; try {/*from ww w .j a v a2s . c o m*/ if (usernamePasswordCredentials != null) { httpclient.getCredentialsProvider().setCredentials(authScope, usernamePasswordCredentials); } HttpResponse response = httpclient.execute(new HttpGet(uri)); HttpEntity entity = response.getEntity(); if (entity != null && response.getStatusLine().getStatusCode() == 200) { rbc = Channels.newChannel(entity.getContent()); output = new FileOutputStream(cachedFilePath); output.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); EntityUtils.consume(entity); } else { EntityUtils.consume(entity); throw new DownloadAdapterException( "Http error code or empty content was returned instead of resource."); } } catch (IOException e) { throw new DownloadAdapterException("Exception caught while downloading file contents to the cache.", e); } finally { httpclient.getConnectionManager().shutdown(); try { if (rbc != null) { rbc.close(); } if (output != null) { output.close(); } } catch (IOException e) { throw new DownloadAdapterException("Exception caught while closing input/output streams.", e); } } return cachedFilePath; }
From source file:com.twitter.hraven.HdfsStatsKey.java
/** * returns the run id based on the encoded run id */ public long getRunId() { return Long.MAX_VALUE - this.encodedRunId; }
From source file:info.archinnov.achilles.it.TestNativeQueries.java
@Test public void should_perform_prepared_native_query() throws Exception { //Given/* ww w .j a v a 2 s . co m*/ final Long id = RandomUtils.nextLong(0L, Long.MAX_VALUE); scriptExecutor.executeScriptTemplate("SimpleEntity/insert_single_row.cql", ImmutableMap.of("id", id, "table", "simple")); final PreparedStatement preparedStatement = session.prepare("SELECT * FROM simple WHERE id = :id"); //When final TypedMap actual = manager.query().nativeQuery(preparedStatement, id).getOne(); //Then assertThat(actual).isNotNull(); assertThat(actual.<String>getTyped("value")).contains("0 AM"); }
From source file:org.nuvola.tvshowtime.ApplicationLauncher.java
@Scheduled(fixedDelay = Long.MAX_VALUE) public void init() { tvShowTimeTemplate = new RestTemplate(); File storeToken = new File(tvShowTimeConfig.getTokenFile()); if (storeToken.exists()) { try {//from ww w . j a va2 s.c o m FileInputStream fileInputStream = new FileInputStream(storeToken); ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream); accessToken = (AccessToken) objectInputStream.readObject(); objectInputStream.close(); fileInputStream.close(); LOG.info("AccessToken loaded from file with success : " + accessToken); } catch (Exception e) { LOG.error("Error parsing the AccessToken stored in 'session_token'."); LOG.error("Please remove the 'session_token' file, and try again."); LOG.error(e.getMessage()); System.exit(1); } try { processWatchedEpisodes(); } catch (Exception e) { LOG.error("Error during marking episodes as watched."); LOG.error(e.getMessage()); System.exit(1); } } else { requestAccessToken(); } }
From source file:com.alehuo.wepas2016projekti.controller.ImageController.java
/** * Hakee tietokannasta kuvan. Kuvan hakemisessa hydynnetn ETag * -otsaketta./*from ww w.j ava 2s. c om*/ * * @param a Autentikointi * @param imageUuid Kuvan UUID * @param ifNoneMatch If-None-Match -headeri vlimuistia varten * @return Kuva */ @RequestMapping(value = "/{imageUuid}", method = RequestMethod.GET) @ResponseBody public ResponseEntity<byte[]> getImage(Authentication a, @PathVariable String imageUuid, @RequestHeader(required = false, value = "If-None-Match") String ifNoneMatch) { if (ifNoneMatch != null) { // LOG.log(Level.INFO, "Kuva ''{0}'' loytyy kayttajan selaimen valimuistista eika sita tarvitse ladata. Kuvaa pyysi kayttaja ''{1}''", new Object[]{imageUuid, a.getName()}); //Jos If-None-Match -headeri lytyy, niin lhet NOT MODIFIED vastaus return new ResponseEntity<>(HttpStatus.NOT_MODIFIED); } Image i = imageService.findOneImageByUuid(imageUuid); if (i != null && i.isVisible()) { //Luodaan ETag kuvalle final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.parseMediaType(i.getContentType())); headers.setContentLength(i.getImageData().length); headers.setCacheControl("public"); headers.setExpires(Long.MAX_VALUE); headers.setETag("\"" + imageUuid + "\""); // LOG.log(Level.INFO, "Kuva ''{0}'' loytyi tietokannasta, ja sita pyysi kayttaja ''{1}''", new Object[]{imageUuid, a.getName()}); //Palautetaan kuva uutena resurssina return new ResponseEntity<>(i.getImageData(), headers, HttpStatus.CREATED); } else { //Jos kuvaa ei lydy tietokannasta LOG.log(Level.WARNING, "Kuvaa ''{0}'' ei loytynyt tietokannasta, ja sita pyysi kayttaja ''{1}''", new Object[] { imageUuid, a.getName() }); return new ResponseEntity<>(HttpStatus.NOT_FOUND); } }
From source file:org.vincibean.salestaxes.service.PoiuytServiceTest.java
/** * Test that, given a not existing ID, method findPoiuytById() will not return any Poiuyt. *///from w ww . j av a2s . co m @Test public void testFindPoiuytByNotExistingId() { Optional<Poiuyt> optionalPoiuyt = poiuytService.findPoiuytById(Long.MAX_VALUE); Assert.assertFalse(optionalPoiuyt.isPresent()); }
From source file:jp.primecloud.auto.api.ApiValidate.java
public static void validateInstanceNo(String instanceNo) { ValidateUtil.required(instanceNo, "EAPI-000001", new Object[] { PARAM_NAME_INSTANCE_NO }); ValidateUtil.longInRange(instanceNo, 1, Long.MAX_VALUE, "EAPI-000002", new Object[] { PARAM_NAME_INSTANCE_NO, 1, Long.MAX_VALUE }); }
From source file:control.services.DownloadPortraitsHttpServiceImpl.java
@Override public File downloadPortraisFile(String portraitsFileName, String portraitsFolderName) throws FileNotFoundException { File file = null;//from w w w .j av a 2 s . c om try { URL website = new URL(PROTOCOL_HOST + CLASH_HOST + PORTRAITS_PATH + portraitsFileName); //https://www.colorado.edu/conflict/peace/download/peace.zip // speedtest.ftp.otenet.gr/files/test10Mb.db // URL website = new URL("https://www.colorado.edu/conflict/peace/download/peace.zip"); file = new File(portraitsFolderName + File.separator + portraitsFileName); ReadableByteChannel rbc = Channels.newChannel(website.openStream()); FileOutputStream fos = new FileOutputStream(file); fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); fos.close(); } catch (IOException ex) { LOG.error(ex); throw new FileNotFoundException(); } return file; }
From source file:com.cloudera.oryx.common.collection.LongSetTest.java
@Test public void testReservedValues() { LongSet set = new LongSet(); try {// w w w .ja v a 2 s . c o m set.add(Long.MIN_VALUE); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException iae) { // good } assertFalse(set.contains(Long.MIN_VALUE)); try { set.add(Long.MAX_VALUE); fail("Should have thrown IllegalArgumentException"); } catch (IllegalArgumentException iae) { // good } assertFalse(set.contains(Long.MAX_VALUE)); }
From source file:info.archinnov.achilles.it.TestEntityWithCompositePartitionKey.java
@Test public void should_find() throws Exception { //Given//from w w w.j av a 2 s. co m final long id = RandomUtils.nextLong(0L, Long.MAX_VALUE); final UUID uuid = new UUID(1L, 1L); scriptExecutor.executeScriptTemplate("EntityWithCompositePartitionKey/insert_single_row.cql", ImmutableMap.of("id", id, "uuid", uuid, "value", "val")); //When final EntityWithCompositePartitionKey actual = manager.crud().findById(id, uuid).get(); //Then assertThat(actual.getValue()).isEqualTo("val"); }