コード例 #1
0
  public String getDDLRecordSetDisplayStyle() {
    if (_ddlRecordDisplayStyle == null) {
      PortalPreferences portalPreferences =
          PortletPreferencesFactoryUtil.getPortalPreferences(_ddlRequestHelper.getRenderRequest());

      _ddlRecordDisplayStyle =
          ParamUtil.getString(_ddlRequestHelper.getRenderRequest(), "displayStyle");

      if (Validator.isNull(_ddlRecordDisplayStyle)) {
        _ddlRecordDisplayStyle =
            portalPreferences.getValue(
                DDLPortletKeys.DYNAMIC_DATA_LISTS,
                "display-style",
                _ddlWebConfiguration.defaultDisplayView());
      } else if (ArrayUtil.contains(getDDLRecordSetDisplayViews(), _ddlRecordDisplayStyle)) {

        portalPreferences.setValue(
            DDLPortletKeys.DYNAMIC_DATA_LISTS, "display-style", _ddlRecordDisplayStyle);
      }

      if (!ArrayUtil.contains(getDDLRecordSetDisplayViews(), _ddlRecordDisplayStyle)) {

        _ddlRecordDisplayStyle = getDDLRecordSetDisplayViews()[0];
      }
    }

    return _ddlRecordDisplayStyle;
  }
コード例 #2
0
  private static List<String> _getDependencies(String bundleId, List<String> dependencies) {

    if (!ArrayUtil.contains(PropsValues.JAVASCRIPT_BUNDLE_IDS, bundleId)) {
      return dependencies;
    }

    String[] bundleDependencies =
        PropsUtil.getArray(PropsKeys.JAVASCRIPT_BUNDLE_DEPENDENCIES, new Filter(bundleId));

    for (String bundleDependency : bundleDependencies) {
      String[] bundleDependencyDependencies =
          PropsUtil.getArray(
              PropsKeys.JAVASCRIPT_BUNDLE_DEPENDENCIES, new Filter(bundleDependency));

      if (!ArrayUtil.contains(bundleDependencyDependencies, bundleId)) {
        _getDependencies(bundleDependency, dependencies);
      }

      dependencies.add(bundleDependency);
    }

    dependencies.add(bundleId);

    return dependencies;
  }
コード例 #3
0
  protected String getDisplayStyle(HttpServletRequest request, String[] displayViews) {

    PortalPreferences portalPreferences =
        PortletPreferencesFactoryUtil.getPortalPreferences(request);

    String displayStyle = ParamUtil.getString(request, "displayStyle");

    if (Validator.isNull(displayStyle)) {
      JournalWebConfiguration journalWebConfiguration =
          (JournalWebConfiguration) _request.getAttribute(JournalWebConfiguration.class.getName());

      displayStyle =
          portalPreferences.getValue(
              JournalPortletKeys.JOURNAL,
              "display-style",
              journalWebConfiguration.defaultDisplayView());
    } else {
      if (ArrayUtil.contains(displayViews, displayStyle)) {
        portalPreferences.setValue(JournalPortletKeys.JOURNAL, "display-style", displayStyle);

        request.setAttribute(WebKeys.SINGLE_PAGE_APPLICATION_CLEAR_CACHE, Boolean.TRUE);
      }
    }

    if (!ArrayUtil.contains(displayViews, displayStyle)) {
      displayStyle = displayViews[0];
    }

    return displayStyle;
  }
コード例 #4
0
  protected Map<String, List<String>> getFolderNameFileEntryNamesMap(ZipReader zipReader) {

    Map<String, List<String>> folderNameFileEntryNamesMap = new TreeMap<String, List<String>>();

    for (String zipEntry : zipReader.getEntries()) {
      String extension = FileUtil.getExtension(zipEntry);

      if (!ArrayUtil.contains(
              PortletPropsValues.MARKDOWN_IMPORTER_ARTICLE_EXTENSIONS,
              StringPool.PERIOD.concat(extension))
          || zipEntry.equals(PortletPropsValues.MARKDOWN_IMPORTER_ARTICLE_HOME)) {

        continue;
      }

      String folderName = zipEntry.substring(0, zipEntry.lastIndexOf(StringPool.SLASH));

      List<String> fileEntryNames = folderNameFileEntryNamesMap.get(folderName);

      if (fileEntryNames == null) {
        fileEntryNames = new ArrayList<String>();
      }

      fileEntryNames.add(zipEntry);

      folderNameFileEntryNamesMap.put(folderName, fileEntryNames);
    }

    return folderNameFileEntryNamesMap;
  }
コード例 #5
0
  public String[] getAllAssetTagNames() throws Exception {
    if (_allAssetTagNames != null) {
      return _allAssetTagNames;
    }

    _allAssetTagNames = new String[0];

    String assetTagName = ParamUtil.getString(_request, "tag");

    String selectionStyle = getSelectionStyle();

    if (selectionStyle.equals("dynamic")) {
      _allAssetTagNames = AssetPublisherUtil.getAssetTagNames(_portletPreferences);
    }

    if (Validator.isNotNull(assetTagName) && !ArrayUtil.contains(_allAssetTagNames, assetTagName)) {

      _allAssetTagNames = ArrayUtil.append(_allAssetTagNames, assetTagName);
    }

    if (isMergeURLTags()) {
      _allAssetTagNames = ArrayUtil.append(_allAssetTagNames, getCompilerTagNames());
    }

    _allAssetTagNames = ArrayUtil.distinct(_allAssetTagNames, new StringComparator());

    return _allAssetTagNames;
  }
コード例 #6
0
  protected void validateDDMFormFieldIndexType(DDMFormField ddmFormField)
      throws DDMFormValidationException {

    if (!ArrayUtil.contains(_ddmFormFieldIndexTypes, ddmFormField.getIndexType())) {

      throw new MustSetValidIndexType(ddmFormField.getName());
    }
  }
コード例 #7
0
  protected void addChildCalendarBookings(
      CalendarBooking calendarBooking, long[] childCalendarIds, ServiceContext serviceContext)
      throws PortalException, SystemException {

    if (!calendarBooking.isMasterBooking()) {
      return;
    }

    List<CalendarBooking> childCalendarBookings =
        calendarBookingPersistence.findByParentCalendarBookingId(
            calendarBooking.getCalendarBookingId());

    for (CalendarBooking childCalendarBooking : childCalendarBookings) {
      if (childCalendarBooking.isMasterBooking()
          || ArrayUtil.contains(childCalendarIds, childCalendarBooking.getCalendarId())) {

        continue;
      }

      deleteCalendarBooking(childCalendarBooking.getCalendarBookingId());
    }

    for (long calendarId : childCalendarIds) {
      int count =
          calendarBookingPersistence.countByC_P(calendarId, calendarBooking.getCalendarBookingId());

      if (count > 0) {
        continue;
      }

      CalendarBooking childCalendarBooking =
          addCalendarBooking(
              calendarBooking.getUserId(),
              calendarId,
              new long[0],
              calendarBooking.getCalendarBookingId(),
              calendarBooking.getTitleMap(),
              calendarBooking.getDescriptionMap(),
              calendarBooking.getLocation(),
              calendarBooking.getStartDate(),
              calendarBooking.getEndDate(),
              calendarBooking.getAllDay(),
              calendarBooking.getRecurrence(),
              calendarBooking.getFirstReminder(),
              calendarBooking.getFirstReminderType(),
              calendarBooking.getSecondReminder(),
              calendarBooking.getSecondReminderType(),
              serviceContext);

      try {
        NotificationType notificationType =
            NotificationType.parse(PortletPropsValues.CALENDAR_NOTIFICATION_DEFAULT_TYPE);

        NotificationUtil.notifyCalendarBookingInvites(childCalendarBooking, notificationType);
      } catch (Exception e) {
      }
    }
  }
コード例 #8
0
  protected void validateDDMFormFieldIndexType(DDMFormField ddmFormField)
      throws DDMFormValidationException {

    if (!ArrayUtil.contains(_ddmFormFieldIndexTypes, ddmFormField.getIndexType())) {

      throw new DDMFormValidationException(
          "Invalid index type set for field " + ddmFormField.getName());
    }
  }
コード例 #9
0
  /** @deprecated As of 6.2.0, replaced by {@link #normalize(String, Pattern)} */
  @Deprecated
  @Override
  public String normalize(String friendlyURL, char[] replaceChars) {
    if (Validator.isNull(friendlyURL)) {
      return friendlyURL;
    }

    friendlyURL = GetterUtil.getString(friendlyURL);
    friendlyURL = StringUtil.toLowerCase(friendlyURL);
    friendlyURL = Normalizer.normalizeToAscii(friendlyURL);

    StringBuilder sb = null;

    int index = 0;

    for (int i = 0; i < friendlyURL.length(); i++) {
      char c = friendlyURL.charAt(i);

      if ((Arrays.binarySearch(_REPLACE_CHARS, c) >= 0)
          || ((replaceChars != null) && ArrayUtil.contains(replaceChars, c))) {

        if (sb == null) {
          sb = new StringBuilder();
        }

        if (i > index) {
          sb.append(friendlyURL.substring(index, i));
        }

        sb.append(CharPool.DASH);

        index = i + 1;
      }
    }

    if (sb != null) {
      if (index < friendlyURL.length()) {
        sb.append(friendlyURL.substring(index));
      }

      friendlyURL = sb.toString();
    }

    while (friendlyURL.contains(StringPool.DOUBLE_DASH)) {
      friendlyURL = StringUtil.replace(friendlyURL, StringPool.DOUBLE_DASH, StringPool.DASH);
    }

    /*if (friendlyURL.startsWith(StringPool.DASH)) {
    	friendlyURL = friendlyURL.substring(1);
    }

    if (friendlyURL.endsWith(StringPool.DASH)) {
    	friendlyURL = friendlyURL.substring(0, friendlyURL.length() - 1);
    }*/

    return friendlyURL;
  }
コード例 #10
0
  @Test
  public void testAddFileEntryType() throws Exception {
    ServiceContext serviceContext = new ServiceContext();

    byte[] testFileBytes = FileUtil.getBytes(getClass(), _TEST_DDM_STRUCTURE);

    serviceContext.setAttribute("xsd", new String(testFileBytes));

    User user = TestPropsValues.getUser();

    serviceContext.setLanguageId(LocaleUtil.toLanguageId(user.getLocale()));

    DLFileEntryType dlFileEntryType =
        DLFileEntryTypeLocalServiceUtil.addFileEntryType(
            TestPropsValues.getUserId(),
            _group.getGroupId(),
            "Test Structure",
            StringPool.BLANK,
            new long[0],
            serviceContext);

    List<DDMStructure> ddmStructures = dlFileEntryType.getDDMStructures();

    Assert.assertEquals(1, ddmStructures.size());

    DDMStructure ddmStructure = ddmStructures.get(0);

    Locale[] availableLocales = LocaleUtil.fromLanguageIds(ddmStructure.getAvailableLanguageIds());

    boolean hasDefaultLocale = ArrayUtil.contains(availableLocales, LocaleUtil.getSiteDefault());

    Assert.assertTrue(hasDefaultLocale);

    boolean hasHungarianLocale = ArrayUtil.contains(availableLocales, LocaleUtil.HUNGARY);

    Assert.assertTrue(hasHungarianLocale);

    boolean hasUserLocale = ArrayUtil.contains(availableLocales, user.getLocale());

    Assert.assertTrue(hasUserLocale);

    DLFileEntryTypeLocalServiceUtil.deleteDLFileEntryType(dlFileEntryType);
  }
コード例 #11
0
  public static String checkOrderByCol(String orderByCol) {
    if (ArrayUtil.contains(ORDER_BY_COLUMNS, orderByCol)
        || ((orderByCol != null)
            && orderByCol.startsWith(DDMStructureManager.STRUCTURE_INDEXER_FIELD_PREFIX))) {

      return orderByCol;
    }

    return ORDER_BY_COLUMNS[2];
  }
  protected void updateLayoutSetPrototype(long groupId, boolean privateLayout)
      throws PortalException {

    // Layout

    LayoutSet layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(groupId, privateLayout);

    LayoutSetPrototype layoutSetPrototype =
        LayoutSetPrototypeLocalServiceUtil.getLayoutSetPrototype(
            layoutSet.getLayoutSetPrototypeId());

    Group layoutSetPrototypeGroup = layoutSetPrototype.getGroup();

    List<Layout> layoutSetPrototypeLayouts =
        LayoutLocalServiceUtil.getLayouts(layoutSetPrototypeGroup.getGroupId(), true);

    String[] layoutSetPrototypeLayoutUuids = new String[layoutSetPrototypeLayouts.size()];

    for (int i = 0; i < layoutSetPrototypeLayouts.size(); i++) {
      Layout layout = layoutSetPrototypeLayouts.get(i);

      layoutSetPrototypeLayoutUuids[i] = layout.getUuid();
    }

    List<Layout> layouts = LayoutLocalServiceUtil.getLayouts(groupId, privateLayout);

    for (Layout layout : layouts) {
      if (ArrayUtil.contains(
          layoutSetPrototypeLayoutUuids, layout.getSourcePrototypeLayoutUuid())) {

        layout.setLayoutPrototypeUuid(StringPool.BLANK);
        layout.setLayoutPrototypeLinkEnabled(false);
        layout.setSourcePrototypeLayoutUuid(StringPool.BLANK);

        LayoutLocalServiceUtil.updateLayout(layout);
      }
    }

    // Layout set

    UnicodeProperties settingsProperties = layoutSet.getSettingsProperties();

    settingsProperties.remove("last-merge-time");

    layoutSet.setSettingsProperties(settingsProperties);

    layoutSet.setLayoutSetPrototypeUuid(StringPool.BLANK);
    layoutSet.setLayoutSetPrototypeLinkEnabled(false);

    LayoutSetLocalServiceUtil.updateLayoutSet(layoutSet);

    LayoutSetLocalServiceUtil.updateLookAndFeel(
        layoutSet.getGroupId(), null, null, StringPool.BLANK, false);
  }
コード例 #13
0
  public String getPaginationType() {
    if (_paginationType == null) {
      _paginationType =
          GetterUtil.getString(_portletPreferences.getValue("paginationType", "none"));

      if (!ArrayUtil.contains(PAGINATION_TYPES, _paginationType)) {
        _paginationType = PAGINATION_TYPE_NONE;
      }
    }

    return _paginationType;
  }
コード例 #14
0
  private void _addCompanyId(long companyId) {
    if (ArrayUtil.contains(_companyIds, companyId)) {
      return;
    }

    long[] companyIds = new long[_companyIds.length + 1];

    System.arraycopy(_companyIds, 0, companyIds, 0, _companyIds.length);

    companyIds[_companyIds.length] = companyId;

    _companyIds = companyIds;
  }
コード例 #15
0
  protected void validateBlockElement(
      String fileName,
      Element commandElement,
      String[] allowedBlockChildElementNames,
      String[] allowedExecuteAttributeNames,
      String[] allowedExecuteChildElementNames,
      String[] allowedIfConditionElementNames) {

    List<Element> elements = commandElement.elements();

    if (elements.isEmpty()) {
      throwValidationException(1001, fileName, commandElement, allowedBlockChildElementNames);
    }

    for (Element element : elements) {
      String elementName = element.getName();

      if (!ArrayUtil.contains(allowedBlockChildElementNames, elementName)) {

        throwValidationException(1002, fileName, element, elementName);
      }

      if (elementName.equals("echo") || elementName.equals("fail")) {
        validateSimpleElement(fileName, element, new String[] {"message"});
      } else if (elementName.equals("execute")) {
        validateExecuteElement(
            fileName, element, allowedExecuteAttributeNames, ".+", allowedExecuteChildElementNames);
      } else if (elementName.equals("if")) {
        validateIfElement(
            fileName,
            element,
            allowedBlockChildElementNames,
            allowedExecuteAttributeNames,
            allowedExecuteChildElementNames,
            allowedIfConditionElementNames);
      } else if (elementName.equals("var")) {
        validateVarElement(fileName, element);
      } else if (elementName.equals("while")) {
        validateWhileElement(
            fileName,
            element,
            allowedBlockChildElementNames,
            allowedExecuteAttributeNames,
            allowedExecuteChildElementNames,
            allowedIfConditionElementNames);
      } else {
        throwValidationException(1002, fileName, element, elementName);
      }
    }
  }
コード例 #16
0
  public static String getDDLRecordSetDisplayStyle(
      PortletRequest portletRequest, String[] displayViews) {

    PortalPreferences portalPreferences =
        PortletPreferencesFactoryUtil.getPortalPreferences(portletRequest);

    String displayStyle = ParamUtil.getString(portletRequest, "displayStyle");

    if (Validator.isNull(displayStyle)) {
      displayStyle =
          portalPreferences.getValue(
              DDLPortletKeys.DYNAMIC_DATA_LISTS,
              "display-style",
              DDLWebConfigurationValues.DEFAULT_DISPLAY_VIEW);
    } else if (ArrayUtil.contains(displayViews, displayStyle)) {
      portalPreferences.setValue(DDLPortletKeys.DYNAMIC_DATA_LISTS, "display-style", displayStyle);
    }

    if (!ArrayUtil.contains(displayViews, displayStyle)) {
      displayStyle = displayViews[0];
    }

    return displayStyle;
  }
コード例 #17
0
  public String normalize(String fileName, char[] replaceChars) {
    if (Validator.isNull(fileName)) {
      return fileName;
    }

    fileName = GetterUtil.getString(fileName);
    fileName = fileName.toLowerCase();
    fileName = Normalizer.normalizeToAscii(fileName);

    StringBuilder sb = null;

    int index = 0;

    for (int i = 0; i < fileName.length(); i++) {
      char c = fileName.charAt(i);

      if ((Arrays.binarySearch(_REPLACE_CHARS, c) >= 0)
          || ((replaceChars != null) && ArrayUtil.contains(replaceChars, c))) {

        if (sb == null) {
          sb = new StringBuilder();
        }

        if (i > index) {
          sb.append(fileName.substring(index, i));
        }

        sb.append(CharPool.DASH);
        // sb.append(CharPool.UNDERLINE);

        index = i + 1;
      }
    }

    if (sb != null) {
      if (index < fileName.length()) {
        sb.append(fileName.substring(index));
      }

      fileName = sb.toString();
    }

    while (fileName.indexOf(StringPool.DOUBLE_DASH) >= 0) {
      fileName = StringUtil.replace(fileName, StringPool.DOUBLE_DASH, StringPool.DASH);
    }

    return fileName;
  }
  private int _countMatchedElements(String[] parameterNames, MethodParameter[] methodParameters) {

    int matched = 0;

    for (MethodParameter methodParameter : methodParameters) {
      String methodParameterName = methodParameter.getName();

      methodParameterName = CamelCaseUtil.normalizeCamelCase(methodParameterName);

      if (ArrayUtil.contains(parameterNames, methodParameterName)) {
        matched++;
      }
    }

    return matched;
  }
コード例 #19
0
  public String[] getEntryColumns() throws PortalException, SystemException {
    String[] entryColumns = _dlPortletInstanceSettings.getEntryColumns();

    String portletId = _portletDisplay.getId();

    if (!_dlActionsDisplayContext.isShowActions()) {
      entryColumns = ArrayUtil.remove(entryColumns, "action");
    } else if (!portletId.equals(PortletKeys.DOCUMENT_LIBRARY)
        && !portletId.equals(PortletKeys.DOCUMENT_LIBRARY_ADMIN)
        && !ArrayUtil.contains(entryColumns, "action")) {

      entryColumns = ArrayUtil.append(entryColumns, "action");
    }

    return entryColumns;
  }
コード例 #20
0
  @Override
  public int countScoredFieldNames(Query query, String[] filedNames) {
    int count = 0;

    for (String fieldName : filedNames) {
      WeightedTerm[] weightedTerms = QueryTermExtractor.getTerms(query, false, fieldName);

      if ((weightedTerms.length > 0)
          && !ArrayUtil.contains(Field.UNSCORED_FIELD_NAMES, fieldName)) {

        count++;
      }
    }

    return count;
  }
コード例 #21
0
  protected void exportLayout(
      PortletDataContext portletDataContext, long[] layoutIds, Layout layout) throws Exception {

    if (!ArrayUtil.contains(layoutIds, layout.getLayoutId())) {
      Element layoutElement = portletDataContext.getExportDataElement(layout);

      layoutElement.addAttribute(Constants.ACTION, Constants.SKIP);

      return;
    }

    if (!prepareLayoutStagingHandler(portletDataContext, layout)) {
      return;
    }

    StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, layout);
  }
コード例 #22
0
  /**
   * @deprecated As of 1.5.0, replaced by {@link #sendFile(String, PortletRequest, PortletResponse)}
   */
  @Deprecated
  public void sendFile(PortletRequest portletRequest, PortletResponse portletResponse)
      throws IOException {

    String targetExtension = ParamUtil.getString(portletRequest, "targetExtension");

    PortletPreferences portletPreferences = portletRequest.getPreferences();

    String[] allowedExtensions = StringUtil.split(portletPreferences.getValue("extensions", null));

    if (Validator.isNull(targetExtension)
        || !ArrayUtil.contains(allowedExtensions, targetExtension)) {

      return;
    }

    sendFile(targetExtension, portletRequest, portletResponse);
  }
コード例 #23
0
  protected String[] appendPortletIds(
      String[] portletIds, String[] newPortletIds, String portletsMergeMode) {

    for (String portletId : newPortletIds) {
      if (ArrayUtil.contains(portletIds, portletId)) {
        continue;
      }

      if (portletsMergeMode.equals(PortletDataHandlerKeys.PORTLETS_MERGE_MODE_ADD_TO_BOTTOM)) {

        portletIds = ArrayUtil.append(portletIds, portletId);
      } else {
        portletIds = ArrayUtil.append(new String[] {portletId}, portletIds);
      }
    }

    return portletIds;
  }
  @Override
  protected void validateExport(PortletDataContext portletDataContext, DDLRecord record)
      throws PortletDataException {

    int status = WorkflowConstants.STATUS_ANY;

    try {
      status = record.getStatus();
    } catch (Exception e) {
      throw new PortletDataException(e);
    }

    if (!ArrayUtil.contains(getExportableStatuses(), status)) {
      PortletDataException pde = new PortletDataException(PortletDataException.STATUS_UNAVAILABLE);

      pde.setStagedModel(record);

      throw pde;
    }
  }
コード例 #25
0
  @Override
  protected Metadata extractMetadata(String extension, String mimeType, InputStream inputStream) {

    Metadata metadata = super.extractMetadata(extension, mimeType, inputStream);

    boolean forkProcess = false;

    if (PropsValues.TEXT_EXTRACTION_FORK_PROCESS_ENABLED) {
      if (ArrayUtil.contains(PropsValues.TEXT_EXTRACTION_FORK_PROCESS_MIME_TYPES, mimeType)) {

        forkProcess = true;
      }
    }

    if (forkProcess) {
      File file = FileUtil.createTempFile();

      try {
        FileUtil.write(file, inputStream);

        ExtractMetadataProcessCallable extractMetadataProcessCallable =
            new ExtractMetadataProcessCallable(file, metadata, _parser);

        Future<Metadata> future =
            ProcessExecutor.execute(
                ClassPathUtil.getPortalProcessConfig(), extractMetadataProcessCallable);

        return future.get();
      } catch (Exception e) {
        throw new SystemException(e);
      } finally {
        file.delete();
      }
    }

    try {
      return extractMetadata(inputStream, metadata, _parser);
    } catch (IOException ioe) {
      throw new SystemException(ioe);
    }
  }
コード例 #26
0
  protected UnicodeProperties addLDAPServer(long companyId, UnicodeProperties properties)
      throws Exception {

    String defaultPostfix = LDAPSettingsUtil.getPropertyPostfix(0);

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

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

    long ldapServerId = CounterLocalServiceUtil.increment();

    String postfix = LDAPSettingsUtil.getPropertyPostfix(ldapServerId);

    String[] keys = properties.keySet().toArray(new String[0]);

    for (String key : keys) {
      if (ArrayUtil.contains(defaultKeys, key)) {
        String value = properties.remove(key);

        if (key.equals(PropsKeys.LDAP_SECURITY_CREDENTIALS + defaultPostfix)
            && value.equals(Portal.TEMP_OBFUSCATION_VALUE)) {

          value = PrefsPropsUtil.getString(PropsKeys.LDAP_SECURITY_CREDENTIALS);
        }

        properties.setProperty(key.replace(defaultPostfix, postfix), value);
      }
    }

    PortletPreferences preferences = PrefsPropsUtil.getPreferences(companyId);

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

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

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

    return properties;
  }
コード例 #27
0
  protected SkinnyJournalArticle getSkinnyJournalArticle(
      JournalArticle journalArticle, String locale) throws Exception {

    SkinnyJournalArticle skinnyJournalArticle = new SkinnyJournalArticle();

    String content = null;

    if (ArrayUtil.contains(journalArticle.getAvailableLocales(), locale)) {
      content = journalArticle.getContentByLocale(locale);
    } else {
      content = journalArticle.getContent();
    }

    Document document = SAXReaderUtil.read(content);

    Element rootElement = document.getRootElement();

    populateSkinnyJournalArticle(skinnyJournalArticle, rootElement);

    return skinnyJournalArticle;
  }
  @Override
  protected void validateExport(PortletDataContext portletDataContext, FileEntry fileEntry)
      throws PortletDataException {

    if ((fileEntry.getGroupId() != portletDataContext.getGroupId())
        && (fileEntry.getGroupId() != portletDataContext.getScopeGroupId())) {

      PortletDataException pde = new PortletDataException(PortletDataException.INVALID_GROUP);

      pde.setStagedModel(fileEntry);

      throw pde;
    }

    try {
      FileVersion fileVersion = fileEntry.getFileVersion();

      if (!portletDataContext.isInitialPublication()
          && !ArrayUtil.contains(getExportableStatuses(), fileVersion.getStatus())) {

        throw new PortletDataException(PortletDataException.STATUS_UNAVAILABLE);
      }
    } catch (PortletDataException pde) {
      throw pde;
    } catch (Exception e) {
      if (_log.isDebugEnabled()) {
        _log.debug(e, e);
      } else if (_log.isWarnEnabled()) {
        _log.warn("Unable to check workflow status for file entry " + fileEntry.getFileEntryId());
      }
    }

    if (fileEntry.isInTrash() || fileEntry.isInTrashContainer()) {
      PortletDataException pde = new PortletDataException(PortletDataException.STATUS_IN_TRASH);

      pde.setStagedModel(fileEntry);

      throw pde;
    }
  }
コード例 #29
0
  public boolean isShowImageEditorAction() throws PortalException {
    if (_isShowImageEditorAction != null) {
      return _isShowImageEditorAction;
    }

    if (!isShowActions()) {
      _isShowImageEditorAction = false;
    } else if (!DLFileEntryPermission.contains(
            _themeDisplay.getPermissionChecker(), _fileEntry, ActionKeys.UPDATE)
        || (_fileEntry.isCheckedOut() && !_fileEntry.hasLock())) {

      _isShowImageEditorAction = false;
    } else if (!ArrayUtil.contains(
        PropsValues.DL_FILE_ENTRY_PREVIEW_IMAGE_MIME_TYPES, _fileEntry.getMimeType())) {

      _isShowImageEditorAction = false;
    } else {
      _isShowImageEditorAction = true;
    }

    return _isShowImageEditorAction;
  }
コード例 #30
0
  public long[] getAllAssetCategoryIds() throws Exception {
    if (_allAssetCategoryIds != null) {
      return _allAssetCategoryIds;
    }

    _allAssetCategoryIds = new long[0];

    long assetCategoryId = ParamUtil.getLong(_request, "categoryId");

    String selectionStyle = getSelectionStyle();

    if (selectionStyle.equals("dynamic")) {
      _allAssetCategoryIds = AssetPublisherUtil.getAssetCategoryIds(_portletPreferences);
    }

    if ((assetCategoryId > 0) && !ArrayUtil.contains(_allAssetCategoryIds, assetCategoryId)) {

      _allAssetCategoryIds = ArrayUtil.append(_allAssetCategoryIds, assetCategoryId);
    }

    return _allAssetCategoryIds;
  }