Exemplo n.º 1
0
  @Override
  public Address getAddress(long addressId) throws PortalException, SystemException {

    Address address = addressPersistence.findByPrimaryKey(addressId);

    CommonPermissionUtil.check(
        getPermissionChecker(), address.getClassNameId(), address.getClassPK(), ActionKeys.VIEW);

    return address;
  }
Exemplo n.º 2
0
  @Override
  public void deleteAddress(long addressId) throws PortalException, SystemException {

    Address address = addressPersistence.findByPrimaryKey(addressId);

    CommonPermissionUtil.check(
        getPermissionChecker(), address.getClassNameId(), address.getClassPK(), ActionKeys.UPDATE);

    addressLocalService.deleteAddress(address);
  }
Exemplo n.º 3
0
  @Override
  public Address updateAddress(
      long addressId,
      String street1,
      String street2,
      String street3,
      String city,
      String zip,
      long regionId,
      long countryId,
      int typeId,
      boolean mailing,
      boolean primary)
      throws PortalException, SystemException {

    Address address = addressPersistence.findByPrimaryKey(addressId);

    CommonPermissionUtil.check(
        getPermissionChecker(), address.getClassNameId(), address.getClassPK(), ActionKeys.UPDATE);

    return addressLocalService.updateAddress(
        addressId, street1, street2, street3, city, zip, regionId, countryId, typeId, mailing,
        primary);
  }
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    Address newAddress = _persistence.create(pk);

    newAddress.setMvccVersion(RandomTestUtil.nextLong());

    newAddress.setUuid(RandomTestUtil.randomString());

    newAddress.setCompanyId(RandomTestUtil.nextLong());

    newAddress.setUserId(RandomTestUtil.nextLong());

    newAddress.setUserName(RandomTestUtil.randomString());

    newAddress.setCreateDate(RandomTestUtil.nextDate());

    newAddress.setModifiedDate(RandomTestUtil.nextDate());

    newAddress.setClassNameId(RandomTestUtil.nextLong());

    newAddress.setClassPK(RandomTestUtil.nextLong());

    newAddress.setStreet1(RandomTestUtil.randomString());

    newAddress.setStreet2(RandomTestUtil.randomString());

    newAddress.setStreet3(RandomTestUtil.randomString());

    newAddress.setCity(RandomTestUtil.randomString());

    newAddress.setZip(RandomTestUtil.randomString());

    newAddress.setRegionId(RandomTestUtil.nextLong());

    newAddress.setCountryId(RandomTestUtil.nextLong());

    newAddress.setTypeId(RandomTestUtil.nextLong());

    newAddress.setMailing(RandomTestUtil.randomBoolean());

    newAddress.setPrimary(RandomTestUtil.randomBoolean());

    newAddress.setLastPublishDate(RandomTestUtil.nextDate());

    _addresses.add(_persistence.update(newAddress));

    Address existingAddress = _persistence.findByPrimaryKey(newAddress.getPrimaryKey());

    Assert.assertEquals(existingAddress.getMvccVersion(), newAddress.getMvccVersion());
    Assert.assertEquals(existingAddress.getUuid(), newAddress.getUuid());
    Assert.assertEquals(existingAddress.getAddressId(), newAddress.getAddressId());
    Assert.assertEquals(existingAddress.getCompanyId(), newAddress.getCompanyId());
    Assert.assertEquals(existingAddress.getUserId(), newAddress.getUserId());
    Assert.assertEquals(existingAddress.getUserName(), newAddress.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingAddress.getCreateDate()),
        Time.getShortTimestamp(newAddress.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingAddress.getModifiedDate()),
        Time.getShortTimestamp(newAddress.getModifiedDate()));
    Assert.assertEquals(existingAddress.getClassNameId(), newAddress.getClassNameId());
    Assert.assertEquals(existingAddress.getClassPK(), newAddress.getClassPK());
    Assert.assertEquals(existingAddress.getStreet1(), newAddress.getStreet1());
    Assert.assertEquals(existingAddress.getStreet2(), newAddress.getStreet2());
    Assert.assertEquals(existingAddress.getStreet3(), newAddress.getStreet3());
    Assert.assertEquals(existingAddress.getCity(), newAddress.getCity());
    Assert.assertEquals(existingAddress.getZip(), newAddress.getZip());
    Assert.assertEquals(existingAddress.getRegionId(), newAddress.getRegionId());
    Assert.assertEquals(existingAddress.getCountryId(), newAddress.getCountryId());
    Assert.assertEquals(existingAddress.getTypeId(), newAddress.getTypeId());
    Assert.assertEquals(existingAddress.getMailing(), newAddress.getMailing());
    Assert.assertEquals(existingAddress.getPrimary(), newAddress.getPrimary());
    Assert.assertEquals(
        Time.getShortTimestamp(existingAddress.getLastPublishDate()),
        Time.getShortTimestamp(newAddress.getLastPublishDate()));
  }