コード例 #1
0
  protected void verifyLDAPProperties() throws Exception {
    long[] companyIds = PortalInstances.getCompanyIdsBySQL();

    for (long companyId : companyIds) {
      UnicodeProperties properties = new UnicodeProperties();

      long[] ldapServerIds =
          StringUtil.split(PrefsPropsUtil.getString(companyId, "ldap.server.ids"), 0L);

      for (long ldapServerId : ldapServerIds) {
        String postfix = LDAPSettingsUtil.getPropertyPostfix(ldapServerId);

        for (String key : _LDAP_KEYS) {
          String value = PrefsPropsUtil.getString(companyId, key + postfix, null);

          if (value == null) {
            properties.put(key + postfix, StringPool.BLANK);
          }
        }
      }

      if (!properties.isEmpty()) {
        CompanyLocalServiceUtil.updatePreferences(companyId, properties);
      }
    }
  }
コード例 #2
0
  protected void deleteLDAPServer(ActionRequest actionRequest) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long ldapServerId = ParamUtil.getLong(actionRequest, "ldapServerId");

    // Remove preferences

    String postfix = LDAPSettingsUtil.getPropertyPostfix(ldapServerId);

    String[] keys = new String[_KEYS.length];

    for (int i = 0; i < _KEYS.length; i++) {
      keys[i] = _KEYS[i] + postfix;
    }

    CompanyServiceUtil.removePreferences(themeDisplay.getCompanyId(), keys);

    // Update preferences

    PortletPreferences preferences = PrefsPropsUtil.getPreferences(themeDisplay.getCompanyId());

    UnicodeProperties properties = new UnicodeProperties();

    String ldapServerIds = preferences.getValue("ldap.server.ids", StringPool.BLANK);

    ldapServerIds = StringUtil.remove(ldapServerIds, String.valueOf(ldapServerId));

    properties.put("ldap.server.ids", ldapServerIds);

    CompanyServiceUtil.updatePreferences(themeDisplay.getCompanyId(), properties);
  }
コード例 #3
0
  public static void updateSetup(HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    UnicodeProperties unicodeProperties =
        PropertiesParamUtil.getProperties(request, _PROPERTIES_PREFIX);

    unicodeProperties.setProperty(
        PropsKeys.LIFERAY_HOME, SystemProperties.get(PropsKeys.LIFERAY_HOME));

    boolean databaseConfigured = _isDatabaseConfigured(unicodeProperties);

    _processDatabaseProperties(request, unicodeProperties, databaseConfigured);

    updateLanguage(request, response);

    unicodeProperties.put(PropsKeys.SETUP_WIZARD_ENABLED, String.valueOf(false));

    PropsUtil.addProperties(unicodeProperties);

    if (!databaseConfigured) {
      _reloadServletContext(request, unicodeProperties);
    }

    _updateCompany(request);
    _updateAdminUser(request, unicodeProperties);

    _initPlugins();

    boolean propertiesFileCreated = _writePropertiesFile(unicodeProperties);

    HttpSession session = request.getSession();

    session.setAttribute(WebKeys.SETUP_WIZARD_PROPERTIES, unicodeProperties);
    session.setAttribute(WebKeys.SETUP_WIZARD_PROPERTIES_FILE_CREATED, propertiesFileCreated);
  }
コード例 #4
0
  private static void _updateAdminUser(
      HttpServletRequest request, UnicodeProperties unicodeProperties) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    Company company = CompanyLocalServiceUtil.getCompanyById(themeDisplay.getCompanyId());

    String emailAddress =
        ParamUtil.getString(
            request,
            "adminEmailAddress",
            PropsValues.DEFAULT_ADMIN_EMAIL_ADDRESS_PREFIX + StringPool.AT + company.getMx());

    PropsValues.ADMIN_EMAIL_FROM_ADDRESS = emailAddress;

    unicodeProperties.put(PropsKeys.ADMIN_EMAIL_FROM_ADDRESS, emailAddress);

    ScreenNameGenerator screenNameGenerator = ScreenNameGeneratorFactory.getInstance();

    String screenName =
        GetterUtil.getString(PropsValues.DEFAULT_ADMIN_EMAIL_ADDRESS_PREFIX, "test");

    try {
      screenName = screenNameGenerator.generate(0, 0, emailAddress);
    } catch (Exception e) {
    }

    String firstName =
        ParamUtil.getString(request, "adminFirstName", PropsValues.DEFAULT_ADMIN_FIRST_NAME);
    String lastName =
        ParamUtil.getString(request, "adminLastName", PropsValues.DEFAULT_ADMIN_LAST_NAME);

    FullNameGenerator fullNameGenerator = FullNameGeneratorFactory.getInstance();

    String fullName = fullNameGenerator.getFullName(firstName, null, lastName);

    PropsValues.ADMIN_EMAIL_FROM_NAME = fullName;

    unicodeProperties.put(PropsKeys.ADMIN_EMAIL_FROM_NAME, fullName);

    User user = null;

    try {
      user = UserLocalServiceUtil.getUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress);

      String greeting =
          LanguageUtil.format(
              themeDisplay.getLocale(), "welcome-x", StringPool.SPACE + fullName, false);

      Contact contact = user.getContact();

      Calendar birthdayCal = CalendarFactoryUtil.getCalendar();

      birthdayCal.setTime(contact.getBirthday());

      int birthdayMonth = birthdayCal.get(Calendar.MONTH);
      int birthdayDay = birthdayCal.get(Calendar.DAY_OF_MONTH);
      int birthdayYear = birthdayCal.get(Calendar.YEAR);

      user =
          UserLocalServiceUtil.updateUser(
              user.getUserId(),
              StringPool.BLANK,
              StringPool.BLANK,
              StringPool.BLANK,
              false,
              user.getReminderQueryQuestion(),
              user.getReminderQueryAnswer(),
              screenName,
              emailAddress,
              user.getFacebookId(),
              user.getOpenId(),
              themeDisplay.getLanguageId(),
              user.getTimeZoneId(),
              greeting,
              user.getComments(),
              firstName,
              user.getMiddleName(),
              lastName,
              contact.getPrefixId(),
              contact.getSuffixId(),
              contact.isMale(),
              birthdayMonth,
              birthdayDay,
              birthdayYear,
              contact.getSmsSn(),
              contact.getAimSn(),
              contact.getFacebookSn(),
              contact.getIcqSn(),
              contact.getJabberSn(),
              contact.getMsnSn(),
              contact.getMySpaceSn(),
              contact.getSkypeSn(),
              contact.getTwitterSn(),
              contact.getYmSn(),
              contact.getJobTitle(),
              null,
              null,
              null,
              null,
              null,
              new ServiceContext());
    } catch (NoSuchUserException nsue) {
      UserLocalServiceUtil.addDefaultAdminUser(
          themeDisplay.getCompanyId(),
          screenName,
          emailAddress,
          themeDisplay.getLocale(),
          firstName,
          StringPool.BLANK,
          lastName);

      user = UserLocalServiceUtil.getUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress);

      String defaultAdminEmailAddress =
          PropsValues.DEFAULT_ADMIN_EMAIL_ADDRESS_PREFIX + "@" + PropsValues.COMPANY_DEFAULT_WEB_ID;

      if (!emailAddress.equals(defaultAdminEmailAddress)) {
        User testUser =
            UserLocalServiceUtil.fetchUserByEmailAddress(
                themeDisplay.getCompanyId(), defaultAdminEmailAddress);

        if (testUser != null) {
          UserLocalServiceUtil.updateStatus(
              testUser.getUserId(), WorkflowConstants.STATUS_INACTIVE);
        }
      }
    }

    user = UserLocalServiceUtil.updatePasswordReset(user.getUserId(), true);

    HttpSession session = request.getSession();

    session.setAttribute(WebKeys.EMAIL_ADDRESS, emailAddress);
    session.setAttribute(WebKeys.SETUP_WIZARD_PASSWORD_UPDATED, true);
    session.setAttribute(WebKeys.USER_ID, user.getUserId());
  }
コード例 #5
0
  public DLFolder updateStatus(
      long userId,
      long folderId,
      int status,
      Map<String, Serializable> workflowContext,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    // Folder

    User user = userPersistence.findByPrimaryKey(userId);

    DLFolder dlFolder = dlFolderPersistence.findByPrimaryKey(folderId);

    int oldStatus = dlFolder.getStatus();

    dlFolder.setStatus(status);
    dlFolder.setStatusByUserId(user.getUserId());
    dlFolder.setStatusByUserName(user.getFullName());
    dlFolder.setStatusDate(new Date());

    dlFolderPersistence.update(dlFolder);

    // Folders, file entries, and file shortcuts

    QueryDefinition queryDefinition = new QueryDefinition(WorkflowConstants.STATUS_ANY);

    List<Object> foldersAndFileEntriesAndFileShortcuts =
        getFoldersAndFileEntriesAndFileShortcuts(
            dlFolder.getGroupId(), folderId, null, false, queryDefinition);

    dlAppHelperLocalService.updateDependentStatus(
        user, foldersAndFileEntriesAndFileShortcuts, status);

    // Asset

    if (status == WorkflowConstants.STATUS_APPROVED) {
      assetEntryLocalService.updateVisible(DLFolder.class.getName(), dlFolder.getFolderId(), true);
    } else if (status == WorkflowConstants.STATUS_IN_TRASH) {
      assetEntryLocalService.updateVisible(DLFolder.class.getName(), dlFolder.getFolderId(), false);
    }

    // Trash

    if (status == WorkflowConstants.STATUS_IN_TRASH) {
      UnicodeProperties typeSettingsProperties = new UnicodeProperties();

      typeSettingsProperties.put("title", dlFolder.getName());

      trashEntryLocalService.addTrashEntry(
          userId,
          dlFolder.getGroupId(),
          DLFolderConstants.getClassName(),
          dlFolder.getFolderId(),
          WorkflowConstants.STATUS_APPROVED,
          null,
          typeSettingsProperties);
    } else {
      trashEntryLocalService.deleteEntry(DLFolderConstants.getClassName(), dlFolder.getFolderId());
    }

    // Indexer

    if (((status == WorkflowConstants.STATUS_APPROVED)
            || (status == WorkflowConstants.STATUS_IN_TRASH)
            || (oldStatus == WorkflowConstants.STATUS_IN_TRASH))
        && ((serviceContext == null) || serviceContext.isIndexingEnabled())) {

      Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(DLFolderConstants.getClassName());

      indexer.reindex(dlFolder);
    }

    return dlFolder;
  }