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;
}
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);
}
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);
}
}
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);
}
}
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;
}
Aggregations