Example usage for com.liferay.portal.kernel.util StringPool PERIOD

List of usage examples for com.liferay.portal.kernel.util StringPool PERIOD

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util StringPool PERIOD.

Prototype

String PERIOD

To view the source code for com.liferay.portal.kernel.util StringPool PERIOD.

Click Source Link

Usage

From source file:com.liferay.faces.bridge.context.map.internal.MultiPartFormDataProcessorImpl.java

License:Open Source License

protected String stripIllegalCharacters(String fileName) {

    // FACES-64: Need to strip out invalid characters.
    // http://technet.microsoft.com/en-us/library/cc956689.aspx
    String strippedFileName = fileName;

    if (fileName != null) {

        int pos = fileName.lastIndexOf(StringPool.PERIOD);
        strippedFileName = fileName.replaceAll("[\\\\/\\[\\]:|<>+;=.?\"]", StringPool.DASH);

        if (pos > 0) {
            strippedFileName = strippedFileName.substring(0, pos) + StringPool.PERIOD
                    + strippedFileName.substring(pos + 1);
        }/*from   w  ww . ja v  a 2s  .c  o m*/
    }

    return strippedFileName;
}

From source file:com.liferay.frontend.taglib.form.navigator.internal.configuration.FormNavigatorEntryConfigurationHelperImpl.java

License:Open Source License

private String _getKey(String key, String formNavigatorId) {
    return formNavigatorId + StringPool.PERIOD + key;
}

From source file:com.liferay.frontend.taglib.form.navigator.internal.configuration.FormNavigatorEntryConfigurationParser.java

License:Open Source License

public Optional<List<String>> getFormNavigatorEntryKeys(String categoryKey, String context) {

    List<String> formNavigatorEntryKeys = null;

    if (Validator.isNotNull(categoryKey) && Validator.isNotNull(context)) {
        formNavigatorEntryKeys = _formNavigatorEntryKeysMap.get(context + StringPool.PERIOD + categoryKey);
    } else if (Validator.isNotNull(context)) {
        formNavigatorEntryKeys = _formNavigatorEntryKeysMap.get(context);
    }//from  w  w w  . j  av a 2s . c  o m

    if (formNavigatorEntryKeys == null) {
        formNavigatorEntryKeys = _formNavigatorEntryKeysMap.get(categoryKey);
    }

    return Optional.ofNullable(formNavigatorEntryKeys);
}

From source file:com.liferay.google.drive.repository.GoogleDriveRepository.java

License:Open Source License

@Override
public ExtRepositoryFileVersion getExtRepositoryFileVersion(ExtRepositoryFileEntry extRepositoryFileEntry,
        String version) throws PortalException {

    try {/*from ww  w  . ja v a2s . c  om*/
        Drive drive = getDrive();

        Drive.Revisions driveRevisions = drive.revisions();

        Drive.Revisions.List driveRevisionsList = driveRevisions
                .list(extRepositoryFileEntry.getExtRepositoryModelKey());

        RevisionList revisionList = driveRevisionsList.execute();

        List<Revision> revisions = revisionList.getItems();

        int[] versionParts = StringUtil.split(version, StringPool.PERIOD, 0);

        Revision revision = revisions.get(versionParts[0]);

        return new GoogleDriveFileVersion(revision, extRepositoryFileEntry.getExtRepositoryModelKey(),
                versionParts[0]);
    } catch (IOException ioe) {
        _log.error(ioe, ioe);

        throw new SystemException(ioe);
    }
}

From source file:com.liferay.journal.exportimport.data.handler.JournalArticleStagedModelDataHandler.java

License:Open Source License

@Override
protected void doExportStagedModel(PortletDataContext portletDataContext, JournalArticle article)
        throws Exception {

    Element articleElement = portletDataContext.getExportDataElement(article);

    articleElement.addAttribute("article-resource-uuid", article.getArticleResourceUuid());

    if (article.getFolderId() != JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

        StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, article, article.getFolder(),
                PortletDataContext.REFERENCE_TYPE_PARENT);
    }//from w  w  w  .ja va2 s.  c  o m

    DDMStructure ddmStructure = _ddmStructureLocalService.getStructure(article.getGroupId(),
            _portal.getClassNameId(JournalArticle.class), article.getDDMStructureKey(), true);

    StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, article, ddmStructure,
            PortletDataContext.REFERENCE_TYPE_STRONG);

    if (article.getClassNameId() != _portal.getClassNameId(DDMStructure.class)) {

        DDMTemplate ddmTemplate = _ddmTemplateLocalService.getTemplate(article.getGroupId(),
                _portal.getClassNameId(DDMStructure.class), article.getDDMTemplateKey(), true);

        StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, article, ddmTemplate,
                PortletDataContext.REFERENCE_TYPE_STRONG);
    }

    Layout layout = article.getLayout();

    if (layout != null) {
        portletDataContext.addReferenceElement(article, articleElement, layout,
                PortletDataContext.REFERENCE_TYPE_DEPENDENCY, true);
    }

    if (article.isSmallImage()) {
        if (Validator.isNotNull(article.getSmallImageURL())) {
            String smallImageURL = _journalArticleExportImportContentProcessor.replaceExportContentReferences(
                    portletDataContext, article, article.getSmallImageURL() + StringPool.SPACE, true, false);

            article.setSmallImageURL(smallImageURL);
        } else {
            Image smallImage = _imageLocalService.fetchImage(article.getSmallImageId());

            if ((smallImage != null) && (smallImage.getTextObj() != null)) {
                String smallImagePath = ExportImportPathUtil.getModelPath(article,
                        smallImage.getImageId() + StringPool.PERIOD + smallImage.getType());

                articleElement.addAttribute("small-image-path", smallImagePath);

                article.setSmallImageType(smallImage.getType());

                portletDataContext.addZipEntry(smallImagePath, smallImage.getTextObj());
            } else {
                if (_log.isWarnEnabled()) {
                    StringBundler sb = new StringBundler(4);

                    sb.append("Unable to export small image ");
                    sb.append(article.getSmallImageId());
                    sb.append(" to article ");
                    sb.append(article.getArticleId());

                    _log.warn(sb.toString());
                }

                article.setSmallImage(false);
                article.setSmallImageId(0);
            }
        }
    }

    JournalArticle latestArticle = _journalArticleLocalService.fetchLatestArticle(article.getResourcePrimKey());

    if ((latestArticle != null) && (latestArticle.getId() == article.getId())) {

        for (FileEntry fileEntry : article.getImagesFileEntries()) {
            StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, article, fileEntry,
                    PortletDataContext.REFERENCE_TYPE_WEAK);
        }
    }

    article.setStatusByUserUuid(article.getStatusByUserUuid());

    String content = _journalArticleExportImportContentProcessor.replaceExportContentReferences(
            portletDataContext, article, article.getContent(),
            portletDataContext.getBooleanParameter("journal", "referenced-content"), false);

    article.setContent(content);

    long defaultUserId = _userLocalService.getDefaultUserId(article.getCompanyId());

    if (defaultUserId == article.getUserId()) {
        articleElement.addAttribute("preloaded", "true");
    }

    portletDataContext.addClassedModel(articleElement, ExportImportPathUtil.getModelPath(article), article);
}

From source file:com.liferay.journal.web.internal.upload.ImageJournalUploadHandler.java

License:Open Source License

@Override
public void validateFile(String fileName, String contentType, long size) throws PortalException {

    _dlValidator.validateFileSize(fileName, size);

    String extension = FileUtil.getExtension(fileName);

    for (String imageExtension : _journalFileUploadsConfiguration.imageExtensions()) {

        if (StringPool.STAR.equals(imageExtension) || imageExtension.equals(StringPool.PERIOD + extension)) {

            return;
        }//from ww w.  java 2  s.co m
    }

    throw new ImageTypeException("Invalid image type for file name " + fileName);
}

From source file:com.liferay.journal.web.util.ExportArticleUtil.java

License:Open Source License

public void sendFile(String targetExtension, PortletRequest portletRequest, PortletResponse portletResponse)
        throws IOException {

    if (Validator.isNull(targetExtension)) {
        return;//from  ww w .  ja v  a 2 s  .c  o m
    }

    long groupId = ParamUtil.getLong(portletRequest, "groupId");
    String articleId = ParamUtil.getString(portletRequest, "articleId");

    String languageId = LanguageUtil.getLanguageId(portletRequest);
    PortletRequestModel portletRequestModel = new PortletRequestModel(portletRequest, portletResponse);
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
    HttpServletRequest request = _portal.getHttpServletRequest(portletRequest);
    HttpServletResponse response = _portal.getHttpServletResponse(portletResponse);

    JournalArticleDisplay articleDisplay = _journalContent.getDisplay(groupId, articleId, null, "export",
            languageId, 1, portletRequestModel, themeDisplay);

    int pages = articleDisplay.getNumberOfPages();

    StringBundler sb = new StringBundler(pages + 12);

    sb.append("<html>");

    sb.append("<head>");
    sb.append("<meta content=\"");
    sb.append(ContentTypes.TEXT_HTML_UTF8);
    sb.append("\" http-equiv=\"content-type\" />");
    sb.append("<base href=\"");
    sb.append(themeDisplay.getPortalURL());
    sb.append("\" />");
    sb.append("</head>");

    sb.append("<body>");

    sb.append(articleDisplay.getContent());

    for (int i = 2; i <= pages; i++) {
        articleDisplay = _journalContent.getDisplay(groupId, articleId, "export", languageId, i, themeDisplay);

        sb.append(articleDisplay.getContent());
    }

    sb.append("</body>");
    sb.append("</html>");

    InputStream is = new UnsyncByteArrayInputStream(sb.toString().getBytes(StringPool.UTF8));

    String title = articleDisplay.getTitle();
    String sourceExtension = "html";

    String fileName = title.concat(StringPool.PERIOD).concat(sourceExtension);

    String contentType = ContentTypes.TEXT_HTML;

    String id = DLUtil.getTempFileId(articleDisplay.getId(), String.valueOf(articleDisplay.getVersion()),
            languageId);

    File convertedFile = DocumentConversionUtil.convert(id, is, sourceExtension, targetExtension);

    if (convertedFile != null) {
        targetExtension = StringUtil.toLowerCase(targetExtension);

        fileName = title.concat(StringPool.PERIOD).concat(targetExtension);

        contentType = MimeTypesUtil.getContentType(fileName);

        is = new FileInputStream(convertedFile);
    }

    ServletResponseUtil.sendFile(request, response, fileName, is, contentType);
}

From source file:com.liferay.knowledgebase.admin.importer.KBArticleImporter.java

License:Open Source License

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))) {

            continue;
        }/*from   ww w. ja v a 2s  . c  o m*/

        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;
}

From source file:com.liferay.knowledgebase.model.impl.FreeMarkerKBTemplateParserImpl.java

License:Open Source License

protected String getFreeMarkerTemplateId(long groupId, long kbTemplateId) {
    return String.valueOf(groupId).concat(StringPool.PERIOD).concat(String.valueOf(kbTemplateId));
}

From source file:com.liferay.knowledgebase.model.impl.VelocityKBTemplateParserImpl.java

License:Open Source License

protected String getVelocityTemplateId(long groupId, long kbTemplateId) {
    return String.valueOf(groupId).concat(StringPool.PERIOD).concat(String.valueOf(kbTemplateId));
}