Search in sources :

Example 16 with Folder

use of com.liferay.portal.kernel.repository.model.Folder in project liferay-ide by liferay.

the class SongLocalServiceImpl method deleteSong.

@Indexable(type = IndexableType.DELETE)
public Song deleteSong(long songId) throws PortalException, SystemException {
    Song song = songPersistence.findByPrimaryKey(songId);
    Repository repository = PortletFileRepositoryUtil.fetchPortletRepository(song.getGroupId(), Constants.JUKEBOX_PORTLET_REPOSITORY);
    if (repository != null) {
        try {
            Folder folder = PortletFileRepositoryUtil.getPortletFolder(0, repository.getRepositoryId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, String.valueOf(songId), null);
            PortletFileRepositoryUtil.deleteFolder(folder.getFolderId());
        } catch (Exception e) {
        }
    }
    return songPersistence.remove(songId);
}
Also used : Song(org.liferay.jukebox.model.Song) Repository(com.liferay.portal.model.Repository) Folder(com.liferay.portal.kernel.repository.model.Folder) SongNameException(org.liferay.jukebox.SongNameException) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) DuplicatedSongException(org.liferay.jukebox.DuplicatedSongException) Indexable(com.liferay.portal.kernel.search.Indexable)

Example 17 with Folder

use of com.liferay.portal.kernel.repository.model.Folder in project liferay-ide by liferay.

the class LiferayAlbumService method doGetAlbum.

protected Album doGetAlbum(UserId userId, String appId, Set<String> fields, String albumId, SecurityToken securityToken) throws Exception {
    long albumIdLong = GetterUtil.getLong(albumId);
    Folder folder = DLAppServiceUtil.getFolder(albumIdLong);
    return toAlbum(folder, fields, securityToken);
}
Also used : Folder(com.liferay.portal.kernel.repository.model.Folder) DLFolder(com.liferay.portlet.documentlibrary.model.DLFolder)

Example 18 with Folder

use of com.liferay.portal.kernel.repository.model.Folder in project liferay-ide by liferay.

the class EditorPortlet method serveAddFileEntry.

protected void serveAddFileEntry(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY);
    long folderId = ParamUtil.getLong(resourceRequest, "folderId");
    Folder folder = DLAppServiceUtil.getFolder(folderId);
    String fileEntryTitle = ParamUtil.getString(resourceRequest, "fileEntryTitle");
    String content = ParamUtil.getString(resourceRequest, "content");
    byte[] bytes = content.getBytes(StringPool.UTF8);
    ServiceContext serviceContext = ServiceContextFactory.getInstance(resourceRequest);
    serviceContext.setAddGroupPermissions(true);
    serviceContext.setAddGuestPermissions(true);
    serviceContext.setAttribute("sourceFileName", fileEntryTitle);
    serviceContext.setScopeGroupId(folder.getGroupId());
    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
    FileEntry fileEntry = DLAppServiceUtil.addFileEntry(folder.getRepositoryId(), folderId, fileEntryTitle, resourceRequest.getContentType(), fileEntryTitle, StringPool.BLANK, StringPool.BLANK, bytes, serviceContext);
    jsonObject.put("fileEntryId", fileEntry.getFileEntryId());
    String portalURL = PortalUtil.getPortalURL(themeDisplay);
    String fileEntryURL = ShindigUtil.getFileEntryURL(portalURL, fileEntry.getFileEntryId());
    jsonObject.put("fileEntryURL", fileEntryURL);
    writeJSON(resourceRequest, resourceResponse, jsonObject);
}
Also used : JSONObject(com.liferay.portal.kernel.json.JSONObject) ServiceContext(com.liferay.portal.service.ServiceContext) FileEntry(com.liferay.portal.kernel.repository.model.FileEntry) Folder(com.liferay.portal.kernel.repository.model.Folder) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 19 with Folder

use of com.liferay.portal.kernel.repository.model.Folder in project liferay-ide by liferay.

the class ShindigUtil method getGadgetEditorRootFolder.

public static Folder getGadgetEditorRootFolder(long repositoryId) throws Exception {
    Folder folder = null;
    try {
        folder = DLAppServiceUtil.getFolder(repositoryId, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, _GADGET_EDITOR_ROOT_FOLDER_NAME);
    } catch (Exception e) {
    }
    if (folder == null) {
        ServiceContext serviceContext = new ServiceContext();
        serviceContext.setGroupPermissions(new String[] { ActionKeys.ADD_DOCUMENT, ActionKeys.DELETE, ActionKeys.UPDATE, ActionKeys.VIEW });
        serviceContext.setGuestPermissions(new String[] { ActionKeys.VIEW });
        serviceContext.setScopeGroupId(repositoryId);
        folder = DLAppServiceUtil.addFolder(repositoryId, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, _GADGET_EDITOR_ROOT_FOLDER_NAME, StringPool.BLANK, serviceContext);
    }
    return folder;
}
Also used : ServiceContext(com.liferay.portal.service.ServiceContext) Folder(com.liferay.portal.kernel.repository.model.Folder) ProcessingException(org.apache.shindig.gadgets.process.ProcessingException) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) GadgetURLException(com.liferay.opensocial.GadgetURLException)

Aggregations

Folder (com.liferay.portal.kernel.repository.model.Folder)19 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)7 ServiceContext (com.liferay.portal.service.ServiceContext)6 PortalException (com.liferay.portal.kernel.exception.PortalException)5 SystemException (com.liferay.portal.kernel.exception.SystemException)5 Repository (com.liferay.portal.model.Repository)5 User (com.liferay.portal.model.User)5 JSONObject (com.liferay.portal.kernel.json.JSONObject)4 DLFolder (com.liferay.portlet.documentlibrary.model.DLFolder)4 Indexable (com.liferay.portal.kernel.search.Indexable)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Song (org.liferay.jukebox.model.Song)3 NoSuchGroupException (com.liferay.portal.NoSuchGroupException)2 RepositoryException (com.liferay.portal.kernel.repository.RepositoryException)2 ServiceContext (com.liferay.portal.kernel.service.ServiceContext)2 Group (com.liferay.portal.model.Group)2 PrincipalException (com.liferay.portal.security.auth.PrincipalException)2 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)2 NoSuchFileEntryException (com.liferay.portlet.documentlibrary.NoSuchFileEntryException)2