Search in sources :

Example 41 with Gadget

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;
}
Also used : Gadget(com.liferay.opensocial.model.Gadget) GadgetImpl(com.liferay.opensocial.model.impl.GadgetImpl) SystemException(com.liferay.portal.kernel.exception.SystemException) NoSuchGadgetException(com.liferay.opensocial.NoSuchGadgetException) Session(com.liferay.portal.kernel.dao.orm.Session)

Example 42 with 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);
}
Also used : Gadget(com.liferay.opensocial.model.Gadget) ServiceContext(com.liferay.portal.service.ServiceContext)

Example 43 with Gadget

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;
}
Also used : Gadget(com.liferay.opensocial.model.Gadget) ServiceContext(com.liferay.portal.service.ServiceContext) ThemeDisplay(com.liferay.portal.theme.ThemeDisplay)

Example 44 with 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());
        }
    }
}
Also used : Gadget(com.liferay.opensocial.model.Gadget)

Example 45 with Gadget

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();
}
Also used : GadgetSpec(org.apache.shindig.gadgets.spec.GadgetSpec) Gadget(com.liferay.opensocial.model.Gadget)

Aggregations

Gadget (com.liferay.opensocial.model.Gadget)48 NoSuchGadgetException (com.liferay.opensocial.NoSuchGadgetException)24 StringBundler (com.liferay.portal.kernel.util.StringBundler)21 SystemException (com.liferay.portal.kernel.exception.SystemException)18 Session (com.liferay.portal.kernel.dao.orm.Session)16 SQLQuery (com.liferay.portal.kernel.dao.orm.SQLQuery)14 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)13 GadgetImpl (com.liferay.opensocial.model.impl.GadgetImpl)9 Query (com.liferay.portal.kernel.dao.orm.Query)8 UnmodifiableList (com.liferay.portal.kernel.util.UnmodifiableList)8 ArrayList (java.util.ArrayList)8 List (java.util.List)8 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)4 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)4 GadgetSpec (org.apache.shindig.gadgets.spec.GadgetSpec)3 DuplicateGadgetURLException (com.liferay.opensocial.DuplicateGadgetURLException)2 PermissionChecker (com.liferay.portal.security.permission.PermissionChecker)2 ServiceContext (com.liferay.portal.service.ServiceContext)2 GadgetPortletCategoryNamesException (com.liferay.opensocial.GadgetPortletCategoryNamesException)1 GadgetURLException (com.liferay.opensocial.GadgetURLException)1