Search in sources :

Example 46 with ServiceContext

use of com.liferay.portal.service.ServiceContext in project liferay-ide by liferay.

the class GadgetStagedModelDataHandler method doImportStagedModel.

@Override
protected void doImportStagedModel(PortletDataContext portletDataContext, Gadget gadget) throws Exception {
    ServiceContext serviceContext = portletDataContext.createServiceContext(gadget);
    Gadget importedGadget = null;
    if (portletDataContext.isDataStrategyMirror()) {
        Gadget existingGadget = GadgetLocalServiceUtil.fetchGadgetByUuidAndCompanyId(gadget.getUuid(), portletDataContext.getCompanyId());
        if (existingGadget == null) {
            serviceContext.setUuid(gadget.getUuid());
            importedGadget = GadgetLocalServiceUtil.addGadget(portletDataContext.getCompanyId(), gadget.getUrl(), gadget.getPortletCategoryNames(), serviceContext);
        } else {
            existingGadget.setName(gadget.getName());
            existingGadget.setUrl(gadget.getUrl());
            existingGadget.setPortletCategoryNames(gadget.getPortletCategoryNames());
            importedGadget = GadgetLocalServiceUtil.updateGadget(existingGadget);
        }
    } else {
        importedGadget = GadgetLocalServiceUtil.addGadget(portletDataContext.getCompanyId(), gadget.getUrl(), gadget.getPortletCategoryNames(), serviceContext);
    }
    portletDataContext.importClassedModel(gadget, importedGadget);
}
Also used : Gadget(com.liferay.opensocial.model.Gadget) ServiceContext(com.liferay.portal.service.ServiceContext)

Example 47 with ServiceContext

use of com.liferay.portal.service.ServiceContext in project liferay-ide by liferay.

the class AdminPortlet method doAddGadget.

protected Gadget doAddGadget(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    String url = ParamUtil.getString(actionRequest, "url");
    String portletCategoryNames = ParamUtil.getString(actionRequest, "portletCategoryNames");
    ServiceContext serviceContext = ServiceContextFactory.getInstance(Gadget.class.getName(), actionRequest);
    Gadget gadget = GadgetServiceUtil.addGadget(themeDisplay.getCompanyId(), url, portletCategoryNames, serviceContext);
    return gadget;
}
Also used : Gadget(com.liferay.opensocial.model.Gadget) ServiceContext(com.liferay.portal.service.ServiceContext) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 48 with ServiceContext

use of com.liferay.portal.service.ServiceContext in project liferay-ide by liferay.

the class AdminPortlet method deleteGadget.

public void deleteGadget(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    long gadgetId = ParamUtil.getLong(actionRequest, "gadgetId");
    ServiceContext serviceContext = ServiceContextFactory.getInstance(Gadget.class.getName(), actionRequest);
    GadgetServiceUtil.deleteGadget(gadgetId, serviceContext);
}
Also used : Gadget(com.liferay.opensocial.model.Gadget) ServiceContext(com.liferay.portal.service.ServiceContext)

Example 49 with ServiceContext

use of com.liferay.portal.service.ServiceContext 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 50 with ServiceContext

use of com.liferay.portal.service.ServiceContext in project liferay-ide by liferay.

the class EditorPortlet method serveUpdateFileEntryTitle.

protected void serveUpdateFileEntryTitle(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception {
    long fileEntryId = ParamUtil.getLong(resourceRequest, "fileEntryId");
    FileEntry fileEntry = DLAppServiceUtil.getFileEntry(fileEntryId);
    String fileEntryTitle = ParamUtil.getString(resourceRequest, "fileEntryTitle");
    byte[] bytes = null;
    ServiceContext serviceContext = ServiceContextFactory.getInstance(resourceRequest);
    DLAppServiceUtil.updateFileEntry(fileEntryId, fileEntryTitle, resourceRequest.getContentType(), fileEntryTitle, fileEntry.getDescription(), StringPool.BLANK, false, bytes, serviceContext);
    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
    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)

Aggregations

ServiceContext (com.liferay.portal.service.ServiceContext)57 User (com.liferay.portal.model.User)11 PrincipalException (com.liferay.portal.security.auth.PrincipalException)11 InputStream (java.io.InputStream)11 AlbumNameException (org.liferay.jukebox.AlbumNameException)9 ArtistNameException (org.liferay.jukebox.ArtistNameException)9 DuplicatedSongException (org.liferay.jukebox.DuplicatedSongException)9 SongNameException (org.liferay.jukebox.SongNameException)9 UploadPortletRequest (com.liferay.portal.kernel.upload.UploadPortletRequest)8 Song (org.liferay.jukebox.model.Song)8 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)7 Date (java.util.Date)7 SystemException (com.liferay.portal.kernel.exception.SystemException)6 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)6 PortalException (com.liferay.portal.kernel.exception.PortalException)5 JSONObject (com.liferay.portal.kernel.json.JSONObject)5 Artist (org.liferay.jukebox.model.Artist)5 Gadget (com.liferay.opensocial.model.Gadget)4 Folder (com.liferay.portal.kernel.repository.model.Folder)4 Element (com.liferay.portal.kernel.xml.Element)4