public Boolean deleteVSByName(String name) {
   Query query =
       em.createQuery("SELECT v FROM VirtualStorage v WHERE v.nombre=:name")
           .setParameter("nombre", name);
   VirtualStorage virtualStorage = (VirtualStorage) query.getResultList().get(0);
   virtualStorage.setEnabled(false);
   em.merge(virtualStorage);
   return true;
 }
 public int AVPorUsuario(String nick) {
   Query query = em.createQuery("SELECT vs FROM VirtualStorage vs ");
   List<VirtualStorage> retorno = query.getResultList();
   int total = 0;
   for (VirtualStorage vs : retorno) {
     if (vs.getOwner().getNick().equals(nick)) {
       total++;
     }
   }
   return total;
 }
 public String insertVS(VirtualStorage vs, int idCreador) {
   Usuario creador = udao.buscarID(idCreador);
   if (creador == null) {
     return "500-Error-Sin_Usuario";
   }
   if (searchVSByName(vs.getName()) == null) {
     return "501-Error-Ya existe AV";
   } else {
     vs.setOwner(creador);
     em.persist(vs);
     em.flush();
     return vs.getName();
   }
 }
 public String createVS(VirtualStorage vs, int ownerId) {
   try {
     Usuario owner = udao.buscarID(ownerId);
     if (owner != null) {
       vs.setOwner(owner);
       vs.setCreatedDate(new Date());
       em.persist(vs);
       em.flush();
       return String.valueOf(vs.getId());
     }
     return "500-Error-no_existe_usuario";
   } catch (Exception ex) {
     return "500-Error-" + ex.getMessage();
   }
 }