Search in sources :

Example 1 with OAuthConsumerImpl

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

the class OAuthConsumerPersistenceImpl method findByGadgetKey_PrevAndNext.

/**
 * Returns the o auth consumers before and after the current o auth consumer in the ordered set where gadgetKey = ?.
 *
 * @param oAuthConsumerId the primary key of the current o auth consumer
 * @param gadgetKey the gadget key
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the previous, current, and next o auth consumer
 * @throws com.liferay.opensocial.NoSuchOAuthConsumerException if a o auth consumer with the primary key could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public OAuthConsumer[] findByGadgetKey_PrevAndNext(long oAuthConsumerId, String gadgetKey, OrderByComparator orderByComparator) throws NoSuchOAuthConsumerException, SystemException {
    OAuthConsumer oAuthConsumer = findByPrimaryKey(oAuthConsumerId);
    Session session = null;
    try {
        session = openSession();
        OAuthConsumer[] array = new OAuthConsumerImpl[3];
        array[0] = getByGadgetKey_PrevAndNext(session, oAuthConsumer, gadgetKey, orderByComparator, true);
        array[1] = oAuthConsumer;
        array[2] = getByGadgetKey_PrevAndNext(session, oAuthConsumer, gadgetKey, orderByComparator, false);
        return array;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}
Also used : OAuthConsumerImpl(com.liferay.opensocial.model.impl.OAuthConsumerImpl) OAuthConsumer(com.liferay.opensocial.model.OAuthConsumer) SystemException(com.liferay.portal.kernel.exception.SystemException) NoSuchOAuthConsumerException(com.liferay.opensocial.NoSuchOAuthConsumerException) Session(com.liferay.portal.kernel.dao.orm.Session)

Example 2 with OAuthConsumerImpl

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

the class OAuthConsumerPersistenceImpl method create.

/**
 * Creates a new o auth consumer with the primary key. Does not add the o auth consumer to the database.
 *
 * @param oAuthConsumerId the primary key for the new o auth consumer
 * @return the new o auth consumer
 */
@Override
public OAuthConsumer create(long oAuthConsumerId) {
    OAuthConsumer oAuthConsumer = new OAuthConsumerImpl();
    oAuthConsumer.setNew(true);
    oAuthConsumer.setPrimaryKey(oAuthConsumerId);
    return oAuthConsumer;
}
Also used : OAuthConsumerImpl(com.liferay.opensocial.model.impl.OAuthConsumerImpl) OAuthConsumer(com.liferay.opensocial.model.OAuthConsumer)

Example 3 with OAuthConsumerImpl

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

the class OAuthConsumerPersistenceImpl method toUnwrappedModel.

protected OAuthConsumer toUnwrappedModel(OAuthConsumer oAuthConsumer) {
    if (oAuthConsumer instanceof OAuthConsumerImpl) {
        return oAuthConsumer;
    }
    OAuthConsumerImpl oAuthConsumerImpl = new OAuthConsumerImpl();
    oAuthConsumerImpl.setNew(oAuthConsumer.isNew());
    oAuthConsumerImpl.setPrimaryKey(oAuthConsumer.getPrimaryKey());
    oAuthConsumerImpl.setOAuthConsumerId(oAuthConsumer.getOAuthConsumerId());
    oAuthConsumerImpl.setCompanyId(oAuthConsumer.getCompanyId());
    oAuthConsumerImpl.setCreateDate(oAuthConsumer.getCreateDate());
    oAuthConsumerImpl.setModifiedDate(oAuthConsumer.getModifiedDate());
    oAuthConsumerImpl.setGadgetKey(oAuthConsumer.getGadgetKey());
    oAuthConsumerImpl.setServiceName(oAuthConsumer.getServiceName());
    oAuthConsumerImpl.setConsumerKey(oAuthConsumer.getConsumerKey());
    oAuthConsumerImpl.setConsumerSecret(oAuthConsumer.getConsumerSecret());
    oAuthConsumerImpl.setKeyType(oAuthConsumer.getKeyType());
    return oAuthConsumerImpl;
}
Also used : OAuthConsumerImpl(com.liferay.opensocial.model.impl.OAuthConsumerImpl)

Example 4 with OAuthConsumerImpl

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

the class LiferayOAuthStoreProvider method _getOAuthConsumer.

private OAuthConsumer _getOAuthConsumer(String keyFileName, String keyName) {
    OAuthConsumer oAuthConsumer = new OAuthConsumerImpl();
    oAuthConsumer.setConsumerKey(_DEFAULT_CONSUMER_KEY);
    oAuthConsumer.setServiceName(_DEFAULT_SERVICE_NAME);
    String consumerSecret = null;
    String path = PropsUtil.get(PropsKeys.LIFERAY_HOME).concat(_KEY_DIR);
    path = path.replaceAll(StringPool.QUOTE, StringPool.BLANK);
    keyFileName = path.concat(keyFileName);
    try {
        consumerSecret = FileUtil.read(keyFileName);
    } catch (Exception e) {
    } finally {
        if (consumerSecret == null) {
            if (!FileUtil.exists(path)) {
                FileUtil.mkdirs(path);
            }
            if (_log.isWarnEnabled()) {
                _log.warn("Unable to load OAuth key from " + keyFileName);
            }
            return null;
        }
    }
    consumerSecret = _convertFromOpenSsl(consumerSecret);
    oAuthConsumer.setConsumerSecret(consumerSecret);
    oAuthConsumer.setKeyType(OAuthConsumerConstants.KEY_TYPE_RSA_PRIVATE);
    oAuthConsumer.setKeyName(keyName);
    return oAuthConsumer;
}
Also used : OAuthConsumerImpl(com.liferay.opensocial.model.impl.OAuthConsumerImpl) OAuthConsumer(com.liferay.opensocial.model.OAuthConsumer)

Aggregations

OAuthConsumerImpl (com.liferay.opensocial.model.impl.OAuthConsumerImpl)4 OAuthConsumer (com.liferay.opensocial.model.OAuthConsumer)3 NoSuchOAuthConsumerException (com.liferay.opensocial.NoSuchOAuthConsumerException)1 Session (com.liferay.portal.kernel.dao.orm.Session)1 SystemException (com.liferay.portal.kernel.exception.SystemException)1