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