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