Search in sources :

Example 11 with ServiceContext

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

the class AdminPortlet method doUpdateGadget.

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

Example 12 with ServiceContext

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

the class EditorPortlet method serveAddFolder.

protected void serveAddFolder(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception {
    long parentFolderId = ParamUtil.getLong(resourceRequest, "parentFolderId");
    Folder parentFolder = DLAppServiceUtil.getFolder(parentFolderId);
    String folderName = ParamUtil.getString(resourceRequest, "folderName");
    ServiceContext serviceContext = ServiceContextFactory.getInstance(resourceRequest);
    serviceContext.setAddGroupPermissions(true);
    serviceContext.setAddGuestPermissions(true);
    serviceContext.setScopeGroupId(parentFolder.getGroupId());
    Folder folder = DLAppServiceUtil.addFolder(parentFolder.getRepositoryId(), parentFolderId, folderName, StringPool.BLANK, serviceContext);
    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
    jsonObject.put("folderId", folder.getFolderId());
    writeJSON(resourceRequest, resourceResponse, jsonObject);
}
Also used : JSONObject(com.liferay.portal.kernel.json.JSONObject) ServiceContext(com.liferay.portal.service.ServiceContext) Folder(com.liferay.portal.kernel.repository.model.Folder)

Example 13 with ServiceContext

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

the class EditorPortlet method serveUpdateFolderName.

protected void serveUpdateFolderName(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception {
    long folderId = ParamUtil.getLong(resourceRequest, "folderId");
    Folder folder = DLAppServiceUtil.getFolder(folderId);
    String folderName = ParamUtil.getString(resourceRequest, "folderName");
    ServiceContext serviceContext = ServiceContextFactory.getInstance(resourceRequest);
    DLAppServiceUtil.updateFolder(folderId, folderName, folder.getDescription(), serviceContext);
    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
    writeJSON(resourceRequest, resourceResponse, jsonObject);
}
Also used : JSONObject(com.liferay.portal.kernel.json.JSONObject) ServiceContext(com.liferay.portal.service.ServiceContext) Folder(com.liferay.portal.kernel.repository.model.Folder)

Example 14 with ServiceContext

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

the class EditDiscussionAction method updateMessage.

protected MBMessage updateMessage(ActionRequest actionRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    String className = ParamUtil.getString(actionRequest, "className");
    long classPK = ParamUtil.getLong(actionRequest, "classPK");
    String permissionClassName = ParamUtil.getString(actionRequest, "permissionClassName");
    long permissionClassPK = ParamUtil.getLong(actionRequest, "permissionClassPK");
    long permissionOwnerId = ParamUtil.getLong(actionRequest, "permissionOwnerId");
    long messageId = ParamUtil.getLong(actionRequest, "messageId");
    long threadId = ParamUtil.getLong(actionRequest, "threadId");
    long parentMessageId = ParamUtil.getLong(actionRequest, "parentMessageId");
    String subject = ParamUtil.getString(actionRequest, "subject");
    String body = ParamUtil.getString(actionRequest, "body");
    ServiceContext serviceContext = ServiceContextFactory.getInstance(MBMessage.class.getName(), actionRequest);
    MBMessage message = null;
    if (messageId <= 0) {
        // Add message
        User user = null;
        if (themeDisplay.isSignedIn()) {
            user = themeDisplay.getUser();
        } else {
            String emailAddress = ParamUtil.getString(actionRequest, "emailAddress");
            user = UserLocalServiceUtil.fetchUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress);
            if ((user == null) || (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE)) {
                return null;
            }
        }
        String name = PrincipalThreadLocal.getName();
        PrincipalThreadLocal.setName(user.getUserId());
        try {
            message = MBMessageServiceUtil.addDiscussionMessage(serviceContext.getScopeGroupId(), className, classPK, permissionClassName, permissionClassPK, permissionOwnerId, threadId, parentMessageId, subject, body, serviceContext);
        } finally {
            PrincipalThreadLocal.setName(name);
        }
    } else {
        // Update message
        message = MBMessageServiceUtil.updateDiscussionMessage(className, classPK, permissionClassName, permissionClassPK, permissionOwnerId, messageId, subject, body, serviceContext);
    }
    // Subscription
    boolean subscribe = ParamUtil.getBoolean(actionRequest, "subscribe");
    if (subscribe) {
        SubscriptionLocalServiceUtil.addSubscription(themeDisplay.getUserId(), themeDisplay.getScopeGroupId(), className, classPK);
    }
    return message;
}
Also used : User(com.liferay.portal.model.User) MBMessage(com.liferay.portlet.messageboards.model.MBMessage) ServiceContext(com.liferay.portal.service.ServiceContext) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 15 with ServiceContext

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

the class StorageAdapterCreateUpdateMethodsTest method updateFieldValues.

protected void updateFieldValues(long storageId, Map<String, String> fieldValues) throws Exception {
    Fields fields = new Fields();
    for (Map.Entry<String, String> entry : fieldValues.entrySet()) {
        Field field = new Field(storageId, entry.getKey(), entry.getValue());
        fields.put(field);
    }
    ServiceContext serviceContext = new ServiceContext();
    StorageEngineUtil.update(storageId, fields, true, serviceContext);
}
Also used : Field(com.liferay.portlet.dynamicdatamapping.storage.Field) Fields(com.liferay.portlet.dynamicdatamapping.storage.Fields) ServiceContext(com.liferay.portal.service.ServiceContext) Map(java.util.Map)

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