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.logbridge.LogBridge.java

License:Open Source License

public void logged(LogEntry logEntry) {
    int level = logEntry.getLevel();

    Bundle bundle = logEntry.getBundle();

    String symbolicName = StringUtil.replace(bundle.getSymbolicName(), StringPool.PERIOD, StringPool.UNDERLINE);

    Log log = LogFactoryUtil.getLog("osgi.logging." + symbolicName);

    String message = logEntry.getMessage();

    ServiceReference<?> serviceReference = logEntry.getServiceReference();

    if (serviceReference != null) {
        message += " " + serviceReference.toString();
    }/* w ww .j  a v a  2 s  . c  o m*/

    if ((level == LogService.LOG_DEBUG) && log.isDebugEnabled()) {
        log.debug(message, logEntry.getException());
    } else if ((level == LogService.LOG_ERROR) && log.isErrorEnabled()) {
        log.error(message, logEntry.getException());
    } else if ((level == LogService.LOG_INFO) && log.isInfoEnabled()) {
        log.info(message, logEntry.getException());
    } else if ((level == LogService.LOG_WARNING) && log.isWarnEnabled()) {
        log.warn(message, logEntry.getException());
    }
}

From source file:com.liferay.mail.imap.IMAPAccessor.java

License:Open Source License

protected Part getPart(Part part, String contentPath) throws IOException, MessagingException {

    int index = GetterUtil.getInteger(StringUtil.split(contentPath.substring(1), StringPool.PERIOD)[0]);

    if (!(part.getContent() instanceof Multipart)) {
        return part;
    }//from  w w w  . j  ava2 s . c  o m

    Multipart multipart = (Multipart) part.getContent();

    for (int i = 0; i < multipart.getCount(); i++) {
        if (i != index) {
            continue;
        }

        String prefix = String.valueOf(index).concat(StringPool.PERIOD);

        return getPart(multipart.getBodyPart(i), contentPath.substring(prefix.length()));
    }

    return part;
}

From source file:com.liferay.mail.imap.IMAPAccessor.java

License:Open Source License

protected void getParts(long userId, StringBundler bodyPlain, StringBundler bodyHtml, String contentPath,
        Part part, List<MailFile> mailFiles) throws IOException, MessagingException {

    String fileName = part.getFileName();
    Object content = part.getContent();

    if (content instanceof Multipart) {
        Multipart multipart = (Multipart) content;

        for (int i = 0; i < multipart.getCount(); i++) {
            Part curPart = multipart.getBodyPart(i);

            getParts(userId, bodyPlain, bodyHtml,
                    contentPath.concat(StringPool.PERIOD).concat(String.valueOf(i)), curPart, mailFiles);
        }//w  w  w . j a va2 s  . c om
    } else if (Validator.isNull(fileName)) {
        String contentType = StringUtil.toLowerCase(part.getContentType());

        if (contentType.startsWith(ContentTypes.TEXT_PLAIN)) {
            bodyPlain.append(content.toString().replaceAll("\r\n", "<br />"));
        } else if (contentType.startsWith(ContentTypes.TEXT_HTML)) {
            bodyHtml.append(HtmlContentUtil.getInlineHtml(content.toString()));
        }
        //else if (contentType.startsWith(ContentTypes.MESSAGE_RFC822)) {
        //}
    } else {
        MailFile mailFile = new MailFile(contentPath.concat(StringPool.PERIOD).concat("-1"), fileName,
                part.getSize());

        mailFiles.add(mailFile);
    }
}

From source file:com.liferay.mail.util.FuseMailHook.java

License:Open Source License

protected String getMailUserId(long companyId, long userId) throws Exception {

    Company company = CompanyLocalServiceUtil.getCompanyById(companyId);

    String mailUserId = company.getMx().concat(StringPool.PERIOD).concat(String.valueOf(userId));

    if (_log.isDebugEnabled()) {
        _log.debug("Mail user id " + mailUserId + " for user id " + userId);
    }//from w  w  w.ja  va  2s  . c  om

    return mailUserId;
}

From source file:com.liferay.marketplace.model.impl.AppImpl.java

License:Open Source License

@Override
public String getFileName() {
    return getAppId() + StringPool.PERIOD + _EXTENSION;
}

From source file:com.liferay.meeting.webex.request.BaseMeetingRequestTranslator.java

License:Open Source License

public String getSiteURL(MeetingContext meetingContext) {
    StringBundler siteURL = new StringBundler(6);

    siteURL.append(Http.HTTP_WITH_SLASH);
    siteURL.append(meetingContext.getName());
    siteURL.append(StringPool.PERIOD);
    siteURL.append(WebExConstants.DOMAIN);
    siteURL.append(StringPool.SLASH);/* w w w  .  j a v a2  s .  c om*/
    siteURL.append(meetingContext.getApiURL());

    return siteURL.toString();
}

From source file:com.liferay.opensocial.shindig.service.LiferayMediaItemService.java

License:Open Source License

protected RestfulCollection<MediaItem> doGetMediaItems(Set<UserId> userIds, GroupId groupId, String appId,
        Set<String> fields, CollectionOptions collectionOptions, SecurityToken securityToken) throws Exception {

    List<MediaItem> mediaItems = new ArrayList<MediaItem>();

    for (UserId userId : userIds) {
        long userIdLong = GetterUtil.getLong(userId.getUserId(securityToken));

        User user = UserLocalServiceUtil.getUserById(userIdLong);

        if (!ShindigUtil.isValidUser(user)) {
            continue;
        }//  w ww.java  2s.  co  m

        List<FileEntry> fileEntries = new ArrayList<FileEntry>();

        GroupId.Type groupIdType = groupId.getType();

        if (groupIdType.equals(GroupId.Type.all) || groupIdType.equals(GroupId.Type.friends)
                || groupIdType.equals(GroupId.Type.groupId)) {

            List<User> socialUsers = UserLocalServiceUtil.getSocialUsers(user.getUserId(),
                    SocialRelationConstants.TYPE_BI_FRIEND, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);

            for (User socialUser : socialUsers) {
                Group group = socialUser.getGroup();

                List<FileEntry> friendFileEntries = DLAppServiceUtil.getGroupFileEntries(group.getGroupId(),
                        socialUser.getUserId(), collectionOptions.getFirst(), collectionOptions.getMax());

                fileEntries.addAll(friendFileEntries);
            }
        } else if (groupIdType.equals(GroupId.Type.self)) {
            Group group = user.getGroup();

            fileEntries = DLAppServiceUtil.getGroupFileEntries(group.getGroupId(), user.getUserId(),
                    collectionOptions.getFirst(), collectionOptions.getMax());
        }

        for (FileEntry fileEntry : fileEntries) {
            MediaItem.Type mediaItemType = toMediaItemType(StringPool.PERIOD.concat(fileEntry.getExtension()));

            if (mediaItemType == null) {
                continue;
            }

            MediaItem mediaItem = toMediaItem(fileEntry, fields, securityToken);

            mediaItems.add(mediaItem);
        }
    }

    return new RestfulCollection<MediaItem>(mediaItems, collectionOptions.getFirst(), mediaItems.size(),
            collectionOptions.getMax());
}

From source file:com.liferay.opensocial.shindig.service.LiferayMediaItemService.java

License:Open Source License

protected RestfulCollection<MediaItem> doGetMediaItems(UserId userId, String appId, String albumId,
        Set<String> fields, CollectionOptions collectionOptions, SecurityToken securityToken) throws Exception {

    long userIdLong = GetterUtil.getLong(userId.getUserId(securityToken));

    User user = UserLocalServiceUtil.getUserById(userIdLong);

    List<MediaItem> mediaItems = new ArrayList<MediaItem>();

    if (!ShindigUtil.isValidUser(user)) {
        return new RestfulCollection<MediaItem>(mediaItems, collectionOptions.getFirst(), mediaItems.size(),
                collectionOptions.getMax());
    }//w  w w  .ja v  a  2s .  c o m

    Group group = user.getGroup();

    long groupIdLong = group.getGroupId();

    long albumIdLong = GetterUtil.getLong(albumId);

    List<FileEntry> fileEntries = DLAppServiceUtil.getFileEntries(groupIdLong, albumIdLong);

    for (FileEntry fileEntry : fileEntries) {
        MediaItem.Type mediaItemType = toMediaItemType(StringPool.PERIOD.concat(fileEntry.getExtension()));

        if (mediaItemType == null) {
            continue;
        }

        MediaItem mediaItem = toMediaItem(fileEntry, fields, securityToken);

        mediaItems.add(mediaItem);
    }

    return new RestfulCollection<MediaItem>(mediaItems, collectionOptions.getFirst(), mediaItems.size(),
            collectionOptions.getMax());
}

From source file:com.liferay.opensocial.shindig.service.LiferayMediaItemService.java

License:Open Source License

protected RestfulCollection<MediaItem> doGetMediaItems(UserId userId, String appId, String albumId,
        Set<String> mediaItemIds, Set<String> fields, CollectionOptions collectionOptions,
        SecurityToken securityToken) throws Exception {

    long userIdLong = GetterUtil.getLong(userId.getUserId(securityToken));

    User user = UserLocalServiceUtil.getUserById(userIdLong);

    List<MediaItem> mediaItems = new ArrayList<MediaItem>();

    if (!ShindigUtil.isValidUser(user)) {
        return new RestfulCollection<MediaItem>(mediaItems, collectionOptions.getFirst(), mediaItems.size(),
                collectionOptions.getMax());
    }/*from  ww w . j  av a  2 s.  co m*/

    Group group = user.getGroup();

    long groupIdLong = group.getGroupId();

    long albumIdLong = GetterUtil.getLong(albumId);

    List<FileEntry> fileEntries = DLAppServiceUtil.getFileEntries(groupIdLong, albumIdLong);

    for (FileEntry fileEntry : fileEntries) {
        MediaItem.Type mediaItemType = toMediaItemType(StringPool.PERIOD.concat(fileEntry.getExtension()));

        if (mediaItemType == null) {
            continue;
        }

        MediaItem mediaItem = toMediaItem(fileEntry, fields, securityToken);

        if (mediaItemIds.contains(mediaItem.getId())) {
            mediaItems.add(mediaItem);
        }
    }

    return new RestfulCollection<MediaItem>(mediaItems, collectionOptions.getFirst(), mediaItems.size(),
            collectionOptions.getMax());
}

From source file:com.liferay.opensocial.shindig.service.LiferayMediaItemService.java

License:Open Source License

protected MediaItem toMediaItem(FileEntry fileEntry, Set<String> fields, SecurityToken securityToken)
        throws Exception {

    MediaItem mediaItem = new MediaItemImpl();

    mediaItem.setAlbumId(String.valueOf(fileEntry.getFolderId()));
    mediaItem.setCreated(String.valueOf(fileEntry.getCreateDate()));
    mediaItem.setDescription(fileEntry.getDescription());
    mediaItem.setId(String.valueOf(fileEntry.getFileEntryId()));
    mediaItem.setLastUpdated(String.valueOf(fileEntry.getModifiedDate()));
    mediaItem.setMimeType(MimeTypesUtil.getContentType(StringPool.PERIOD.concat(fileEntry.getExtension())));
    mediaItem.setNumViews(String.valueOf(fileEntry.getReadCount()));
    mediaItem.setTitle(fileEntry.getTitle());
    mediaItem.setType(toMediaItemType(StringPool.PERIOD.concat(fileEntry.getExtension())));

    String fileEntryURL = ShindigUtil.getFileEntryURL(securityToken.getDomain(), fileEntry.getFileEntryId());

    mediaItem.setUrl(fileEntryURL);//from www  .ja  va2 s  .  c o m

    FileVersion fileVersion = fileEntry.getLatestFileVersion();

    SerializerUtil.copyProperties(fileVersion.getAttributes(), mediaItem, _MEDIA_ITEM_FIELDS);

    return mediaItem;
}