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);
}
}
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;
}
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;
}
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());
}
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 = ?.
*
* @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);
}
}
Aggregations