/** * Generate a new entity with the given type and a new id * @param type */ public Entity(String type){ this(new SimpleId( type )); }
@Test public void typeComparison() { final UUID uuid = UUIDGenerator.newTimeUUID(); final String firstType = "test1"; final String secondType = "test2"; SimpleId first = new SimpleId( uuid, firstType ); SimpleId second = new SimpleId( uuid, secondType ); assertTrue( first.compareTo( second ) < 0 ); assertTrue( first.compareTo( first ) == 0 ); assertTrue( second.compareTo( first ) > 0 ); } }
@Test public void uuidComparison() { final UUID firstId = UUIDGenerator.newTimeUUID(); final UUID secondId = UUIDGenerator.newTimeUUID(); final String type = "test"; SimpleId first = new SimpleId( firstId, type ); SimpleId second = new SimpleId( secondId, type ); assertTrue( first.compareTo( second ) < 0 ); assertTrue( first.compareTo( first ) == 0 ); assertTrue( second.compareTo( first ) > 0 ); }
/** * Generate an entity Id from the given UUID * * @param entityId the entity's UUID */ public static Id generateEntityId( UUID entityId, String entityType ) { return new SimpleId( entityId, entityType ); }
@Override public Id asId() { return new SimpleId(id, CONNECTION_ENTITY_TYPE ); }
@Override public Id asId() { return new SimpleId(uuid, type); }
@Override public Id asId() { return new SimpleId( id, type ); }
@Override public Id asId() { return new SimpleId( id, "role" ); }
@Override public Id asId() { return new SimpleId( uuid, type ); }
private Id getAppIdObject(){ return new SimpleId( applicationId, TYPE_APPLICATION ); }
/** * Generate an ID with the type and id * * @param id The uuid in the id * @param type The type of id */ public static Id createId( UUID id, String type ) { return new SimpleId( id, type ); } }
@Override public Id asId() { return new SimpleId( uuid, getType() ); }
@Override public Health getEntityStoreHealth() { // could use any collection scope here, does not matter EntityCollectionManager ecm = managerCache.getEntityCollectionManager( new ApplicationScopeImpl( new SimpleId( CpNamingUtils.MANAGEMENT_APPLICATION_ID, "application" ) ) ); return ecm.getHealth(); }
private void invalidateManagementAppAuthCache() { ScopedCache scopedCache = cacheFactory.getScopedCache( new CacheScope( new SimpleId( CpNamingUtils.MANAGEMENT_APPLICATION_ID, "application" ))); scopedCache.invalidate(); localShiroCache.invalidateAll(); }
/** * Get the map manager for uuid mapping */ private MapManager getMapManagerForTypes() { Id mapOwner = new SimpleId( applicationId, TYPE_APPLICATION ); final MapScope ms = CpNamingUtils.getEntityTypeMapScope(mapOwner); MapManager mm = managerCache.getMapManager( ms ); return mm; }
@Override public Id fromComposite( final CompositeParser composite ) { final UUID uuid = composite.readUUID(); final String type = composite.readString(); return new SimpleId( uuid, type ); }
/** * Get the map manager for uuid mapping */ private MapManager getMapManagerForTypes() { Id mapOwner = new SimpleId( applicationId, TYPE_APPLICATION ); final MapScope ms = CpNamingUtils.getEntityTypeMapScope(mapOwner); MapManager mm = managerCache.getMapManager( ms ); return mm; }
/** get cache for application scope */ private ScopedCache<String, V> getCacheScope( K key ) { PrincipalIdentifier principal; if ( key instanceof SimplePrincipalCollection) { SimplePrincipalCollection spc = (SimplePrincipalCollection) key; principal = (PrincipalIdentifier) spc.getPrimaryPrincipal(); } else { principal = (PrincipalIdentifier)key; } CacheScope scope = new CacheScope(new SimpleId(principal.getApplicationId(), "application")); ScopedCache<String, V> scopedCache = cacheFactory.getScopedCache(scope); return scopedCache; }
@Override public Id fromComposite( final DynamicComposite composite, int startIndex ) { Preconditions.checkArgument( composite.size() >= startIndex+2, "Composite must contain a next element for uuid and type" ); final UUID uuid = composite.get(startIndex, UUID_SERIALIZER ); final String type = composite.get(startIndex +1, STRING_SERIALIZER); return new SimpleId(uuid, type ); }