Example usage for com.liferay.portal.kernel.repository.model FileEntry getCreateDate

List of usage examples for com.liferay.portal.kernel.repository.model FileEntry getCreateDate

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.repository.model FileEntry getCreateDate.

Prototype

@Override
    public Date getCreateDate();

Source Link

Usage

From source file:blade.document.action.configurationicon.BladeActionConfigurationIcon.java

License:Apache License

public String getURL(PortletRequest portletRequest, PortletResponse portletResponse) {

    HttpServletRequest servletRequest = _portal.getHttpServletRequest(portletRequest);

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

    FileEntry fileEntry = _retrieveFile(servletRequest);

    PortletURL portletURL = PortletURLFactoryUtil.create(servletRequest,
            "blade_document_action_portlet_BladeDocumentActionPortlet", themeDisplay.getPlid(),
            PortletRequest.RENDER_PHASE);

    String fileName = fileEntry.getFileName();
    String mimeType = fileEntry.getMimeType();
    String version = fileEntry.getVersion();
    String createdDate = fileEntry.getCreateDate().toString();
    String createdUserName = fileEntry.getUserName();
    String statusLabel = null;//from w  w  w.j a va2  s  . c  o  m

    try {
        statusLabel = WorkflowConstants.getStatusLabel(fileEntry.getLatestFileVersion().getStatus());
    } catch (PortalException pe) {
        _log.error(pe);
    }

    portletURL.setParameter("fileName", fileName);
    portletURL.setParameter("mimeType", mimeType);
    portletURL.setParameter("version", version);
    portletURL.setParameter("statusLabel", statusLabel);
    portletURL.setParameter("createdDate", createdDate);
    portletURL.setParameter("createdUserName", createdUserName);

    try {
        portletURL.setWindowState(LiferayWindowState.POP_UP);
    } catch (WindowStateException wse) {
        _log.error(wse);
    }

    StringBuilder stringBuilder = new StringBuilder();

    stringBuilder.append("javascript:Liferay.Util.openWindow(");
    stringBuilder.append("{dialog: {cache: false,width:800,modal: true},");
    stringBuilder.append("title: 'basic information',id: ");
    stringBuilder.append("'testPopupIdUnique',uri: '");
    stringBuilder.append(portletURL.toString() + "'});");

    return stringBuilder.toString();
}

From source file:com.liferay.document.library.jaxrs.FolderResource.java

License:Open Source License

protected RepositoryContentObject toObjectRepository(Object rco) {
    if (rco instanceof FileEntry) {
        FileEntry fileEntry = (FileEntry) rco;

        String url = _fileUriBuilder.build(fileEntry.getFileEntryId()).toString();

        return new RepositoryContentObject(fileEntry.getFileEntryId(), fileEntry.getTitle(), url,
                RepositoryContentObject.RepositoryContentType.FILE, fileEntry.getCreateDate(),
                fileEntry.getModifiedDate());
    } else if (rco instanceof Folder) {
        Folder folder = (Folder) rco;/*from   w w  w.  ja  v a 2  s. c  om*/

        String url = _folderUriBuilder.build(Long.toString(folder.getFolderId())).toString();

        return new RepositoryContentObject(folder.getFolderId(), folder.getName(), url,
                RepositoryContentObject.RepositoryContentType.FOLDER, folder.getCreateDate(),
                folder.getModifiedDate());
    } else if (rco instanceof FileShortcut) {
        FileShortcut fileShortcut = (FileShortcut) rco;

        String url = _fileUriBuilder.build(Long.toString(fileShortcut.getToFileEntryId())).toString();

        return new RepositoryContentObject(fileShortcut.getFileShortcutId(), fileShortcut.getToTitle(), url,
                RepositoryContentObject.RepositoryContentType.SHORTCUT, fileShortcut.getCreateDate(),
                fileShortcut.getModifiedDate());
    } else {
        throw new IllegalArgumentException(
                "Object must be an instance of FileEntry, Folder of " + "FileShortcut");
    }
}

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

License:Open Source License

protected void doUpdateMediaItem(UserId userId, String appId, String albumId, String mediaItemId,
        MediaItem mediaItem, SecurityToken securityToken) throws Exception {

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

    User user = UserLocalServiceUtil.getUserById(userIdLong);

    if (!ShindigUtil.isValidUser(user)) {
        return;//from  w  ww  .j  a va  2 s . c  o m
    }

    Group group = user.getGroup();

    long groupIdLong = group.getGroupId();

    Http.Options options = new Http.Options();

    options.setLocation(mediaItem.getUrl());

    byte[] byteArray = HttpUtil.URLtoByteArray(options);

    String fileName = getFileName(mediaItem, options);
    String contentType = MimeTypesUtil.getContentType(fileName);

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setAddGroupPermissions(true);
    serviceContext.setAddGuestPermissions(true);

    serviceContext.setAttribute("sourceFileName", fileName);

    serviceContext.setExpandoBridgeAttributes(SerializerUtil.toExpandoAttributes(mediaItem, _MEDIA_ITEM_FIELDS,
            user.getCompanyId(), DLFileEntry.class.getName()));
    serviceContext.setScopeGroupId(groupIdLong);

    if (mediaItemId == null) {
        long albumIdLong = GetterUtil.getLong(albumId);

        DLAppServiceUtil.addFileEntry(groupIdLong, albumIdLong, fileName, contentType, mediaItem.getTitle(),
                mediaItem.getDescription(), StringPool.BLANK, byteArray, serviceContext);
    } else {
        long mediaItemIdLong = GetterUtil.getLong(mediaItemId);

        FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(mediaItemIdLong);

        serviceContext.setCreateDate(fileEntry.getCreateDate());
        serviceContext.setModifiedDate(fileEntry.getModifiedDate());

        DLAppServiceUtil.updateFileEntry(fileEntry.getFileEntryId(), fileName, contentType,
                mediaItem.getTitle(), mediaItem.getDescription(), StringPool.BLANK, false, byteArray,
                serviceContext);
    }
}

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 w  w  w  . j  av a2s . c  o  m

    FileVersion fileVersion = fileEntry.getLatestFileVersion();

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

    return mediaItem;
}

From source file:com.liferay.portlet.documentlibrary.sharepoint.DLSharepointStorageImpl.java

License:Open Source License

@Override
public void addDocumentElements(SharepointRequest sharepointRequest, Element element) throws Exception {

    String parentFolderPath = sharepointRequest.getRootPath();

    long groupId = SharepointUtil.getGroupId(parentFolderPath);
    long parentFolderId = getLastFolderId(groupId, parentFolderPath,
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);

    if (parentFolderId == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
        return;/*  w ww. j  av  a  2 s  . c  o  m*/
    }

    List<FileEntry> fileEntries = DLAppServiceUtil.getFileEntries(groupId, parentFolderId);

    for (FileEntry fileEntry : fileEntries) {
        String documentPath = parentFolderPath.concat(StringPool.SLASH).concat(fileEntry.getTitle());

        addDocumentElement(element, documentPath, fileEntry.getCreateDate(), fileEntry.getModifiedDate(),
                fileEntry.getUserName());
    }
}

From source file:com.liferay.portlet.documentlibrary.sharepoint.DLSharepointStorageImpl.java

License:Open Source License

protected Tree getFileEntryTree(FileEntry fileEntry, String parentFolderPath) {

    String documentPath = parentFolderPath.concat(StringPool.SLASH).concat(fileEntry.getTitle());

    return getDocumentTree(documentPath, fileEntry.getCreateDate(), fileEntry.getModifiedDate(),
            fileEntry.getSize(), fileEntry.getUserName(), fileEntry.getVersion());
}

From source file:com.liferay.portlet.documentlibrary.util.comparator.RepositoryModelCreateDateComparator.java

License:Open Source License

protected Date getCreateDate(Object obj) {
    if (obj instanceof DLFileEntry) {
        DLFileEntry dlFileEntry = (DLFileEntry) obj;

        return dlFileEntry.getCreateDate();
    } else if (obj instanceof DLFileShortcut) {
        DLFileShortcut dlFileShortcut = (DLFileShortcut) obj;

        return dlFileShortcut.getCreateDate();
    } else if (obj instanceof DLFolder) {
        DLFolder dlFolder = (DLFolder) obj;

        return dlFolder.getCreateDate();
    } else if (obj instanceof FileEntry) {
        FileEntry fileEntry = (FileEntry) obj;

        return fileEntry.getCreateDate();
    } else {//from  w w w . ja v  a 2 s .  co  m
        Folder folder = (Folder) obj;

        return folder.getCreateDate();
    }
}

From source file:com.liferay.portlet.documentlibrary.webdav.DLFileEntryResourceImpl.java

License:Open Source License

public DLFileEntryResourceImpl(WebDAVRequest webDavRequest, FileEntry fileEntry, String parentPath,
        String name) {/*from   w ww .j a v a2s .  co m*/

    super(parentPath, name, fileEntry.getTitle(), fileEntry.getCreateDate(), fileEntry.getModifiedDate(),
            fileEntry.getSize());

    setModel(fileEntry);
    setClassName(DLFileEntry.class.getName());
    setPrimaryKey(fileEntry.getPrimaryKey());

    //_webDavRequest = webDavRequest;
    _fileEntry = fileEntry;
}