Search in sources :

Example 1 with Gadget

use of com.liferay.opensocial.model.Gadget in project liferay-ide by liferay.

the class LiferayOAuthStore method setTokenInfo.

public void setTokenInfo(SecurityToken securityToken, ConsumerInfo consumerInfo, String serviceName, String tokenName, TokenInfo tokenInfo) throws GadgetException {
    long userId = GetterUtil.getLong(securityToken.getViewerId());
    User user = null;
    try {
        user = UserLocalServiceUtil.getUser(userId);
    } catch (Exception e) {
        throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, e);
    }
    Gadget gadget = null;
    try {
        gadget = GadgetLocalServiceUtil.fetchGadget(user.getCompanyId(), securityToken.getAppUrl());
    } catch (SystemException se) {
        throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, se);
    }
    String gadgetKey = StringPool.BLANK;
    if (gadget == null) {
        gadgetKey = GadgetConstants.toAdhocGadgetKey(securityToken.getModuleId());
    } else {
        gadgetKey = GadgetConstants.toPublishedGadgetKey(gadget.getGadgetId());
    }
    try {
        OAuthTokenLocalServiceUtil.addOAuthToken(userId, gadgetKey, serviceName, securityToken.getModuleId(), tokenInfo.getAccessToken(), tokenName, tokenInfo.getTokenSecret(), tokenInfo.getSessionHandle(), tokenInfo.getTokenExpireMillis());
    } catch (Exception e) {
        throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, e);
    }
}
Also used : Gadget(com.liferay.opensocial.model.Gadget) User(com.liferay.portal.model.User) SystemException(com.liferay.portal.kernel.exception.SystemException) GadgetException(org.apache.shindig.gadgets.GadgetException) SystemException(com.liferay.portal.kernel.exception.SystemException) GadgetException(org.apache.shindig.gadgets.GadgetException)

Example 2 with Gadget

use of com.liferay.opensocial.model.Gadget in project liferay-ide by liferay.

the class GadgetLocalServiceImpl method updateGadget.

public Gadget updateGadget(long gadgetId, String portletCategoryNames) throws PortalException, SystemException {
    validate(portletCategoryNames);
    Gadget gadget = gadgetPersistence.findByPrimaryKey(gadgetId);
    gadget.setPortletCategoryNames(portletCategoryNames);
    gadgetPersistence.update(gadget);
    gadgetLocalService.initGadget(gadget.getUuid(), gadget.getCompanyId(), gadgetId, gadget.getName(), gadget.getPortletCategoryNames());
    return gadget;
}
Also used : Gadget(com.liferay.opensocial.model.Gadget)

Example 3 with Gadget

use of com.liferay.opensocial.model.Gadget in project liferay-ide by liferay.

the class GadgetLocalServiceImpl method addGadget.

public Gadget addGadget(long companyId, String url, String portletCategoryNames, ServiceContext serviceContext) throws PortalException, SystemException {
    Date now = new Date();
    validate(companyId, url, portletCategoryNames);
    long gadgetId = counterLocalService.increment();
    Gadget gadget = gadgetPersistence.create(gadgetId);
    gadget.setUuid(serviceContext.getUuid());
    gadget.setCompanyId(companyId);
    gadget.setCreateDate(now);
    gadget.setModifiedDate(now);
    GadgetSpec gadgetSpec = null;
    try {
        gadgetSpec = ShindigUtil.getGadgetSpec(url);
    } catch (Exception e) {
        throw new GadgetURLException(e);
    }
    ModulePrefs modulePrefs = gadgetSpec.getModulePrefs();
    gadget.setName(modulePrefs.getTitle());
    gadget.setUrl(url);
    gadget.setPortletCategoryNames(portletCategoryNames);
    gadgetPersistence.update(gadget);
    gadgetLocalService.initGadget(gadget.getUuid(), companyId, gadgetId, gadget.getName(), gadget.getPortletCategoryNames());
    return gadget;
}
Also used : GadgetSpec(org.apache.shindig.gadgets.spec.GadgetSpec) Gadget(com.liferay.opensocial.model.Gadget) ModulePrefs(org.apache.shindig.gadgets.spec.ModulePrefs) DuplicateGadgetURLException(com.liferay.opensocial.DuplicateGadgetURLException) GadgetURLException(com.liferay.opensocial.GadgetURLException) Date(java.util.Date) DuplicateGadgetURLException(com.liferay.opensocial.DuplicateGadgetURLException) PortalException(com.liferay.portal.kernel.exception.PortalException) SystemException(com.liferay.portal.kernel.exception.SystemException) GadgetPortletCategoryNamesException(com.liferay.opensocial.GadgetPortletCategoryNamesException) NoSuchGadgetException(com.liferay.opensocial.NoSuchGadgetException) GadgetURLException(com.liferay.opensocial.GadgetURLException)

Example 4 with Gadget

use of com.liferay.opensocial.model.Gadget in project liferay-ide by liferay.

the class GadgetPersistenceImpl method findByUuid_Last.

/**
 * Returns the last gadget in the ordered set where uuid = ?.
 *
 * @param uuid the uuid
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the last matching gadget
 * @throws com.liferay.opensocial.NoSuchGadgetException if a matching gadget could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public Gadget findByUuid_Last(String uuid, OrderByComparator orderByComparator) throws NoSuchGadgetException, SystemException {
    Gadget gadget = fetchByUuid_Last(uuid, orderByComparator);
    if (gadget != null) {
        return gadget;
    }
    StringBundler msg = new StringBundler(4);
    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
    msg.append("uuid=");
    msg.append(uuid);
    msg.append(StringPool.CLOSE_CURLY_BRACE);
    throw new NoSuchGadgetException(msg.toString());
}
Also used : Gadget(com.liferay.opensocial.model.Gadget) NoSuchGadgetException(com.liferay.opensocial.NoSuchGadgetException) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Example 5 with Gadget

use of com.liferay.opensocial.model.Gadget in project liferay-ide by liferay.

the class GadgetPersistenceImpl method findByCompanyId_PrevAndNext.

/**
 * Returns the gadgets before and after the current gadget in the ordered set where companyId = &#63;.
 *
 * @param gadgetId the primary key of the current gadget
 * @param companyId the company ID
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the previous, current, and next gadget
 * @throws com.liferay.opensocial.NoSuchGadgetException if a gadget with the primary key could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public Gadget[] findByCompanyId_PrevAndNext(long gadgetId, long companyId, OrderByComparator orderByComparator) throws NoSuchGadgetException, SystemException {
    Gadget gadget = findByPrimaryKey(gadgetId);
    Session session = null;
    try {
        session = openSession();
        Gadget[] array = new GadgetImpl[3];
        array[0] = getByCompanyId_PrevAndNext(session, gadget, companyId, orderByComparator, true);
        array[1] = gadget;
        array[2] = getByCompanyId_PrevAndNext(session, gadget, companyId, orderByComparator, false);
        return array;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}
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)

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