コード例 #1
0
  protected void validate(
      long websiteId,
      long companyId,
      long classNameId,
      long classPK,
      String url,
      int typeId,
      boolean primary)
      throws PortalException, SystemException {

    if (!Validator.isUrl(url)) {
      throw new WebsiteURLException();
    }

    if (websiteId > 0) {
      Website website = websitePersistence.findByPrimaryKey(websiteId);

      companyId = website.getCompanyId();
      classNameId = website.getClassNameId();
      classPK = website.getClassPK();
    }

    listTypeService.validate(typeId, classNameId, ListTypeConstants.WEBSITE);

    validate(websiteId, companyId, classNameId, classPK, primary);
  }
  @Override
  protected void doImportStagedModel(PortletDataContext portletDataContext, Website website)
      throws Exception {

    long userId = portletDataContext.getUserId(website.getUserUuid());

    ServiceContext serviceContext = portletDataContext.createServiceContext(website);

    Website existingWebsite =
        _websiteLocalService.fetchWebsiteByUuidAndCompanyId(
            website.getUuid(), portletDataContext.getCompanyGroupId());

    Website importedWebsite = null;

    if (existingWebsite == null) {
      serviceContext.setUuid(website.getUuid());

      importedWebsite =
          _websiteLocalService.addWebsite(
              userId,
              website.getClassName(),
              website.getClassPK(),
              website.getUrl(),
              website.getTypeId(),
              website.isPrimary(),
              serviceContext);
    } else {
      importedWebsite =
          _websiteLocalService.updateWebsite(
              existingWebsite.getWebsiteId(), website.getUrl(),
              website.getTypeId(), website.isPrimary());
    }

    portletDataContext.importClassedModel(website, importedWebsite);
  }