@Override
public ServiceResults postItemsByQuery( ServiceContext context, Query query ) throws Exception {
checkPermissionsForCollection( context );
if ( !query.hasQueryPredicates() && ( query.getEntityType() != null ) ) {
Entity entity;
if ( query.containsSingleNameOrEmailIdentifier() ) {
String name = query.getSingleNameOrEmailIdentifier();
entity = em.getUniqueEntityFromAlias( query.getEntityType(), name, true);
if ( entity == null ) {
throw new ServiceResourceNotFoundException( context );
}
}
else {
entity = em.create( query.getEntityType(), context.getProperties() );
if ( entity == null ) {
throw new ServiceResourceNotFoundException( context );
}
}
entity = importEntity( context, entity );
createConnection( context.getOwner(), query.getConnectionType(), entity );
return new ServiceResults( null, context, Type.CONNECTION, Results.fromEntity( entity ), null, null );
}
return getItemsByQuery( context, query );
}