List of usage examples for java.lang Long equals
public boolean equals(Object obj)
From source file:org.alfresco.solr.tracker.MetadataTracker.java
private void indexTransactions() throws IOException, AuthenticationException, JSONException { long startElapsed = System.nanoTime(); int docCount = 0; boolean requiresCommit = false; while (transactionsToIndex.peek() != null) { Long transactionId = transactionsToIndex.poll(); if (transactionId != null) { Transactions transactions = client.getTransactions(null, transactionId, null, transactionId + 1, 1); if ((transactions.getTransactions().size() > 0) && (transactionId.equals(transactions.getTransactions().get(0).getId()))) { Transaction info = transactions.getTransactions().get(0); GetNodesParameters gnp = new GetNodesParameters(); ArrayList<Long> txs = new ArrayList<Long>(); txs.add(info.getId());//from ww w . j a v a 2 s. c o m gnp.setTransactionIds(txs); gnp.setStoreProtocol(storeRef.getProtocol()); gnp.setStoreIdentifier(storeRef.getIdentifier()); List<Node> nodes = client.getNodes(gnp, (int) info.getUpdates()); for (Node node : nodes) { docCount++; if (log.isDebugEnabled()) { log.debug(node.toString()); } this.infoSrv.indexNode(node, false); checkShutdown(); } // Index the transaction doc after the node - if this is not found then a reindex will be done. this.infoSrv.indexTransaction(info, false); requiresCommit = true; trackerStats.addTxDocs(nodes.size()); } } if (docCount > batchCount) { if (this.infoSrv.getRegisteredSearcherCount() < getMaxLiveSearchers()) { checkShutdown(); this.infoSrv.commit(); long endElapsed = System.nanoTime(); trackerStats.addElapsedNodeTime(docCount, endElapsed - startElapsed); startElapsed = endElapsed; docCount = 0; requiresCommit = false; } } } if (requiresCommit || (docCount > 0)) { checkShutdown(); this.infoSrv.commit(); long endElapsed = System.nanoTime(); trackerStats.addElapsedNodeTime(docCount, endElapsed - startElapsed); } }
From source file:org.alfresco.repo.domain.permissions.ADMAccessControlListDAO.java
/** * {@inheritDoc}/*from w w w .j a v a 2 s .co m*/ */ public void updateInheritance(Long childNodeId, Long oldParentAclId, Long newParentAclId) { if (oldParentAclId == null) { // nothing to do return; } List<AclChange> changes = new ArrayList<AclChange>(); Long childAclId = nodeDAO.getNodeAclId(childNodeId); if (childAclId == null) { if (newParentAclId != null) { Long newParentSharedAclId = aclDaoComponent.getInheritedAccessControlList(newParentAclId); setFixedAcls(childNodeId, newParentSharedAclId, null, null, changes, true); } } Acl acl = aclDaoComponent.getAcl(childAclId); if (acl != null && acl.getInherits()) { Long oldParentSharedAclId = aclDaoComponent.getInheritedAccessControlList(oldParentAclId); Long sharedAclchildInheritsFrom = acl.getInheritsFrom(); if (childAclId.equals(oldParentSharedAclId)) { // child had old shared acl if (newParentAclId != null) { Long newParentSharedAclId = aclDaoComponent.getInheritedAccessControlList(newParentAclId); setFixedAcls(childNodeId, newParentSharedAclId, null, childAclId, changes, true); } } else if (sharedAclchildInheritsFrom == null) { // child has defining acl of some form that does not inherit ? // Leave alone } else if (sharedAclchildInheritsFrom.equals(oldParentSharedAclId)) { // child has defining acl and needs to be remerged if (acl.getAclType() == ACLType.LAYERED) { throw new UnsupportedOperationException(); } else if (acl.getAclType() == ACLType.DEFINING) { Long newParentSharedAclId = aclDaoComponent.getInheritedAccessControlList(newParentAclId); @SuppressWarnings("unused") List<AclChange> newChanges = aclDaoComponent .mergeInheritedAccessControlList(newParentSharedAclId, childAclId); } else if (acl.getAclType() == ACLType.SHARED) { throw new IllegalStateException(); } } else { // the acl does not inherit from a node and does not need to be fixed up // Leave alone } } }
From source file:nl.b3p.viewer.admin.stripes.ApplicationSettingsActionBean.java
@ValidationMethod(on = "save") public void validate(ValidationErrors errors) throws Exception { if (name == null) { errors.add("name", new SimpleError("Naam is verplicht")); return;//from w ww . j av a2 s .c o m } try { Long foundId = null; if (version == null) { foundId = (Long) Stripersist.getEntityManager() .createQuery("select id from Application where name = :name and version is null") .setMaxResults(1).setParameter("name", name).getSingleResult(); } else { foundId = (Long) Stripersist.getEntityManager() .createQuery("select id from Application where name = :name and version = :version") .setMaxResults(1).setParameter("name", name).setParameter("version", version) .getSingleResult(); } if (application != null && application.getId() != null) { if (!foundId.equals(application.getId())) { errors.add("name", new SimpleError("Naam en versie moeten een unieke combinatie vormen.")); } } else { errors.add("name", new SimpleError("Naam en versie moeten een unieke combinatie vormen.")); } } catch (NoResultException nre) { // name version combination is unique } /* * Check if owner is an excisting user */ if (owner != null) { try { User appOwner = Stripersist.getEntityManager().find(User.class, owner); if (appOwner == null) { errors.add("owner", new SimpleError("Gebruiker met deze naam bestaat niet.")); } } catch (NoResultException nre) { errors.add("owner", new SimpleError("Gebruiker met deze naam bestaat niet.")); } } if (startExtent != null) { if (startExtent.getMinx() == null || startExtent.getMiny() == null || startExtent.getMaxx() == null || startExtent.getMaxy() == null) { errors.add("startExtent", new SimpleError("Alle velden van de start extentie moeten ingevuld worden.")); } } if (maxExtent != null) { if (maxExtent.getMinx() == null || maxExtent.getMiny() == null || maxExtent.getMaxx() == null || maxExtent.getMaxy() == null) { errors.add("maxExtent", new SimpleError("Alle velden van de max extentie moeten ingevuld worden.")); } } }
From source file:org.apache.fineract.portfolio.shareaccounts.service.ShareAccountWritePlatformServiceJpaRepositoryImpl.java
@SuppressWarnings("unchecked") @Override//from ww w . j a v a 2 s . c om public CommandProcessingResult approveAdditionalShares(Long accountId, JsonCommand jsonCommand) { try { ShareAccount account = this.shareAccountRepository.findOneWithNotFoundDetection(accountId); Map<String, Object> changes = this.accountDataSerializer.validateAndApproveAddtionalShares(jsonCommand, account); if (!changes.isEmpty()) { this.shareAccountRepository.save(account); ArrayList<Long> transactionIds = (ArrayList<Long>) changes .get(ShareAccountApiConstants.requestedshares_paramname); Long totalSubscribedShares = new Long(0); if (transactionIds != null) { Set<ShareAccountTransaction> transactions = new HashSet<>(); for (Long id : transactionIds) { ShareAccountTransaction transaction = account.retrievePurchasedShares(id); transactions.add(transaction); totalSubscribedShares += transaction.getTotalShares(); } this.journalEntryWritePlatformService .createJournalEntriesForShares(populateJournalEntries(account, transactions)); } if (!totalSubscribedShares.equals(new Long(0))) { ShareProduct shareProduct = account.getShareProduct(); shareProduct.addSubscribedShares(totalSubscribedShares); this.shareProductRepository.save(shareProduct); } } return new CommandProcessingResultBuilder() // .withCommandId(jsonCommand.commandId()) // .withEntityId(accountId) // .with(changes) // .build(); } catch (DataIntegrityViolationException dve) { handleDataIntegrityIssues(jsonCommand, dve); return CommandProcessingResult.empty(); } }
From source file:gov.va.isaac.gui.preferences.plugins.ViewCoordinatePreferencesPluginViewController.java
public Region getContent() { Task<Void> task = new Task<Void>() { @Override// w w w . j a va 2s . c om protected Void call() throws Exception { log.debug("initializing content"); try { if (!contentLoaded) { contentLoaded = true; // Populate selectableModules final ConceptVersionBI moduleRootConcept = OTFUtility.getConceptVersion( IsaacMetadataAuxiliaryBinding.MODULE.getPrimodialUuid(), panelViewCoordinate); final Set<ConceptVersionBI> moduleConcepts = new HashSet<>(); try { moduleConcepts.addAll(OTFUtility.getAllChildrenOfConcept(moduleRootConcept.getNid(), panelViewCoordinate, false)); } catch (Exception e) { log.error("Failed loading module concepts as children of " + moduleRootConcept, e); e.printStackTrace(); AppContext.getCommonDialogs() .showErrorDialog("Failed loading module concepts as children of " + moduleRootConcept + ". See logs.", e); } List<SelectableModule> modules = new ArrayList<>(); for (ConceptVersionBI cv : moduleConcepts) { modules.add(new SelectableModule(cv.getNid())); } selectableModules.clear(); selectableModules.addAll(modules); allModulesMarker.selected.addListener((observable, oldValue, newValue) -> { if (newValue) { for (SelectableModule module : selectableModules) { module.selectedProperty().set(false); } } }); selectableModules.forEach(selectableModule -> selectableModule.selectedProperty() .addListener((observable, wasSelected, isSelected) -> { if (isSelected) { if (!wasSelected) { //log.debug("Adding module nid={}, uuid={}, desc={}", selectableModule.getNid(), selectableModule.getUuid(), selectableModule.getDescription()); selectedModules.add(selectableModule.getUuid()); allModulesMarker.selectedProperty().set(false); } } else { if (wasSelected) { //log.debug("Removing module nid={}, uuid={}, desc={}", selectableModule.getNid(), selectableModule.getUuid(), selectableModule.getDescription()); selectedModules.remove(selectableModule.getUuid()); if (selectedModules.size() == 0) { allModulesMarker.selectedProperty().set(true); } } } })); selectableModuleListView.getItems().clear(); selectableModuleListView.getItems().add(allModulesMarker); Collections.sort(selectableModules); selectableModuleListView.getItems().addAll(selectableModules); runLaterIfNotFXApplicationThread( () -> pathComboBox.setTooltip(new Tooltip("Default path is \"" + OTFUtility.getDescription(getDefaultPath(), panelViewCoordinate) + "\""))); pathComboBox.getItems().clear(); pathComboBox.getItems().addAll(getPathOptions()); } // Reload persisted values every time UserProfile loggedIn = ExtendedAppContext.getCurrentlyLoggedInUserProfile(); pathComboBox.getSelectionModel().select(loggedIn.getViewCoordinatePath()); // Reload storedStatedInferredOption loadStoredStatedInferredOption(); // Reload storedStatuses loadStoredStatuses(); // Reload storedModules final Set<UUID> storedModuleUuids = getStoredModules(); if (storedModuleUuids.size() == 0) { allModulesMarker.setSelected(true); } else { // Check to make sure that stored UUID refers to an existing, known module for (UUID storedModuleUuid : storedModuleUuids) { boolean foundStoredUuidModuleInSelectableModules = false; for (SelectableModule selectableModule : selectableModules) { if (storedModuleUuid.equals(selectableModule.getUuid())) { foundStoredUuidModuleInSelectableModules = true; break; } } if (!foundStoredUuidModuleInSelectableModules) { log.error( "Loaded module (uuid={}) from user preferences that does not currently exist", storedModuleUuid); AppContext.getCommonDialogs().showErrorDialog("Unsupported Module", "Loaded a module UUID from UserProfile that does not correspond to existing module", "Concept (UUID=" + storedModuleUuid + ") not a valid module. Must be one of " + Arrays.toString(selectableModules.toArray())); } } for (SelectableModule module : selectableModules) { if (storedModuleUuids.contains(module.getUuid())) { module.setSelected(true); } else { module.setSelected(false); } } } Long storedTime = getStoredTime(); if (storedTime.equals(Long.MAX_VALUE)) { dateSelectionMethodComboBox.getSelectionModel().select(DateSelectionMethod.USE_LATEST); currentTimeProperty.set(Long.MAX_VALUE); runLaterIfNotFXApplicationThread(() -> datePicker.setValue(LocalDate.now())); } else { dateSelectionMethodComboBox.getSelectionModel().select(DateSelectionMethod.SPECIFY); currentTimeProperty.set(storedTime); setDatePickerFromCurrentTimeProperty(); } return null; } catch (Exception e) { log.error("initContent() task caught " + e.getClass().getName() + " " + e.getLocalizedMessage(), e); e.printStackTrace(); throw e; } } @Override protected void succeeded() { log.debug("Content initialization succeeded"); removeProgressIndicator(); } @Override protected void failed() { removeProgressIndicator(); Throwable ex = getException(); log.error("loadContent() caught " + ex.getClass().getName() + " " + ex.getLocalizedMessage(), ex); AppContext.getCommonDialogs().showErrorDialog("Failed loading content. See logs.", ex); } }; addProgressIndicator(); Utility.execute(task); return gridPaneInRootStackPane; }
From source file:com.gsma.rcs.ri.messaging.GroupTalkView.java
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_gchat_item, menu); menu.findItem(R.id.menu_display_content).setVisible(false); menu.findItem(R.id.menu_listen_content).setVisible(false); /* Get the list item position. */ AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; Cursor cursor = (Cursor) mAdapter.getItem(info.position); int providerId = cursor.getInt(cursor.getColumnIndexOrThrow(HistoryLog.PROVIDER_ID)); Direction direction = Direction.valueOf(cursor.getInt(cursor.getColumnIndexOrThrow(Message.DIRECTION))); if (FileTransferLog.HISTORYLOG_MEMBER_ID == providerId) { String mimeType = cursor.getString(cursor.getColumnIndexOrThrow(HistoryLog.MIME_TYPE)); if (Utils.isImageType(mimeType)) { if (Direction.OUTGOING == direction) { menu.findItem(R.id.menu_display_content).setVisible(true); } else { Long transferred = cursor.getLong(cursor.getColumnIndexOrThrow(HistoryLog.TRANSFERRED)); Long size = cursor.getLong(cursor.getColumnIndexOrThrow(HistoryLog.FILESIZE)); if (size.equals(transferred)) { menu.findItem(R.id.menu_display_content).setVisible(true); }// w ww.jav a 2 s .c o m } } else if (Utils.isAudioType(mimeType)) { if (Direction.OUTGOING == direction) { menu.findItem(R.id.menu_listen_content).setVisible(true); } else { Long transferred = cursor.getLong(cursor.getColumnIndexOrThrow(HistoryLog.TRANSFERRED)); Long size = cursor.getLong(cursor.getColumnIndexOrThrow(HistoryLog.FILESIZE)); if (size.equals(transferred)) { menu.findItem(R.id.menu_listen_content).setVisible(true); } } } } if (Direction.OUTGOING != direction) { menu.findItem(R.id.menu_view_group_delivery).setVisible(false); } }
From source file:edu.ku.brc.specify.dbsupport.cleanuptools.GeoCleanupFuzzySearch.java
public boolean shouldIndex() { AppPreferences localPrefs = AppPreferences.getLocalPrefs(); boolean needsIndexing = true; Long lastGeoNamesBuildTime = BuildFromGeonames.getLastGeonamesBuiltTime(); Long lastIndexBuild = localPrefs != null ? localPrefs.getLong(GEONAMES_INDEX_DATE_PREF, null) : null; if (!initLuceneforReading() || lastIndexBuild == null || lastGeoNamesBuildTime == null || !lastIndexBuild.equals(lastGeoNamesBuildTime)) { if (getReader() != null) { Integer numDocs = localPrefs != null ? localPrefs.getInt(GEONAMES_INDEX_NUMDOCS, null) : null; if (numDocs != null) { //System.out.println(String.format("%d %d", getReader().numDocs(), numDocs)); needsIndexing = getReader().numDocs() != numDocs; }/*from w ww .j a va2s . c o m*/ } doneSearching(); } else { needsIndexing = false; } return needsIndexing; }
From source file:org.alfresco.repo.domain.permissions.ADMAccessControlListDAO.java
/** * Support to set a shared ACL on a node and all of its children * /*from www .ja v a2 s .c o m*/ * @param nodeId * the parent node * @param inheritFrom * the parent node's ACL * @param mergeFrom * the shared ACL, if already known. If <code>null</code>, will be retrieved / created lazily * @param changes * the list in which to record changes * @param set * set the shared ACL on the parent ? * @param asyncCall * function may require asynchronous call depending the execution time; if time exceeds configured <code>fixedAclMaxTransactionTime</code> value, * recursion is stopped using propagateOnChildren parameter(set on false) and those nodes for which the method execution was not finished * in the classical way, will have ASPECT_PENDING_FIX_ACL, which will be used in {@link FixedAclUpdater} for later processing */ public void setFixedAcls(Long nodeId, Long inheritFrom, Long mergeFrom, Long sharedAclToReplace, List<AclChange> changes, boolean set, boolean asyncCall, boolean propagateOnChildren) { if (log.isDebugEnabled()) { log.debug(" Set fixed acl for nodeId=" + nodeId + " inheritFrom=" + inheritFrom + " sharedAclToReplace=" + sharedAclToReplace + " mergefrom= " + mergeFrom); } if (nodeId == null) { return; } else { // Lazily retrieve/create the shared ACL if (mergeFrom == null) { mergeFrom = aclDaoComponent.getInheritedAccessControlList(inheritFrom); } if (set) { nodeDAO.setNodeAclId(nodeId, mergeFrom); } List<NodeIdAndAclId> children = nodeDAO.getPrimaryChildrenAcls(nodeId); if (children.size() > 0) { nodeDAO.setPrimaryChildrenSharedAclId(nodeId, sharedAclToReplace, mergeFrom); } if (!propagateOnChildren) { return; } for (NodeIdAndAclId child : children) { Long acl = child.getAclId(); if (acl == null) { propagateOnChildren = setFixAclPending(child.getId(), inheritFrom, mergeFrom, sharedAclToReplace, changes, false, asyncCall, propagateOnChildren); } else { // if(acl.equals(mergeFrom)) // { // setFixedAcls(child.getId(), inheritFrom, mergeFrom, sharedAclToReplace, changes, false); // } // Already replaced if (acl.equals(sharedAclToReplace)) { propagateOnChildren = setFixAclPending(child.getId(), inheritFrom, mergeFrom, sharedAclToReplace, changes, false, asyncCall, propagateOnChildren); } else { Acl dbAcl = aclDaoComponent.getAcl(acl); if (dbAcl.getAclType() == ACLType.LAYERED) { throw new UnsupportedOperationException(); } else if (dbAcl.getAclType() == ACLType.DEFINING) { if (dbAcl.getInherits()) { @SuppressWarnings("unused") List<AclChange> newChanges = aclDaoComponent .mergeInheritedAccessControlList(mergeFrom, acl); } } else if (dbAcl.getAclType() == ACLType.SHARED) { throw new ConcurrencyFailureException("setFixedAcls: unexpected shared acl: " + dbAcl); } } } } } }
From source file:com.gst.portfolio.shareaccounts.service.ShareAccountWritePlatformServiceJpaRepositoryImpl.java
@SuppressWarnings("unchecked") @Override/*w w w . ja v a 2s . c o m*/ public CommandProcessingResult approveAdditionalShares(Long accountId, JsonCommand jsonCommand) { try { ShareAccount account = this.shareAccountRepository.findOneWithNotFoundDetection(accountId); Map<String, Object> changes = this.accountDataSerializer.validateAndApproveAddtionalShares(jsonCommand, account); if (!changes.isEmpty()) { this.shareAccountRepository.save(account); ArrayList<Long> transactionIds = (ArrayList<Long>) changes .get(ShareAccountApiConstants.requestedshares_paramname); Long totalSubscribedShares = new Long(0); if (transactionIds != null) { Set<ShareAccountTransaction> transactions = new HashSet<>(); for (Long id : transactionIds) { ShareAccountTransaction transaction = account.retrievePurchasedShares(id); transactions.add(transaction); totalSubscribedShares += transaction.getTotalShares(); } this.journalEntryWritePlatformService .createJournalEntriesForShares(populateJournalEntries(account, transactions)); } if (!totalSubscribedShares.equals(new Long(0))) { ShareProduct shareProduct = account.getShareProduct(); shareProduct.addSubscribedShares(totalSubscribedShares); this.shareProductRepository.save(shareProduct); } } return new CommandProcessingResultBuilder() // .withCommandId(jsonCommand.commandId()) // .withEntityId(accountId) // .with(changes) // .build(); } catch (DataIntegrityViolationException dve) { handleDataIntegrityIssues(jsonCommand, dve.getMostSpecificCause(), dve); return CommandProcessingResult.empty(); } }
From source file:org.mitre.uma.web.PolicyAPI.java
/** * Update a specific policy//from w w w . j av a2s. c om * @param rsid * @param pid * @param jsonString * @param m * @param auth * @return */ @RequestMapping(value = "/{rsid}" + POLICYURL + "/{pid}", method = RequestMethod.PUT, consumes = MimeTypeUtils.APPLICATION_JSON_VALUE, produces = MimeTypeUtils.APPLICATION_JSON_VALUE) public String setClaimsForResourceSet(@PathVariable(value = "rsid") Long rsid, @PathVariable(value = "pid") Long pid, @RequestBody String jsonString, Model m, Authentication auth) { ResourceSet rs = resourceSetService.getById(rsid); if (rs == null) { m.addAttribute(HttpCodeView.CODE, HttpStatus.NOT_FOUND); return HttpCodeView.VIEWNAME; } if (!rs.getOwner().equals(auth.getName())) { logger.warn("Unauthorized resource set request from bad user; expected " + rs.getOwner() + " got " + auth.getName()); // authenticated user didn't match the owner of the resource set m.addAttribute(HttpCodeView.CODE, HttpStatus.FORBIDDEN); return HttpCodeView.VIEWNAME; } Policy p = gson.fromJson(jsonString, Policy.class); if (!pid.equals(p.getId())) { logger.warn("Policy ID mismatch, expected " + pid + " got " + p.getId()); m.addAttribute(HttpCodeView.CODE, HttpStatus.BAD_REQUEST); return HttpCodeView.VIEWNAME; } for (Policy policy : rs.getPolicies()) { if (policy.getId().equals(pid)) { // found it! // find the existing claim IDs, make sure we're not overwriting anything from another policy Set<Long> claimIds = new HashSet<>(); for (Claim claim : policy.getClaimsRequired()) { claimIds.add(claim.getId()); } for (Claim claim : p.getClaimsRequired()) { if (claim.getId() != null && !claimIds.contains(claim.getId())) { logger.warn("Tried to add a policy with a an unmatched claim ID: got " + claim.getId() + " expected " + claimIds); m.addAttribute(HttpCodeView.CODE, HttpStatus.BAD_REQUEST); return HttpCodeView.VIEWNAME; } } // update the existing object with the new values policy.setClaimsRequired(p.getClaimsRequired()); policy.setName(p.getName()); policy.setScopes(p.getScopes()); resourceSetService.update(rs, rs); m.addAttribute(JsonEntityView.ENTITY, policy); return JsonEntityView.VIEWNAME; } } // if we made it this far, we haven't found it m.addAttribute(HttpCodeView.CODE, HttpStatus.NOT_FOUND); return HttpCodeView.VIEWNAME; }