public void setValue( Object value ) { if ( isUUID() && value instanceof String ) { value = UUID.fromString( ( String ) value ); } this.value = value; } }
public List<UUID> getUuidIdentifiers() { if ( ( identifiers == null ) || identifiers.isEmpty() ) { return null; } List<UUID> ids = new ArrayList<UUID>(); for ( Identifier identifier : identifiers ) { if ( identifier.isUUID() ) { ids.add( identifier.getUUID() ); } } return ids; }
public boolean containsUuidIdentifersOnly() { if ( hasFilterPredicates() ) { return false; } if ( ( identifiers == null ) || identifiers.isEmpty() ) { return false; } for ( Identifier identifier : identifiers ) { if ( !identifier.isUUID() ) { return false; } } return true; }
boolean containsUuidIdentifiersOnly() { if ( hasQueryPredicates() ) { return false; } if ( ( identifiers == null ) || identifiers.isEmpty() ) { return false; } for ( Identifier identifier : identifiers ) { if (identifier == null) { logger.error("containsUuidIdentifiersOnly(): identifier in identifiers list is null"); return false; } if ( !identifier.isUUID() ) { return false; } } return true; }
public static OrganizationInfo getOrganization( Identifier identifier ) { if ( identifier == null ) { return null; } UUID organizationId = null; String organizationName = null; BiMap<UUID, String> organizations = getOrganizations(); if ( organizations == null ) { return null; } if ( identifier.isName() ) { organizationName = identifier.getName().toLowerCase(); organizationId = organizations.inverse().get( organizationName ); } else if ( identifier.isUUID() ) { organizationId = identifier.getUUID(); organizationName = organizations.get( organizationId ); } if ( ( organizationId != null ) && ( organizationName != null ) ) { return new OrganizationInfo( organizationId, organizationName ); } return null; }
protected Map<Object, Notifier> getNotifierMap(Map payloads) throws Exception { Map<Object, Notifier> notifiers = new HashMap<Object, Notifier>( payloads.size() * 2); for (Object id : payloads.keySet()) { Identifier identifier = Identifier.from(id); Notifier notifier; if (identifier.isUUID()) { notifier = em.get(identifier.getUUID(), Notifier.class); } else { EntityRef ref = em.getAlias("notifier", identifier.getName()); notifier = em.get(ref, Notifier.class); } if (notifier != null) { notifiers.put(notifier.getUuid(), notifier); notifiers.put(notifier.getUuid().toString(), notifier); if (notifier.getName() != null) { notifiers.put(notifier.getName(), notifier); } } } return notifiers; }
/** * Build CandidateResults from direct query */ private CandidateResults buildCandidateResultsForDirectQuery(final List<Identifier> directIdentifiers, final ParsedQuery query, final SearchTypes searchTypes) { Preconditions.checkArgument(searchTypes.getTypes().length > 0, "Search type required"); String entityType = searchTypes.getTypes()[0]; List<CandidateResult> candidates = new ArrayList<>(directIdentifiers.size()); for (Identifier id : directIdentifiers) { CandidateResult candidateResult = null; if (id.isUUID()) { candidateResult = new CandidateResult(entityType, id.getUUID()); } else if (id.isName()) { candidateResult = new CandidateResult(entityType, id.getName()); } candidates.add(candidateResult); } return new CandidateResults(candidates, query.getSelectFieldMappings(), true); }
public static ApplicationInfo getApplication( Identifier identifier ) { if ( identifier == null ) { return null; } if ( !isApplicationAdmin() && !isApplicationUser() ) { return null; } String applicationName = null; UUID applicationId = null; BiMap<UUID, String> applications = getApplications(); if ( applications == null ) { return null; } if ( identifier.isName() ) { applicationName = identifier.getName().toLowerCase(); applicationId = applications.inverse().get( applicationName ); } else if ( identifier.isUUID() ) { applicationId = identifier.getUUID(); applicationName = applications.get( identifier.getUUID() ); } if ( ( applicationId != null ) && ( applicationName != null ) ) { return new ApplicationInfo( applicationId, applicationName ); } return null; }
@Override public OrganizationInfo getOrganizationByIdentifier( Identifier id ) throws Exception { if ( id.isUUID() ) { return getOrganizationByUuid( id.getUUID() ); } if ( id.isName() ) { return getOrganizationByName( id.getName() ); } return null; }
@Override public ApplicationInfo getApplicationInfo( Identifier id ) throws Exception { if ( id == null ) { return null; } if ( id.isUUID() ) { return getApplicationInfo( id.getUUID() ); } if ( id.isName() ) { return getApplicationInfo( id.getName() ); } return null; }
public static boolean isUser( Identifier identifier ) { if ( identifier == null ) { return false; } UserInfo user = getUser(); if ( user == null ) { return false; } if ( identifier.isUUID() ) { return user.getUuid().equals( identifier.getUUID() ); } if ( identifier.isEmail() ) { return user.getEmail().equalsIgnoreCase( identifier.getEmail() ); } if ( identifier.isName() ) { return user.getUsername().equals( identifier.getName() ); } return false; }
@Override public EntityRef getGroupByIdentifier( Identifier identifier ) throws Exception { if ( identifier == null ) { return null; } if ( identifier.isUUID() ) { return new SimpleEntityRef( "group", identifier.getUUID() ); } if ( identifier.isName() ) { return this.getAlias( new SimpleEntityRef( Application.ENTITY_TYPE, applicationId ), "group", identifier.getName() ); } return null; }
@Override public UserInfo getAdminUserByIdentifier( Identifier id ) throws Exception { if ( id.isUUID() ) { return getAdminUserByUuid( id.getUUID() ); } if ( id.isName() ) { return getAdminUserByUsername( id.getName() ); } if ( id.isEmail() ) { return getAdminUserByEmail( id.getEmail() ); } return null; }
if ( ( param.getValue() == null ) || ( param.getValue().size() == 0 ) || identifier.isUUID() ) { if ( identifier != null ) { if ( identifiers == null ) {
if ( identifier.isUUID() ) { return new SimpleEntityRef( "user", identifier.getUUID() );