@Override
public ServiceResults deleteItemsByQuery( ServiceContext context, Query query ) throws Exception {
checkPermissionsForCollection( context );
if ( !query.hasQueryPredicates() && ( query.getEntityType() != null ) && query
.containsNameOrEmailIdentifiersOnly() ) {
String name = query.getSingleNameOrEmailIdentifier();
String nameProperty = Schema.getDefaultSchema().aliasProperty( query.getEntityType() );
if ( nameProperty == null ) {
nameProperty = "name";
}
Entity entity = em.getUniqueEntityFromAlias( query.getEntityType(), name, true);
if ( entity == null ) {
throw new ServiceResourceNotFoundException( context );
}
entity = importEntity( context, entity );
deleteConnection( em.connectionRef( context.getOwner(), query.getConnectionType(), entity ) );
return new ServiceResults( null, context, Type.CONNECTION, Results.fromEntity( entity ), null, null );
}
return getItemsByQuery( context, query );
}