use of com.liferay.opensocial.model.Gadget in project liferay-ide by liferay.
the class GadgetPersistenceImpl method fetchByPrimaryKey.
/**
* Returns the gadget with the primary key or returns <code>null</code> if it could not be found.
*
* @param primaryKey the primary key of the gadget
* @return the gadget, or <code>null</code> if a gadget with the primary key could not be found
* @throws SystemException if a system exception occurred
*/
@Override
public Gadget fetchByPrimaryKey(Serializable primaryKey) throws SystemException {
Gadget gadget = (Gadget) EntityCacheUtil.getResult(GadgetModelImpl.ENTITY_CACHE_ENABLED, GadgetImpl.class, primaryKey);
if (gadget == _nullGadget) {
return null;
}
if (gadget == null) {
Session session = null;
try {
session = openSession();
gadget = (Gadget) session.get(GadgetImpl.class, primaryKey);
if (gadget != null) {
cacheResult(gadget);
} else {
EntityCacheUtil.putResult(GadgetModelImpl.ENTITY_CACHE_ENABLED, GadgetImpl.class, primaryKey, _nullGadget);
}
} catch (Exception e) {
EntityCacheUtil.removeResult(GadgetModelImpl.ENTITY_CACHE_ENABLED, GadgetImpl.class, primaryKey);
throw processException(e);
} finally {
closeSession(session);
}
}
return gadget;
}
use of com.liferay.opensocial.model.Gadget 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.opensocial.model.Gadget 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.opensocial.model.Gadget in project liferay-ide by liferay.
the class AdminPortlet method refreshGadgets.
public void refreshGadgets(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
long[] gadgetIds = ParamUtil.getLongValues(actionRequest, "gadgetId");
if (gadgetIds.length == 0) {
List<Gadget> gadgets = GadgetLocalServiceUtil.getGadgets(QueryUtil.ALL_POS, QueryUtil.ALL_POS);
for (Gadget gadget : gadgets) {
ShindigUtil.clearGadgetSpecCache(gadget.getUrl());
}
} else {
for (long gadgetId : gadgetIds) {
Gadget gadget = GadgetLocalServiceUtil.getGadget(gadgetId);
ShindigUtil.clearGadgetSpecCache(gadget.getUrl());
}
}
}
use of com.liferay.opensocial.model.Gadget in project liferay-ide by liferay.
the class BaseConfigurationAction method getUserPrefs.
protected Map<String, UserPref> getUserPrefs(PortletConfig portletConfig, PortletRequest portletRequest) throws Exception {
Gadget gadget = getGadget(portletConfig, portletRequest);
GadgetSpec gadgetSpec = ShindigUtil.getGadgetSpec(gadget.getUrl());
return gadgetSpec.getUserPrefs();
}
Aggregations