List of usage examples for java.util UUID equals
public boolean equals(Object obj)
From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKb.CFGenKbHPKey.java
public boolean equals(Object obj) { if (obj == null) { return (false); } else if (obj instanceof CFGenKbHPKey) { CFGenKbHPKey rhs = (CFGenKbHPKey) obj; {//from w ww.j a va2s.c om long lhsClusterId = getAuditClusterId(); long rhsClusterId = rhs.getAuditClusterId(); if (lhsClusterId != rhsClusterId) { return (false); } } { Calendar lhsAuditStamp = getAuditStamp(); Calendar rhsAuditStamp = rhs.getAuditStamp(); if (lhsAuditStamp != null) { if (rhsAuditStamp != null) { if (!lhsAuditStamp.equals(rhsAuditStamp)) { return (false); } } else { return (false); } } else { return (false); } } { short lhsActionId = getAuditActionId(); short rhsActionId = rhs.getAuditActionId(); if (lhsActionId != rhsActionId) { return (false); } } { int lhsRevision = getRequiredRevision(); int rhsRevision = rhs.getRequiredRevision(); if (lhsRevision != rhsRevision) { return (false); } } { UUID lhsAuditSessionId = getAuditSessionId(); UUID rhsAuditSessionId = rhs.getAuditSessionId(); if (lhsAuditSessionId != null) { if (rhsAuditSessionId != null) { if (!lhsAuditSessionId.equals(rhsAuditSessionId)) { return (false); } } else { return (false); } } else { return (false); } } return (true); } else { return (false); } }
From source file:org.openlmis.fulfillment.web.BaseWebIntegrationTest.java
protected UUID getNonMatchingUuid(UUID match) { UUID uuid; do {/*from w w w .jav a 2 s . c o m*/ uuid = UUID.randomUUID(); } while (uuid.equals(match)); return uuid; }
From source file:com.example.android.alertbuddy.BluetoothLeService.java
private void broadcastUpdate(final String action, final BluetoothGattCharacteristic characteristic) { final Intent intent = new Intent(action); UUID uuid = characteristic.getUuid(); final byte[] data = characteristic.getValue(); if (uuid.equals(RX_UUID)) { if (data != null && data.length > 0) { intent.putExtra(EXTRA_DATA, data); }/*from ww w . j a v a2 s . co m*/ } sendBroadcast(intent); }
From source file:com.hp.autonomy.hod.sso.HodAuthenticationProvider.java
/** * Authenticates the given authentication * @param authentication The authentication to authenticate. This should be a HodTokenAuthentication * @return A HodAuthentication based on the given HodTokenAuthentication * @throws AuthenticationException if authentication fails *///from ww w .j a v a 2 s . co m @Override public Authentication authenticate(final Authentication authentication) throws AuthenticationException { final AuthenticationToken<EntityType.Combined, TokenType.Simple> combinedToken = ((HodTokenAuthentication) authentication) .getCredentials(); final CombinedTokenInformation combinedTokenInformation; try { combinedTokenInformation = authenticationService.getCombinedTokenInformation(combinedToken); } catch (final HodErrorException e) { if (HodErrorCode.AUTHENTICATION_FAILED.equals(e.getErrorCode())) { throw new BadCredentialsException("HOD authentication failed", e); } else { throw new AuthenticationServiceException("HOD returned an error while authenticating", e); } } final UUID unboundAuthenticationUuid; try { unboundAuthenticationUuid = unboundTokenService.getAuthenticationUuid(); } catch (final HodErrorException e) { throw new AuthenticationServiceException("HOD returned an error while authenticating", e); } if (!unboundAuthenticationUuid .equals(combinedTokenInformation.getApplication().getAuthentication().getUuid())) { // The provided combined token was not generated with our unbound token throw new BadCredentialsException("Invalid combined token"); } final TokenProxy<EntityType.Combined, TokenType.Simple> combinedTokenProxy; try { combinedTokenProxy = tokenRepository.insert(combinedToken); } catch (final IOException e) { throw new AuthenticationServiceException("An error occurred while authenticating", e); } Map<String, Serializable> metadata = new HashMap<>(); String name = null; final ResourceIdentifier userStore = combinedTokenInformation.getUserStore().getIdentifier(); final UUID userUuid = combinedTokenInformation.getUser().getUuid(); if (metadataTypes != null) { try { metadata = userStoreUsersService.getUserMetadata(combinedTokenProxy, userStore, userUuid, metadataTypes); if (hodUsernameResolver != null) { name = hodUsernameResolver.resolve(metadata); } } catch (final HodErrorException e) { throw new AuthenticationServiceException("HOD returned an error while authenticating", e); } } String securityInfo = null; if (securityInfoRetriever != null) { try { securityInfo = securityInfoRetriever.getSecurityInfo(combinedTokenInformation.getUser()); } catch (final Exception e) { throw new AuthenticationServiceException("There was an error while authenticating", e); } if (securityInfo == null) { throw new AuthenticationServiceException("There was an error while authenticating"); } } final HodAuthenticationPrincipal principal = new HodAuthenticationPrincipal(combinedTokenInformation, name, metadata, securityInfo); final ResourceIdentifier applicationIdentifier = combinedTokenInformation.getApplication().getIdentifier(); // Resolve application granted authorities, adding an authority representing the HOD application final Collection<GrantedAuthority> grantedAuthorities = ImmutableSet.<GrantedAuthority>builder() .addAll(authoritiesResolver.resolveAuthorities(combinedTokenProxy, combinedTokenInformation)) .add(new HodApplicationGrantedAuthority(applicationIdentifier)).build(); return new HodAuthentication<>(combinedTokenProxy, grantedAuthorities, principal); }
From source file:com.github.rolecraftdev.guild.GuildManager.java
/** * Retrieve the registered {@link Guild} with the specified {@link UUID}. * Note that {@code null} will automatically be returned when this isn't * loaded.//from ww w.ja va 2s . c o m * * @param uuid the {@link UUID} of the wanted {@link Guild} * @return the {@link Guild} with the given {@link UUID} * @since 0.0.5 */ @Nullable public Guild getGuild(final UUID uuid) { Validate.notNull(uuid); if (loaded) { for (final Guild guild : guilds) { if (uuid.equals(guild.getId())) { return guild; } } } return null; }
From source file:com.microsoft.aad.adal.Oauth2.java
/** * extract AuthenticationResult object from response body if available * //from w ww . j av a 2s. c o m * @param webResponse * @return */ private AuthenticationResult processTokenResponse(HttpWebResponse webResponse) throws AuthenticationException { AuthenticationResult result; String correlationIdInHeader = null; if (webResponse.getResponseHeaders() != null && webResponse.getResponseHeaders().containsKey(AuthenticationConstants.AAD.CLIENT_REQUEST_ID)) { // headers are returning as a list List<String> listOfHeaders = webResponse.getResponseHeaders() .get(AuthenticationConstants.AAD.CLIENT_REQUEST_ID); if (listOfHeaders != null && listOfHeaders.size() > 0) { correlationIdInHeader = listOfHeaders.get(0); } } final int statusCode = webResponse.getStatusCode(); switch (statusCode) { case HttpURLConnection.HTTP_OK: case HttpURLConnection.HTTP_BAD_REQUEST: case HttpURLConnection.HTTP_UNAUTHORIZED: try { result = parseJsonResponse(webResponse.getBody()); } catch (final JSONException jsonException) { throw new AuthenticationException(ADALError.SERVER_INVALID_JSON_RESPONSE, "Can't parse server response " + webResponse.getBody(), jsonException); } break; default: throw new AuthenticationException(ADALError.SERVER_ERROR, "Unexpected server response " + webResponse.getBody()); } // Set correlationId in the result if (correlationIdInHeader != null && !correlationIdInHeader.isEmpty()) { try { UUID correlation = UUID.fromString(correlationIdInHeader); if (!correlation.equals(mRequest.getCorrelationId())) { Logger.w(TAG, "CorrelationId is not matching", "", ADALError.CORRELATION_ID_NOT_MATCHING_REQUEST_RESPONSE); } Logger.v(TAG, "Response correlationId:" + correlationIdInHeader); } catch (IllegalArgumentException ex) { Logger.e(TAG, "Wrong format of the correlation ID:" + correlationIdInHeader, "", ADALError.CORRELATION_ID_FORMAT, ex); } } return result; }
From source file:org.photovault.replication.ChangeFactory.java
public void addObjectHistory(ObjectHistoryDTO<T> h) throws ClassNotFoundException, IOException { log.debug("addObjectHistory: entry"); UUID targetUuid = h.getTargetUuid(); ObjectHistory<T> targetHistory = dao.findObjectHistory(h.getTargetUuid()); if (targetHistory == null) { /*//ww w .j a v a 2 s. c o m The target object was not known to local database. Create local copy */ log.debug("addObjectHistory: creating " + h.getTargetClassName() + " " + h.getTargetUuid()); targetHistory = createTarget(h.getTargetClassName(), h.getTargetUuid()); } for (ChangeDTO<T> ch : h.getChanges()) { if (!targetUuid.equals(ch.targetUuid)) { // TODO: handle error!!! } addChange(targetHistory, ch); } dao.flush(); }
From source file:org.photovault.swingui.PhotoViewController.java
private void changeApplied(ApplyChangeCommand cmd) { for (ChangeDTO ch : cmd.getChanges()) { UUID id = ch.getTargetUuid(); for (PhotoInfo p : photos) { if (id.equals(p.getUuid())) { DTOResolverFactory rf = getDAOFactory().getDTOResolverFactory(); VersionedObjectEditor e = new VersionedObjectEditor(p, rf); ChangeDAO chDao = getDAOFactory().getChangeDAO(); Change c = chDao.findChange(ch.getChangeUuid()); e.changeToVersion(c);//from ww w. j a v a 2s .co m break; } } } thumbPane.setPhotos(photos); }
From source file:com.haulmont.cuba.core.sys.EntityManagerImpl.java
protected <T extends Entity> T internalMerge(T entity) { try {/*from ww w. j av a 2 s .co m*/ CubaUtil.setSoftDeletion(false); CubaUtil.setOriginalSoftDeletion(false); UUID uuid = null; if (entity.getId() instanceof IdProxy) { uuid = ((IdProxy) entity.getId()).getUuid(); } T merged = delegate.merge(entity); if (entity.getId() instanceof IdProxy && uuid != null && !uuid.equals(((IdProxy) merged.getId()).getUuid())) { ((IdProxy) merged.getId()).setUuid(uuid); } // copy non-persistent attributes to the resulting merged instance for (MetaProperty property : metadata.getClassNN(entity.getClass()).getProperties()) { if (metadata.getTools().isNotPersistent(property) && !property.isReadOnly()) { // copy using reflection to avoid executing getter/setter code Field field = FieldUtils.getDeclaredField(entity.getClass(), property.getName(), true); if (field != null) { try { Object value = FieldUtils.readField(field, entity); if (value != null) { FieldUtils.writeField(field, merged, value); } } catch (IllegalAccessException e) { throw new RuntimeException( "Error copying non-persistent attribute value to merged instance", e); } } } } return merged; } finally { CubaUtil.setSoftDeletion(softDeletion); CubaUtil.setOriginalSoftDeletion(softDeletion); } }
From source file:org.eclipse.skalli.core.project.ProjectComponent.java
private void validateDirectParent(ProjectTemplate projectTemplate, Project project, Set<Issue> issues) { UUID directParent = projectTemplate.getDirectParent(); if (directParent != null && !directParent.equals(project.getParentEntityId())) { issues.add(new Issue(Severity.FATAL, ProjectService.class, project.getUuid(), Project.class, Project.PROPERTY_PARENT_ENTITY_ID, MessageFormat.format( "Project assigned to project template ''{0}'' must be direct subproject of project ''{1}''", project.getProjectTemplateId(), directParent))); }/* ww w . ja v a2 s .co m*/ }