Пример #1
0
  public UserConfig getUserConfig(String companyId) throws PortalException, SystemException {

    String type = UserConfig.USER_CONFIG;
    String name = UserConfig.USER_CONFIG;

    List configs = getAdminConfig(companyId, type);

    AdminConfig config = null;

    UserConfig userConfig = null;

    if (configs.size() == 0) {
      String configId = Long.toString(CounterManagerUtil.increment(AdminConfig.class.getName()));

      Company company = CompanyManagerUtil.getCompany(companyId);

      userConfig =
          new UserConfig(
              UserConfig.DEFAULT_GROUPS,
              UserConfig.DEFAULT_ROLES,
              UserConfig.DEFAULT_RESERVED_USER_IDS,
              UserConfig.DEFAULT_RESERVED_USER_EMAIL_ADDRESSES,
              UserConfig.DEFAULT_MAIL_HOST_NAMES,
              _getUserConfigRegistrationEmail());

      config = AdminConfigUtil.create(configId);

      config.setCompanyId(companyId);
      config.setType(type);
      config.setName(name);
      config.setConfigObj(userConfig);

      AdminConfigUtil.update(config);

      configs.add(config);
    } else {
      config = (AdminConfig) configs.iterator().next();

      userConfig = (UserConfig) config.getConfigObj();
    }

    // Make sure new fields are not null

    if (userConfig.getRegistrationEmail() == null) {
      userConfig.setRegistrationEmail(_getUserConfigRegistrationEmail());

      config.setConfigObj(userConfig);

      AdminConfigUtil.update(config);
    }

    return userConfig;
  }
Пример #2
0
  public JournalConfig getJournalConfig(String companyId, String portletId)
      throws PortalException, SystemException {

    String type = JournalConfig.JOURNAL_CONFIG + "." + portletId;
    String name = JournalConfig.JOURNAL_CONFIG;

    List configs = getAdminConfig(companyId, type);

    AdminConfig config = null;

    JournalConfig journalConfig = null;

    if (configs.size() == 0) {
      String configId = Long.toString(CounterManagerUtil.increment(AdminConfig.class.getName()));

      Company company = CompanyManagerUtil.getCompany(companyId);

      journalConfig =
          new JournalConfig(
              JournalConfig.DEFAULT_ALLOW_SIMPLE_ARTICLES,
              _getJournalApprovalRequestedEmail(),
              _getJournalApprovalGrantedEmail(),
              _getJournalApprovalDeniedEmail());

      config = AdminConfigUtil.create(configId);

      config.setCompanyId(companyId);
      config.setType(type);
      config.setName(name);
      config.setConfigObj(journalConfig);

      AdminConfigUtil.update(config);

      configs.add(config);
    } else {
      config = (AdminConfig) configs.iterator().next();

      journalConfig = (JournalConfig) config.getConfigObj();
    }

    return journalConfig;
  }
Пример #3
0
  public ShoppingConfig getShoppingConfig(String companyId)
      throws PortalException, SystemException {

    String type = ShoppingConfig.SHOPPING_CONFIG;
    String name = ShoppingConfig.SHOPPING_CONFIG;

    List configs = getAdminConfig(companyId, type);

    AdminConfig config = null;

    ShoppingConfig shoppingConfig = null;

    if (configs.size() == 0) {
      String configId = Long.toString(CounterManagerUtil.increment(AdminConfig.class.getName()));

      Company company = CompanyManagerUtil.getCompany(companyId);

      shoppingConfig =
          new ShoppingConfig(
              company.getEmailAddress(),
              ShoppingConfig.CC_TYPES,
              ShoppingConfig.DEFAULT_CURRENCY_ID,
              GetterUtil.get(company.getState(), ShoppingConfig.DEFAULT_TAX_STATE),
              ShoppingConfig.DEFAULT_TAX_RATE,
              ShoppingConfig.DEFAULT_SHIPPING_FORMULA,
              ShoppingConfig.DEFAULT_SHIPPING,
              ShoppingConfig.DEFAULT_ALTERNATIVE_SHIPPING,
              ShoppingConfig.DEFAULT_MIN_ORDER,
              ShoppingConfig.DEFAULT_SHOW_SPECIAL_ITEMS,
              _getShoppingConfigOrderEmail(),
              _getShoppingConfigShippingEmail());

      config = AdminConfigUtil.create(configId);

      config.setCompanyId(companyId);
      config.setType(type);
      config.setName(name);
      config.setConfigObj(shoppingConfig);

      AdminConfigUtil.update(config);

      configs.add(config);
    } else {
      config = (AdminConfig) configs.iterator().next();

      shoppingConfig = (ShoppingConfig) config.getConfigObj();
    }

    // Make sure new fields are not null

    if (shoppingConfig.getCcTypes() == null) {
      shoppingConfig.setCcTypes(new String[0]);

      config.setConfigObj(shoppingConfig);

      AdminConfigUtil.update(config);
    }

    if (shoppingConfig.getOrderEmail() == null) {
      shoppingConfig.setOrderEmail(_getShoppingConfigOrderEmail());

      config.setConfigObj(shoppingConfig);

      AdminConfigUtil.update(config);
    }

    if (shoppingConfig.getShippingEmail() == null) {
      shoppingConfig.setShippingEmail(_getShoppingConfigShippingEmail());

      config.setConfigObj(shoppingConfig);

      AdminConfigUtil.update(config);
    }

    return shoppingConfig;
  }