@Override
 public void execute() throws Exception {
   if (newUrlName == null || newUrlName.trim().length() == 0) {
     throw new JsonException("Must not be null");
   }
   newUrlName = newUrlName.trim();
   if (newUrlName.indexOf(' ') > -1) {
     throw new JsonException("Must not have spaces in it");
   }
   Key restId = Authentication.getLoggedUserKey(session);
   if (restId == null) {
     throw new JsonException("Must be authenticated");
   }
   RestaurantManager restMan = new RestaurantManager();
   String oldUrl = restMan.getRestaurant(restId).getUniqueUrlName();
   restMan.updateUniqueUrl(restId, newUrlName);
   UniqueUrlFilter.replace(oldUrl, newUrlName);
   status = "ok";
 }
コード例 #2
0
  @Override
  public void execute() throws Exception {
    RestaurantManager restMan = new RestaurantManager();
    if (restaurant.getId() != null) {
      Restaurant r = restMan.get(restaurant.getId());
      r.setFormalName(restaurant.getFormalName());
      r.setFormalDocumentId(restaurant.getFormalDocumentId());
      r.setFormalName(restaurant.getFormalName());
      r.setName(restaurant.getName());
      r.setPersonInChargeName(restaurant.getPersonInChargeName());
      r.setUrl(restaurant.getUrl());
      r.setDescription(restaurant.getDescription());
      r.setContact(restaurant.getContact());
      NeighborhoodManager nman = new NeighborhoodManager();
      AddressManager addMan = new AddressManager();
      address.setNeighborhood(neighborhood);
      Address changedAddress = addMan.changeAddress(address);

      UserBeanManager uman = new UserBeanManager();
      UserBean ub = uman.find(user.getId(), UserBean.class);
      ub.setLogin(user.getLogin());
      uman.update(ub);
      r.setUser(ub);
      r.setAddress(changedAddress.getId());

      restMan.update(r);

    } else {

      AddressManager man = new AddressManager();
      address.setNeighborhood(neighborhood);
      man.createAddres(address);
      restaurant.setAddress(address.getId());
      restaurant.setUser(user);
      ContactInfo cinfo = new ContactInfo(user.getLogin());
      restaurant.setContact(cinfo);
      restMan.create(restaurant);
    }
  }