@SuppressWarnings("unchecked") public static Map<String, String> asMap( Properties properties ) { return cast( properties ); }
@SuppressWarnings("unchecked") public Message( Map<String, Object> properties ) { this.properties.putAll( coerceMap( ( Map<String, Class<?>> ) cast( MESSAGE_PROPERTIES ), properties ) ); }
@SuppressWarnings("unchecked") public static Map<String, List<?>> toMapList( Map<String, ?> m ) { Map<String, List<Object>> mapList = new LinkedHashMap<String, List<Object>>(); for ( Entry<String, ?> e : m.entrySet() ) { if ( e.getValue() instanceof List ) { addListToMapList( mapList, e.getKey(), ( List<Object> ) e.getValue() ); } else { addMapList( mapList, e.getKey(), e.getValue() ); } } return cast( mapList ); }
@Override public Set<String> getCounterNames() throws Exception { Set<String> names = new TreeSet<String>( CASE_INSENSITIVE_ORDER ); Set<String> nameSet = cast( getDictionaryAsSet( getApplicationRef(), Schema.DICTIONARY_COUNTERS ) ); names.addAll( nameSet ); return names; }
@Override public Map<String, String> getUserGroupRoles( UUID userId, UUID groupId ) throws Exception { // TODO this never returns anything - write path not invoked EntityRef userRef = userRef( userId ); return cast( getDictionaryAsMap( userRef, DICTIONARY_ROLENAMES ) ); }
@Override public Set<String> getUserPermissions( UUID userId ) throws Exception { return cast(getDictionaryAsSet( new SimpleEntityRef( User.ENTITY_TYPE, userId ), Schema.DICTIONARY_PERMISSIONS ) ); }
@Override public Set<String> getUserRoles( UUID userId ) throws Exception { return cast( getDictionaryAsSet( userRef( userId ), DICTIONARY_ROLENAMES ) ); }
@Override public Map<String, String> getRoles() throws Exception { return cast(getDictionaryAsMap(getApplicationRef(), DICTIONARY_ROLENAMES)); }
@Override public Map<String, String> getGroupRoles( UUID groupId ) throws Exception { return cast( getDictionaryAsMap( new SimpleEntityRef( Group.ENTITY_TYPE, groupId ), DICTIONARY_ROLENAMES ) ); }
@Override public Set<String> getGroupPermissions( UUID groupId ) throws Exception { return cast( getDictionaryAsSet( groupRef( groupId ), Schema.DICTIONARY_PERMISSIONS ) ); }
@JsonSerialize(include = Inclusion.NON_NULL) public Map<UUID, EntityRef> getRefsMap() { if ( refsMap != null ) { return refsMap; } getEntitiesMap(); if ( entitiesMap != null ) { refsMap = cast( entitiesMap ); return refsMap; } getRefs(); if ( refs != null ) { refsMap = new LinkedHashMap<UUID, EntityRef>(); for ( EntityRef ref : refs ) { refsMap.put( ref.getUuid(), ref ); } } return refsMap; }
public List<EntityRef> getEntityRefsByType( String type ) { if ( entitiesByType != null ) { return refsByType.get( type ); } List<EntityRef> l = cast( getEntitiesByType( type ) ); if ( l != null ) { return l; } getRefs(); if ( refs == null ) { return null; } refsByType = new LinkedHashMap<String, List<EntityRef>>(); for ( Entity entity : entities ) { l = refsByType.get( entity.getType() ); if ( l == null ) { l = new ArrayList<EntityRef>(); refsByType.put( entity.getType(), l ); } l.add( entity ); } return l; }
public static CounterQuery fromJsonString( String json ) { Object o = JsonUtils.parse( json ); if ( o instanceof Map ) { @SuppressWarnings({ "unchecked", "rawtypes" }) Map<String, List<String>> params = cast( toMapList( ( Map ) o ) ); return fromQueryParams( params ); } return null; }
public static CounterQuery fromJsonString( String json ) { Object o = JsonUtils.parse( json ); if ( o instanceof Map ) { @SuppressWarnings({ "unchecked", "rawtypes" }) Map<String, List<String>> params = cast( toMapList( ( Map ) o ) ); return fromQueryParams( params ); } return null; }
public static Query fromJsonString( String json ) { Object o = JsonUtils.parse( json ); if ( o instanceof Map ) { @SuppressWarnings({ "unchecked", "rawtypes" }) Map<String, List<String>> params = cast( toMapList( ( Map ) o ) ); return fromQueryParams( params ); } return null; }
@SuppressWarnings( "unchecked" ) @Override public Map<String, Role> getGroupRolesWithTitles( UUID groupId ) throws Exception { return getRolesWithTitles( ( Set<String> ) cast( getDictionaryAsSet( groupRef(groupId), DICTIONARY_ROLENAMES ) ) ); }
@SuppressWarnings( "unchecked" ) @Override public Map<String, Role> getUserRolesWithTitles( UUID userId ) throws Exception { return getRolesWithTitles( ( Set<String> ) cast( getDictionaryAsSet( userRef( userId ), DICTIONARY_ROLENAMES ) ) ); }
public ServiceResults getEntityDictionary( ServiceContext context, List<EntityRef> refs, EntityDictionaryEntry dictionary ) throws Exception { for ( EntityDictionaryEntry entry : entityDictionaries ) { if ( entry.getName().equalsIgnoreCase( dictionary.getName() ) ) { EntityRef entityRef = refs.get( 0 ); checkPermissionsForEntitySubPath( context, entityRef, entry.getPath() ); Set<String> items = cast( em.getDictionaryAsSet( entityRef, entry.getName() ) ); return new ServiceResults( this, context, Type.GENERIC, Results.fromData( items ), null, null ); } } throw new UnsupportedServiceOperationException( context ); }
@Override public ServiceResults getServiceMetadata( ServiceContext context, String metadataType ) throws Exception { if ( "indexes".equals( metadataType ) ) { Set<String> indexes = cast( em.getCollectionIndexes( context.getOwner(), context.getCollectionName() ) ); return new ServiceResults( this, context.getRequest().withPath( context.getRequest().getPath() + "/indexes" ), context.getPreviousResults(), context.getChildPath(), Type.GENERIC, Results.fromData( indexes ), null, null ); } return null; }
@Override public ServiceResults getServiceMetadata( ServiceContext context, String metadataType ) throws Exception { if ( "indexes".equals( metadataType ) ) { String cType = context.getQuery().getConnectionType(); if ( cType != null ) { Set<String> indexes = cast( em.getConnectionIndexes( context.getOwner(), cType ) ); return new ServiceResults( this, context.getRequest().withPath( context.getRequest().getPath() + "/indexes" ), context.getPreviousResults(), context.getChildPath(), Type.GENERIC, Results.fromData( indexes ), null, null ); } } return null; }