Search in sources :

Example 26 with PortalException

use of com.liferay.portal.kernel.exception.PortalException in project liferay-ide by liferay.

the class AlbumLocalServiceImpl method updateAlbum.

@Indexable(type = IndexableType.REINDEX)
public Album updateAlbum(long userId, long albumId, long artistId, String name, int year, InputStream inputStream, ServiceContext serviceContext) throws PortalException, SystemException {
    // Event
    User user = userPersistence.findByPrimaryKey(userId);
    validate(name);
    Album album = albumPersistence.findByPrimaryKey(albumId);
    album.setModifiedDate(serviceContext.getModifiedDate(null));
    album.setArtistId(artistId);
    album.setName(name);
    album.setYear(year);
    album.setExpandoBridgeAttributes(serviceContext);
    albumPersistence.update(album);
    if (inputStream != null) {
        Repository repository = PortletFileRepositoryUtil.fetchPortletRepository(serviceContext.getScopeGroupId(), Constants.JUKEBOX_PORTLET_REPOSITORY);
        if (repository != null) {
            try {
                PortletFileRepositoryUtil.deletePortletFileEntry(repository.getRepositoryId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, String.valueOf(album.getAlbumId()));
            } catch (Exception e) {
                if (_log.isDebugEnabled()) {
                    _log.debug("Cannot delete album cover");
                }
            }
        }
        PortletFileRepositoryUtil.addPortletFileEntry(serviceContext.getScopeGroupId(), userId, Album.class.getName(), album.getAlbumId(), Constants.JUKEBOX_PORTLET_REPOSITORY, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, inputStream, String.valueOf(album.getAlbumId()), StringPool.BLANK, true);
    }
    // Asset
    updateAsset(userId, album, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds());
    return album;
}
Also used : Repository(com.liferay.portal.model.Repository) User(com.liferay.portal.model.User) Album(org.liferay.jukebox.model.Album) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) AlbumNameException(org.liferay.jukebox.AlbumNameException) Indexable(com.liferay.portal.kernel.search.Indexable)

Example 27 with PortalException

use of com.liferay.portal.kernel.exception.PortalException 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 28 with PortalException

use of com.liferay.portal.kernel.exception.PortalException in project liferay-ide by liferay.

the class MediaWikiImporter method importPage.

protected void importPage(long userId, String author, WikiNode node, String title, String content, String summary, Map<String, String> usersMap, boolean strictImportMode) throws PortalException {
    try {
        long authorUserId = getUserId(userId, node, author, usersMap);
        String parentTitle = readParentTitle(content);
        String redirectTitle = readRedirectTitle(content);
        ServiceContext serviceContext = new ServiceContext();
        serviceContext.setAddGroupPermissions(true);
        serviceContext.setAddGuestPermissions(true);
        serviceContext.setAssetTagNames(readAssetTagNames(userId, node, content));
        if (Validator.isNull(redirectTitle)) {
            _translator.setStrictImportMode(strictImportMode);
            content = _translator.translate(content);
        } else {
            content = StringPool.DOUBLE_OPEN_BRACKET + redirectTitle + StringPool.DOUBLE_CLOSE_BRACKET;
        }
        WikiPage page = null;
        try {
            page = WikiPageLocalServiceUtil.getPage(node.getNodeId(), title);
        } catch (NoSuchPageException nspe) {
            page = WikiPageLocalServiceUtil.addPage(authorUserId, node.getNodeId(), title, WikiPageConstants.NEW, null, true, serviceContext);
        }
        WikiPageLocalServiceUtil.updatePage(authorUserId, node.getNodeId(), title, page.getVersion(), content, summary, true, "creole", parentTitle, redirectTitle, serviceContext);
    } catch (Exception e) {
        throw new PortalException("Error importing page " + title, e);
    }
}
Also used : NoSuchPageException(com.liferay.portlet.wiki.NoSuchPageException) ServiceContext(com.liferay.portal.service.ServiceContext) WikiPage(com.liferay.portlet.wiki.model.WikiPage) PortalException(com.liferay.portal.kernel.exception.PortalException) NoSuchPageException(com.liferay.portlet.wiki.NoSuchPageException) ImportFilesException(com.liferay.portlet.wiki.ImportFilesException) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) DocumentException(com.liferay.portal.kernel.xml.DocumentException) IOException(java.io.IOException) NoSuchTagException(com.liferay.portlet.asset.NoSuchTagException)

Example 29 with PortalException

use of com.liferay.portal.kernel.exception.PortalException in project liferay-ide by liferay.

the class AdminPortlet method buildEditURL.

@Override
protected String buildEditURL(ActionRequest actionRequest, ActionResponse actionResponse, KBArticle kbArticle) throws PortalException, SystemException {
    try {
        ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
        PortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, PortletKeys.KNOWLEDGE_BASE_ADMIN, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);
        portletURL.setParameter("mvcPath", templatePath + "edit_article.jsp");
        portletURL.setParameter("redirect", getRedirect(actionRequest, actionResponse));
        portletURL.setParameter("resourcePrimKey", String.valueOf(kbArticle.getResourcePrimKey()));
        portletURL.setWindowState(actionRequest.getWindowState());
        return portletURL.toString();
    } catch (WindowStateException wse) {
        throw new PortalException(wse);
    }
}
Also used : WindowStateException(javax.portlet.WindowStateException) PortalException(com.liferay.portal.kernel.exception.PortalException) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay) PortletURL(javax.portlet.PortletURL)

Example 30 with PortalException

use of com.liferay.portal.kernel.exception.PortalException in project liferay-blade-samples by liferay.

the class FooLocalServiceBaseImpl method getExportActionableDynamicQuery.

@Override
public ExportActionableDynamicQuery getExportActionableDynamicQuery(final PortletDataContext portletDataContext) {
    final ExportActionableDynamicQuery exportActionableDynamicQuery = new ExportActionableDynamicQuery() {

        @Override
        public long performCount() throws PortalException {
            ManifestSummary manifestSummary = portletDataContext.getManifestSummary();
            StagedModelType stagedModelType = getStagedModelType();
            long modelAdditionCount = super.performCount();
            manifestSummary.addModelAdditionCount(stagedModelType, modelAdditionCount);
            long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(portletDataContext, stagedModelType);
            manifestSummary.addModelDeletionCount(stagedModelType, modelDeletionCount);
            return modelAdditionCount;
        }
    };
    initActionableDynamicQuery(exportActionableDynamicQuery);
    exportActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {

        @Override
        public void addCriteria(DynamicQuery dynamicQuery) {
            portletDataContext.addDateRangeCriteria(dynamicQuery, "modifiedDate");
        }
    });
    exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());
    exportActionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Foo>() {

        @Override
        public void performAction(Foo foo) throws PortalException {
            StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, foo);
        }
    });
    exportActionableDynamicQuery.setStagedModelType(new StagedModelType(PortalUtil.getClassNameId(Foo.class.getName())));
    return exportActionableDynamicQuery;
}
Also used : ExportActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery) DefaultActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery) ExportActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) IndexableActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) ManifestSummary(com.liferay.exportimport.kernel.lar.ManifestSummary) Foo(com.liferay.blade.samples.servicebuilder.model.Foo) StagedModelType(com.liferay.exportimport.kernel.lar.StagedModelType) PortalException(com.liferay.portal.kernel.exception.PortalException) DefaultActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery) ExportActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery) IndexableActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)

Aggregations

PortalException (com.liferay.portal.kernel.exception.PortalException)40 SystemException (com.liferay.portal.kernel.exception.SystemException)25 User (com.liferay.portal.model.User)10 IOException (java.io.IOException)10 User (com.liferay.portal.kernel.model.User)9 Indexable (com.liferay.portal.kernel.search.Indexable)5 UploadPortletRequest (com.liferay.portal.kernel.upload.UploadPortletRequest)4 PrincipalException (com.liferay.portal.security.auth.PrincipalException)4 CompanyMaxUsersException (com.liferay.portal.CompanyMaxUsersException)3 ContactBirthdayException (com.liferay.portal.ContactBirthdayException)3 ContactFirstNameException (com.liferay.portal.ContactFirstNameException)3 ContactFullNameException (com.liferay.portal.ContactFullNameException)3 ContactLastNameException (com.liferay.portal.ContactLastNameException)3 DuplicateOpenIdException (com.liferay.portal.DuplicateOpenIdException)3 DuplicateUserEmailAddressException (com.liferay.portal.DuplicateUserEmailAddressException)3 DuplicateUserScreenNameException (com.liferay.portal.DuplicateUserScreenNameException)3 GroupFriendlyURLException (com.liferay.portal.GroupFriendlyURLException)3 ModelListenerException (com.liferay.portal.ModelListenerException)3 NoSuchImageException (com.liferay.portal.NoSuchImageException)3 NoSuchOrganizationException (com.liferay.portal.NoSuchOrganizationException)3