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.alloy.mvc.jsonwebservice.AlloyControllerInvokerManager.java

License:Open Source License

protected String getAlloyControllerInvokerClassName(Class<? extends AlloyController> controllerClass) {

    Package pkg = controllerClass.getPackage();

    String simpleName = StringPool.BLANK;

    Class<?> enclosingClass = controllerClass.getEnclosingClass();

    if (enclosingClass != null) {
        String name = StringUtil.replace(enclosingClass.getSimpleName(), "005f", StringPool.BLANK);

        int trimIndex = name.indexOf("_controller");

        String[] wordElements = StringUtil.split(name.substring(0, trimIndex), CharPool.UNDERLINE);

        for (String wordElement : wordElements) {
            simpleName = simpleName.concat(StringUtil.upperCaseFirstLetter(wordElement));
        }//from   w w  w . jav  a 2 s.  com

        simpleName = simpleName.concat(_BASE_CLASS_NAME);
    } else {
        simpleName = _BASE_CLASS_NAME + _counter.getAndIncrement();
    }

    return pkg.getName() + StringPool.PERIOD + simpleName;
}

From source file:com.liferay.alloy.util.DefaultValueUtil.java

License:Open Source License

public static boolean isValidStringValue(String value) {
    value = StringUtil.trim(GetterUtil.getString(value));

    if (Validator.isNull(value)) {
        return false;
    }/*from  ww w  .  ja  v a2 s.c  om*/

    if (StringUtils.isAlpha(value) || (!StringUtils.containsIgnoreCase(value, _GENERATED)
            && !StringUtils.isAlpha(value.substring(0, 1))
            && !StringUtils.endsWith(value, StringPool.PERIOD))) {

        return true;
    }

    return false;
}

From source file:com.liferay.blogs.internal.exportimport.data.handler.BlogsEntryStagedModelDataHandler.java

License:Open Source License

@Override
protected void doExportStagedModel(PortletDataContext portletDataContext, BlogsEntry entry) throws Exception {

    Element entryElement = portletDataContext.getExportDataElement(entry);

    if (entry.isSmallImage()) {
        if (entry.getSmallImageFileEntryId() > 0) {
            FileEntry fileEntry = PortletFileRepositoryUtil
                    .getPortletFileEntry(entry.getSmallImageFileEntryId());

            StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, entry, fileEntry,
                    PortletDataContext.REFERENCE_TYPE_WEAK);
        } else if (entry.getSmallImageId() > 0) {
            Image smallImage = _imageLocalService.fetchImage(entry.getSmallImageId());

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

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

                entry.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(entry.getSmallImageId());
                    sb.append(" to blogs entry ");
                    sb.append(entry.getEntryId());

                    _log.warn(sb.toString());
                }//  ww w. j ava 2  s . c  o  m

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

    if (entry.getCoverImageFileEntryId() != 0) {
        FileEntry fileEntry = PortletFileRepositoryUtil.getPortletFileEntry(entry.getCoverImageFileEntryId());

        StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, entry, fileEntry,
                PortletDataContext.REFERENCE_TYPE_WEAK);
    }

    String content = _exportImportContentProcessorController.replaceExportContentReferences(portletDataContext,
            entry, entry.getContent(), portletDataContext.getBooleanParameter("blogs", "referenced-content"),
            true);

    entry.setContent(content);

    portletDataContext.addClassedModel(entryElement, ExportImportPathUtil.getModelPath(entry), entry);
}

From source file:com.liferay.blogs.internal.exportimport.data.handler.BlogsEntryStagedModelDataHandler.java

License:Open Source License

@Override
protected void doImportStagedModel(PortletDataContext portletDataContext, BlogsEntry entry) throws Exception {

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

    Element entryElement = portletDataContext.getImportDataStagedModelElement(entry);

    String content = _exportImportContentProcessorController.replaceImportContentReferences(portletDataContext,
            entry, entry.getContent());/*from  www. j  a v a  2  s . c  o  m*/

    entry.setContent(content);

    Calendar displayDateCal = CalendarFactoryUtil.getCalendar();

    displayDateCal.setTime(entry.getDisplayDate());

    int displayDateMonth = displayDateCal.get(Calendar.MONTH);
    int displayDateDay = displayDateCal.get(Calendar.DATE);
    int displayDateYear = displayDateCal.get(Calendar.YEAR);
    int displayDateHour = displayDateCal.get(Calendar.HOUR);
    int displayDateMinute = displayDateCal.get(Calendar.MINUTE);

    if (displayDateCal.get(Calendar.AM_PM) == Calendar.PM) {
        displayDateHour += 12;
    }

    boolean allowPingbacks = entry.isAllowPingbacks();
    boolean allowTrackbacks = entry.isAllowTrackbacks();
    String[] trackbacks = StringUtil.split(entry.getTrackbacks());

    ServiceContext serviceContext = portletDataContext.createServiceContext(entry);

    BlogsEntry importedEntry = null;

    if (portletDataContext.isDataStrategyMirror()) {
        BlogsEntry existingEntry = fetchStagedModelByUuidAndGroupId(entry.getUuid(),
                portletDataContext.getScopeGroupId());

        if (existingEntry == null) {
            serviceContext.setUuid(entry.getUuid());

            importedEntry = _blogsEntryLocalService.addEntry(userId, entry.getTitle(), entry.getSubtitle(),
                    entry.getDescription(), entry.getContent(), displayDateMonth, displayDateDay,
                    displayDateYear, displayDateHour, displayDateMinute, allowPingbacks, allowTrackbacks,
                    trackbacks, entry.getCoverImageCaption(), null, null, serviceContext);
        } else {
            importedEntry = _blogsEntryLocalService.updateEntry(userId, existingEntry.getEntryId(),
                    entry.getTitle(), entry.getSubtitle(), entry.getDescription(), entry.getContent(),
                    displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute,
                    allowPingbacks, allowTrackbacks, trackbacks, entry.getCoverImageCaption(),
                    new ImageSelector(), new ImageSelector(), serviceContext);
        }
    } else {
        importedEntry = _blogsEntryLocalService.addEntry(userId, entry.getTitle(), entry.getSubtitle(),
                entry.getDescription(), entry.getContent(), displayDateMonth, displayDateDay, displayDateYear,
                displayDateHour, displayDateMinute, allowPingbacks, allowTrackbacks, trackbacks,
                entry.getCoverImageCaption(), null, null, serviceContext);
    }

    if ((entry.getCoverImageFileEntryId() == 0) && Validator.isNull(entry.getCoverImageURL())
            && (entry.getSmallImageFileEntryId() == 0) && Validator.isNull(entry.getSmallImageURL())
            && !entry.isSmallImage()) {

        portletDataContext.importClassedModel(entry, importedEntry);

        return;
    }

    // Cover image

    ImageSelector coverImageSelector = null;

    List<Element> attachmentElements = portletDataContext.getReferenceDataElements(entry, DLFileEntry.class,
            PortletDataContext.REFERENCE_TYPE_WEAK);

    if (Validator.isNotNull(entry.getCoverImageURL())) {
        coverImageSelector = new ImageSelector(entry.getCoverImageURL());
    } else if (entry.getCoverImageFileEntryId() != 0) {
        coverImageSelector = _getImageSelector(portletDataContext, entry.getCoverImageFileEntryId(),
                attachmentElements);
    }

    if (coverImageSelector != null) {
        _blogsEntryLocalService.addCoverImage(importedEntry.getEntryId(), coverImageSelector);
    }

    // Small image

    ImageSelector smallImageSelector = null;

    if (entry.isSmallImage()) {
        String smallImagePath = entryElement.attributeValue("small-image-path");

        if (Validator.isNotNull(entry.getSmallImageURL())) {
            smallImageSelector = new ImageSelector(entry.getSmallImageURL());
        } else if (Validator.isNotNull(smallImagePath)) {
            String smallImageFileName = entry.getSmallImageId() + StringPool.PERIOD + entry.getSmallImageType();

            InputStream inputStream = null;

            try {
                inputStream = portletDataContext.getZipEntryAsInputStream(smallImagePath);

                smallImageSelector = new ImageSelector(FileUtil.getBytes(inputStream), smallImageFileName,
                        MimeTypesUtil.getContentType(smallImageFileName), null);
            } finally {
                StreamUtil.cleanUp(inputStream);
            }
        } else if (entry.getSmallImageFileEntryId() != 0) {
            smallImageSelector = _getImageSelector(portletDataContext, entry.getSmallImageFileEntryId(),
                    attachmentElements);
        }
    }

    if (smallImageSelector != null) {
        _blogsEntryLocalService.addSmallImage(importedEntry.getEntryId(), smallImageSelector);
    }

    if ((coverImageSelector != null) || (smallImageSelector != null)) {
        importedEntry = _blogsEntryLocalService.getEntry(importedEntry.getEntryId());
    }

    portletDataContext.importClassedModel(entry, importedEntry);
}

From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java

License:Open Source License

protected void validate(long smallImageFileEntryId) throws PortalException {
    String[] imageExtensions = PrefsPropsUtil.getStringArray(PropsKeys.BLOGS_IMAGE_EXTENSIONS,
            StringPool.COMMA);//w  w  w.  java  2s  . c o m

    if (smallImageFileEntryId != 0) {
        FileEntry fileEntry = PortletFileRepositoryUtil.getPortletFileEntry(smallImageFileEntryId);

        boolean validSmallImageExtension = false;

        for (String imageExtension : imageExtensions) {
            if (StringPool.STAR.equals(imageExtension)
                    || imageExtension.equals(StringPool.PERIOD + fileEntry.getExtension())) {

                validSmallImageExtension = true;

                break;
            }
        }

        if (!validSmallImageExtension) {
            throw new EntrySmallImageNameException(
                    "Invalid small image for file entry " + smallImageFileEntryId);
        }
    }
}

From source file:com.liferay.blogs.web.internal.upload.BaseBlogsUploadHandler.java

License:Open Source License

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

    long maxSize = getMaxFileSize();

    if ((maxSize > 0) && (size > maxSize)) {
        throw new EntryImageSizeException();
    }//from   ww w.  ja va2s . c om

    String extension = FileUtil.getExtension(fileName);

    String[] imageExtensions = PrefsPropsUtil.getStringArray(PropsKeys.BLOGS_IMAGE_EXTENSIONS,
            StringPool.COMMA);

    for (String imageExtension : imageExtensions) {
        if (StringPool.STAR.equals(imageExtension) || imageExtension.equals(StringPool.PERIOD + extension)) {

            return;
        }
    }

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

From source file:com.liferay.calendar.notification.impl.NotificationUtil.java

License:Open Source License

public static String getDefaultTemplate(NotificationType notificationType,
        NotificationTemplateType notificationTemplateType, NotificationField notificationField)
        throws Exception {

    Filter filter = new Filter(notificationType.toString(), notificationTemplateType.toString());

    String propertyName = CalendarServiceConfigurationKeys.CALENDAR_NOTIFICATION_PREFIX + StringPool.PERIOD
            + notificationField.toString();

    String templatePath = CalendarServiceConfigurationUtil.get(propertyName, filter);

    return ContentUtil.get(NotificationUtil.class.getClassLoader(), templatePath);
}

From source file:com.liferay.calendar.util.NotificationUtil.java

License:Open Source License

public static String getDefaultTemplate(NotificationType notificationType,
        NotificationTemplateType notificationTemplateType, NotificationField notificationField)
        throws Exception {

    Filter filter = new Filter(notificationType.toString(), notificationTemplateType.toString());

    String propertyName = PortletPropsKeys.CALENDAR_NOTIFICATION_PREFIX + StringPool.PERIOD
            + notificationField.toString();

    String templatePath = PortletProps.get(propertyName, filter);

    return ContentUtil.get(templatePath);
}

From source file:com.liferay.content.targeting.rule.facebook.FacebookEducationRule.java

License:Open Source License

@Override
public String getSummary(RuleInstance ruleInstance, Locale locale) {
    String typeSettings = ruleInstance.getTypeSettings();

    String summary = StringPool.BLANK;

    try {//from   ww  w  .ja v a  2 s  .c  o m
        JSONObject jsonObj = JSONFactoryUtil.createJSONObject(typeSettings);

        String educationLevel = jsonObj.getString("educationLevel");
        String schoolName = jsonObj.getString("schoolName");

        StringBundler sb = new StringBundler();

        if (Validator.isNotNull(educationLevel)) {
            sb.append(LanguageUtil.get(locale, "education-level"));
            sb.append(StringPool.COLON);
            sb.append(LanguageUtil.get(locale, educationLevel));
            sb.append(StringPool.PERIOD);
            sb.append(StringPool.SPACE);
        }

        if (Validator.isNotNull(schoolName)) {
            sb.append(LanguageUtil.get(locale, "college-high-school-name"));
            sb.append(StringPool.COLON);
            sb.append(schoolName);
        }
    } catch (JSONException jse) {
    }

    return summary;
}

From source file:com.liferay.customsql.CustomSQL.java

License:Open Source License

public String get(String id, QueryDefinition queryDefinition, String tableName) {

    String sql = get(id);//from www  .  ja va  2s  .  co m

    if (!Validator.isBlank(tableName) && !tableName.endsWith(StringPool.PERIOD)) {

        tableName = tableName.concat(StringPool.PERIOD);
    }

    if (queryDefinition.getStatus() == WorkflowConstants.STATUS_ANY) {
        sql = sql.replace(_STATUS_KEYWORD, _STATUS_CONDITION_EMPTY);
    } else {
        if (queryDefinition.isExcludeStatus()) {
            sql = sql.replace(_STATUS_KEYWORD, tableName.concat(_STATUS_CONDITION_INVERSE));
        } else {
            sql = sql.replace(_STATUS_KEYWORD, tableName.concat(_STATUS_CONDITION_DEFAULT));
        }
    }

    return sql;
}