List of usage examples for java.lang Long decode
public static Long decode(String nm) throws NumberFormatException
From source file:org.jbpm.formModeler.core.config.FormManagerImpl.java
protected static Long generateUniqueId() { UUID idOne = UUID.randomUUID(); String str = "" + idOne; int uid = str.hashCode(); String filterStr = "" + uid; str = filterStr.replaceAll("-", ""); return Long.decode(str); }
From source file:org.flockdata.search.dao.EntityChangeWriterEs.java
@Override public EntitySearchChange handle(EntitySearchChange searchChange) throws IOException { String source = getJsonToIndex(searchChange); if (searchChange.getSearchKey() == null || searchChange.getSearchKey().equals("")) { searchChange.setSearchKey(/* ww w . jav a 2s . c o m*/ (searchChange.getCode() == null ? searchChange.getKey() : searchChange.getCode())); logger.debug("No search key, creating as a new document [{}]", searchChange.getKey()); return save(searchChange, source); } try { logger.debug("Update request for searchKey [{}], key[{}]", searchChange.getSearchKey(), searchChange.getKey()); GetRequestBuilder request = elasticSearchClient.prepareGet(searchChange.getIndexName(), searchChange.getDocumentType(), searchChange.getSearchKey()); // if (searchChange.getParent() != null) { // request.setRouting(searchChange.getParent().getCode()); // } GetResponse response = request.execute().actionGet(); logger.debug("executed get request for {}", searchChange.toString()); if (response.isExists() && !response.isSourceEmpty()) { logger.debug("Document exists!"); // Messages can be received out of sequence // Check to ensure we don't accidentally overwrite a more current // document with an older one. We assume the calling fortress understands // what the most recent doc is. Object o = response.getSource().get(SearchSchema.UPDATED); // fortress view of UPDATED, not FlockDatas! if (o != null) { Long existingWhen = Long.decode(o.toString()); logger.debug("Comparing searchChange when {} with stored when {}", searchChange.getUpdatedDate(), existingWhen); if (!searchChange.isForceReindex()) { if (existingWhen.compareTo(searchChange.getUpdatedDate().getTime()) > 0) { logger.debug( "ignoring a request to update as the existing document dated [{}] is newer than the searchChange document dated [{}]", new Date(existingWhen), searchChange.getUpdatedDate()); return searchChange; // Don't overwrite the most current doc! } else if (searchChange.getUpdatedDate().getTime() == 0L && !searchChange.isReplyRequired()) { // Meta Change - not indexed in FD, so ignore something we already have. // Likely scenario is a batch is being reprocessed return searchChange; } logger.debug("Document is more recent. Proceeding with update"); } else { logger.debug("Forcing an update of the document."); } } } else { // No response, to a search key we expect to exist. Create a new one // Likely to be in response to rebuilding an ES index from Graph data. logger.debug("About to create in response to an update request for {}", searchChange.toString()); return save(searchChange, source); } // Update the existing document with the searchChange change IndexRequestBuilder update = elasticSearchClient.prepareIndex(searchChange.getIndexName(), searchChange.getDocumentType(), searchChange.getSearchKey()); //.setRouting(searchChange.getKey()); ListenableActionFuture<IndexResponse> ur = update.setSource(source).execute(); if (logger.isDebugEnabled()) { IndexResponse indexResponse = ur.actionGet(); logger.debug("Updated [{}] logId=[{}] for [{}] to version [{}]", searchChange.getSearchKey(), searchChange.getLogId(), searchChange, indexResponse.getVersion()); } // } catch (IndexMissingException e) { // administrator must have deleted it, but we think it still exists // logger.info("Attempt to update non-existent index [{}]. Creating it..", searchChange.getIndexName()); // purgeCache(); // return save(searchChange, source); } catch (NoShardAvailableActionException e) { return save(searchChange, source); } return searchChange; }
From source file:fr.gael.dhus.sync.impl.ODataProductSynchronizer.java
/** * Creates a new ODataSynchronizer./*from w w w . j a v a 2s . c o m*/ * * @param sc configuration for this synchronizer. * * @throws IllegalStateException if the configuration doe not contains the * required fields, or those fields are malformed. * @throws IOException when the OdataClient fails to contact the server * at {@code url}. * @throws ODataException when no OData service have been found at the * given url. * @throws NumberFormatException if the value of the `target_collection` * configuration field is not a number. */ public ODataProductSynchronizer(SynchronizerConf sc) throws IOException, ODataException { super(sc); // Checks if required configuration is set String urilit = sc.getConfig("service_uri"); serviceUser = sc.getConfig("service_username"); servicePass = sc.getConfig("service_password"); if (urilit == null || urilit.isEmpty()) { throw new IllegalStateException("`service_uri` is not set"); } try { client = new ODataClient(urilit, serviceUser, servicePass); } catch (URISyntaxException e) { throw new IllegalStateException("`service_uri` is malformed"); } String dec_name = client.getSchema().getDefaultEntityContainer().getName(); if (!dec_name.equals(V1Model.ENTITY_CONTAINER)) { throw new IllegalStateException("`service_uri` does not reference a DHuS odata service"); } String last_cr = sc.getConfig("last_created"); if (last_cr != null && !last_cr.isEmpty()) { lastCreated = new Date(Long.decode(last_cr)); } else { lastCreated = new Date(0L); } String last_up = sc.getConfig("last_updated"); if (last_up != null && !last_up.isEmpty()) { lastUpdated = new Date(Long.decode(last_up)); } else { lastUpdated = new Date(0L); } String last_del = sc.getConfig("last_deleted"); if (last_del != null && !last_del.isEmpty()) { lastDeleted = new Date(Long.decode(last_del)); } else { lastDeleted = new Date(0L); } String page_size = sc.getConfig("page_size"); if (page_size != null && !page_size.isEmpty()) { pageSize = Integer.decode(page_size); } else { pageSize = 30; // FIXME get that value from the config? } String remote_incoming = sc.getConfig("remote_incoming_path"); if (remote_incoming != null && !remote_incoming.isEmpty()) { File ri = new File(remote_incoming); if (!ri.exists() || !ri.isDirectory() || !ri.canRead()) { throw new IOException("Cannot access remote incoming " + remote_incoming); } this.remoteIncoming = remote_incoming; } else { this.remoteIncoming = null; } String target_collection = sc.getConfig("target_collection"); if (target_collection != null && !target_collection.isEmpty()) { this.targetCollection = Long.parseLong(target_collection); } else { this.targetCollection = null; } String filter_param = sc.getConfig("filter_param"); if (filter_param != null && !filter_param.isEmpty()) { filterParam = filter_param; } else { filterParam = null; } String source_collection = sc.getConfig("source_collection"); if (source_collection != null && !source_collection.isEmpty()) { sourceCollection = source_collection; } else { sourceCollection = ""; } String copy_product = sc.getConfig("copy_product"); if (copy_product != null && !copy_product.isEmpty()) { this.copyProduct = Boolean.parseBoolean(copy_product); } else { this.copyProduct = false; } }
From source file:com.bmd.android.collection.SparseArrayCompatTest.java
public void testConversions() { assertThat(AndroidCollections.iterate(mArray).toLongs(new Translator<SparseArrayEntry<String>, Long>() { @Override//from www .j a v a 2 s. c o m public Long translate(final SparseArrayEntry<String> element) { return Long.decode(element.getValue()); } }).reverse()).containsExactly(4L, 3L, 2L, 1L, 0L); assertThat(AndroidCollections.iterate(mArray).only().key(2) .toBooleans(new Translator<SparseArrayEntry<String>, Boolean>() { @Override public Boolean translate(final SparseArrayEntry<String> element) { return "2".equals(element.getValue()); } })).containsExactly(true); assertThat(AndroidCollections.iterate(mArray).reverse() .toIntegers(new Translator<SparseArrayEntry<String>, Integer>() { @Override public Integer translate(final SparseArrayEntry<String> element) { return element.getKey(); } }).only().first(3).retain().reverse()).containsExactly(2, 3, 4); assertThat(AndroidCollections.iterate(mArray).keys()).containsExactly(2, 3, 4); }
From source file:com.auditbucket.search.dao.TrackDaoES.java
@Override public SearchChange update(SearchChange incoming) { String source = makeIndexJson(incoming); if (incoming.getSearchKey() == null) return save(incoming); try {//from www . j a v a 2s .co m logger.debug("Received request to Update [{}]", incoming.getMetaKey()); ensureIndex(incoming.getIndexName(), incoming.getDocumentType()); ensureMapping(incoming.getIndexName(), incoming.getDocumentType()); GetResponse response = esClient .prepareGet(incoming.getIndexName(), incoming.getDocumentType(), incoming.getSearchKey()) //.setRouting(incoming.getMetaKey()) .execute().actionGet(); if (response.isExists() && !response.isSourceEmpty()) { // Messages can be received out of sequence // Check to ensure we don't accidentally overwrite a more current // document with an older one. We assume the calling fortress understands // what the most recent doc is. Object o = response.getSource().get(MetaSearchSchema.WHEN); // fortress view of WHEN, not AuditBuckets! if (o != null) { Long existingWhen = Long.decode(o.toString()); if (existingWhen > incoming.getWhen()) { logger.debug( "ignoring a request to update as the existing document dated [{}] is newer than the incoming document dated [{}]", new Date(existingWhen), new Date(incoming.getWhen())); return incoming; // Don't overwrite the most current doc! } else if (incoming.getWhen() == 0l && !incoming.isReplyRequired()) { // Meta Change - not indexed in AB, so ignore something we already have. // Likely scenario is a batch is being reprocessed return incoming; } } } else { // No response, to a search key we expect to exist. Create a new one // Likely to be in response to rebuilding an ES index from Graph data. return save(incoming); } // Update the existing document with the incoming change IndexRequestBuilder update = esClient.prepareIndex(incoming.getIndexName(), incoming.getDocumentType(), incoming.getSearchKey()); //.setRouting(incoming.getMetaKey()); ListenableActionFuture<IndexResponse> ur = update.setSource(source).execute(); if (logger.isDebugEnabled()) { IndexResponse indexResponse = ur.actionGet(); logger.debug("Updated [{}] logId=[{}] for [{}] to version [{}]", incoming.getSearchKey(), incoming.getLogId(), incoming, indexResponse.getVersion()); } } catch (IndexMissingException e) { // administrator must have deleted it, but we think it still exists logger.info("Attempt to update non-existent index [{}]. Moving to create it", incoming.getIndexName()); return save(incoming); } return incoming; }
From source file:com.bmd.android.collection.SupportLongSparseArrayTest.java
public void testConversions() { assertThat(AndroidCollections.iterate(mArray).toLongs(new Translator<LongSparseArrayEntry<String>, Long>() { @Override//w w w . j a v a 2 s.c o m public Long translate(final LongSparseArrayEntry<String> element) { return Long.decode(element.getValue()); } }).reverse()).containsExactly(4L, 3L, 2L, 1L, 0L); assertThat(AndroidCollections.iterate(mArray).only().key(2) .toBooleans(new Translator<LongSparseArrayEntry<String>, Boolean>() { @Override public Boolean translate(final LongSparseArrayEntry<String> element) { return "2".equals(element.getValue()); } })).containsExactly(true); assertThat(AndroidCollections.iterate(mArray).reverse() .toIntegers(new Translator<LongSparseArrayEntry<String>, Integer>() { @Override public Integer translate(final LongSparseArrayEntry<String> element) { return (int) element.getKey(); } }).only().first(3).retain().reverse()).containsExactly(2, 3, 4); assertThat(AndroidCollections.iterate(mArray).keys()).containsExactly(2L, 3L, 4L); }
From source file:com.emergya.persistenceGeo.web.RestUserAdminController.java
@RequestMapping(value = "/persistenceGeo/getUsersByGroup/{idGroup}", method = RequestMethod.GET) public @ResponseBody Map<String, Object> getUsersByGroup(@PathVariable String idGroup) { Map<String, Object> result = new HashMap<String, Object>(); List<UserDto> users = null; try {//from w w w . ja v a2s.c o m //TODO: get user by authority group of user logged users = (List<UserDto>) userAdminService.getUsersByGroup(Long.decode(idGroup)); } catch (Exception e) { //Nothing } result.put(RESULTS, users != null ? users.size() : 0); result.put(ROOT, users != null ? users : ListUtils.EMPTY_LIST); return result; }
From source file:com.bmd.android.collection.SimpleArrayMapTest.java
public void testConversions() { assertThat(AndroidCollections.iterate(mArray) .toLongs(new Translator<SimpleArrayMapEntry<Integer, String>, Long>() { @Override/*w w w .j a va 2s .c o m*/ public Long translate(final SimpleArrayMapEntry<Integer, String> element) { return Long.decode(element.getValue()); } }).reverse()).containsExactly(4L, 3L, 2L, 1L, 0L); assertThat(AndroidCollections.iterate(mArray).only().key(2) .toBooleans(new Translator<SimpleArrayMapEntry<Integer, String>, Boolean>() { @Override public Boolean translate(final SimpleArrayMapEntry<Integer, String> element) { return "2".equals(element.getValue()); } })).containsExactly(true); assertThat(AndroidCollections.iterate(mArray).reverse() .toIntegers(new Translator<SimpleArrayMapEntry<Integer, String>, Integer>() { @Override public Integer translate(final SimpleArrayMapEntry<Integer, String> element) { return element.getKey(); } }).only().first(3).retain().reverse()).containsExactly(2, 3, 4); assertThat(AndroidCollections.iterate(mArray).keys()).containsExactly(2, 3, 4); }
From source file:com.bmd.android.collection.LongSparseArrayTest.java
public void testConversions() { if (VERSION.SDK_INT < VERSION_CODES.JELLY_BEAN) { return;/*from w ww . j a va 2 s . c om*/ } assertThat(AndroidCollections.iterate(mArray).toLongs(new Translator<LongSparseArrayEntry<String>, Long>() { @Override public Long translate(final LongSparseArrayEntry<String> element) { return Long.decode(element.getValue()); } }).reverse()).containsExactly(4L, 3L, 2L, 1L, 0L); assertThat(AndroidCollections.iterate(mArray).only().key(2) .toBooleans(new Translator<LongSparseArrayEntry<String>, Boolean>() { @Override public Boolean translate(final LongSparseArrayEntry<String> element) { return "2".equals(element.getValue()); } })).containsExactly(true); assertThat(AndroidCollections.iterate(mArray).reverse() .toIntegers(new Translator<LongSparseArrayEntry<String>, Integer>() { @Override public Integer translate(final LongSparseArrayEntry<String> element) { return (int) element.getKey(); } }).only().first(3).retain().reverse()).containsExactly(2, 3, 4); assertThat(AndroidCollections.iterate(mArray).keys()).containsExactly(2L, 3L, 4L); }
From source file:com.l2jfree.config.L2Properties.java
public long getLong(String name, String deflt) { String val = getProperty(name, deflt); if (val == null) throw new IllegalArgumentException("Integer value required, but not specified"); try {/*from ww w . j a v a 2 s. c o m*/ return Long.decode(val); } catch (Exception e) { throw new IllegalArgumentException("Integer value required, but found: " + val); } }