public static void updateOAuthConsumers( ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long[] oAuthConsumerIds = ParamUtil.getLongValues(actionRequest, "oAuthConsumerId"); String gadgetKey = ParamUtil.getString(actionRequest, "gadgetKey"); String[] serviceNames = ParamUtil.getParameterValues(actionRequest, "serviceName"); String[] consumerKeys = ParamUtil.getParameterValues(actionRequest, "consumerKey"); String[] consumerSecrets = ParamUtil.getParameterValues(actionRequest, "consumerSecret"); String[] keyTypes = ParamUtil.getParameterValues(actionRequest, "keyType"); if ((serviceNames.length == 0) && (keyTypes.length != 0)) { serviceNames = new String[] {StringPool.BLANK}; } for (int i = 0; i < serviceNames.length; i++) { String consumerKey = (String) ArrayUtil.getValue(consumerKeys, i); String consumerSecret = (String) ArrayUtil.getValue(consumerSecrets, i); if (Validator.isNull(consumerKey)) { consumerKey = StringPool.BLANK; } if (Validator.isNull(consumerSecret)) { consumerSecret = StringPool.BLANK; } if (oAuthConsumerIds[i] <= 0) { OAuthConsumerLocalServiceUtil.addOAuthConsumer( themeDisplay.getCompanyId(), gadgetKey, serviceNames[i], consumerKey, consumerSecret, keyTypes[i]); } else { OAuthConsumerLocalServiceUtil.updateOAuthConsumer( oAuthConsumerIds[i], consumerKey, consumerSecret, keyTypes[i], StringPool.BLANK, StringPool.BLANK); } } }
protected OAuthConsumer getOAuthConsumer(SecurityToken securityToken, String serviceName) 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.getGadget(user.getCompanyId(), securityToken.getAppUrl()); } catch (Exception e) { throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, e); } OAuthConsumer oAuthConsumer = null; try { oAuthConsumer = OAuthConsumerLocalServiceUtil.getOAuthConsumer(gadget.getGadgetId(), serviceName); } catch (Exception e) { return _oAuthConsumer; } if (oAuthConsumer.getKeyType().equals(OAuthConsumerConstants.KEY_TYPE_RSA_PRIVATE)) { if (_oAuthConsumer == null) { throw new GadgetException( GadgetException.Code.INTERNAL_SERVER_ERROR, "No OAuth key specified"); } oAuthConsumer.setConsumerSecret(_oAuthConsumer.getConsumerSecret()); } return oAuthConsumer; }
public Object invokeMethod(String name, String[] parameterTypes, Object[] arguments) throws Throwable { if (_methodName0.equals(name) && Arrays.deepEquals(_methodParameterTypes0, parameterTypes)) { return OAuthConsumerLocalServiceUtil.addOAuthConsumer( (com.liferay.opensocial.model.OAuthConsumer) arguments[0]); } if (_methodName1.equals(name) && Arrays.deepEquals(_methodParameterTypes1, parameterTypes)) { return OAuthConsumerLocalServiceUtil.createOAuthConsumer(((Long) arguments[0]).longValue()); } if (_methodName2.equals(name) && Arrays.deepEquals(_methodParameterTypes2, parameterTypes)) { return OAuthConsumerLocalServiceUtil.deleteOAuthConsumer(((Long) arguments[0]).longValue()); } if (_methodName3.equals(name) && Arrays.deepEquals(_methodParameterTypes3, parameterTypes)) { return OAuthConsumerLocalServiceUtil.deleteOAuthConsumer( (com.liferay.opensocial.model.OAuthConsumer) arguments[0]); } if (_methodName4.equals(name) && Arrays.deepEquals(_methodParameterTypes4, parameterTypes)) { return OAuthConsumerLocalServiceUtil.dynamicQuery(); } if (_methodName5.equals(name) && Arrays.deepEquals(_methodParameterTypes5, parameterTypes)) { return OAuthConsumerLocalServiceUtil.dynamicQuery( (com.liferay.portal.kernel.dao.orm.DynamicQuery) arguments[0]); } if (_methodName6.equals(name) && Arrays.deepEquals(_methodParameterTypes6, parameterTypes)) { return OAuthConsumerLocalServiceUtil.dynamicQuery( (com.liferay.portal.kernel.dao.orm.DynamicQuery) arguments[0], ((Integer) arguments[1]).intValue(), ((Integer) arguments[2]).intValue()); } if (_methodName7.equals(name) && Arrays.deepEquals(_methodParameterTypes7, parameterTypes)) { return OAuthConsumerLocalServiceUtil.dynamicQuery( (com.liferay.portal.kernel.dao.orm.DynamicQuery) arguments[0], ((Integer) arguments[1]).intValue(), ((Integer) arguments[2]).intValue(), (com.liferay.portal.kernel.util.OrderByComparator) arguments[3]); } if (_methodName8.equals(name) && Arrays.deepEquals(_methodParameterTypes8, parameterTypes)) { return OAuthConsumerLocalServiceUtil.dynamicQueryCount( (com.liferay.portal.kernel.dao.orm.DynamicQuery) arguments[0]); } if (_methodName9.equals(name) && Arrays.deepEquals(_methodParameterTypes9, parameterTypes)) { return OAuthConsumerLocalServiceUtil.fetchOAuthConsumer(((Long) arguments[0]).longValue()); } if (_methodName10.equals(name) && Arrays.deepEquals(_methodParameterTypes10, parameterTypes)) { return OAuthConsumerLocalServiceUtil.getOAuthConsumer(((Long) arguments[0]).longValue()); } if (_methodName11.equals(name) && Arrays.deepEquals(_methodParameterTypes11, parameterTypes)) { return OAuthConsumerLocalServiceUtil.getPersistedModel((java.io.Serializable) arguments[0]); } if (_methodName12.equals(name) && Arrays.deepEquals(_methodParameterTypes12, parameterTypes)) { return OAuthConsumerLocalServiceUtil.getOAuthConsumers( ((Integer) arguments[0]).intValue(), ((Integer) arguments[1]).intValue()); } if (_methodName13.equals(name) && Arrays.deepEquals(_methodParameterTypes13, parameterTypes)) { return OAuthConsumerLocalServiceUtil.getOAuthConsumersCount(); } if (_methodName14.equals(name) && Arrays.deepEquals(_methodParameterTypes14, parameterTypes)) { return OAuthConsumerLocalServiceUtil.updateOAuthConsumer( (com.liferay.opensocial.model.OAuthConsumer) arguments[0]); } if (_methodName41.equals(name) && Arrays.deepEquals(_methodParameterTypes41, parameterTypes)) { return OAuthConsumerLocalServiceUtil.getBeanIdentifier(); } if (_methodName42.equals(name) && Arrays.deepEquals(_methodParameterTypes42, parameterTypes)) { OAuthConsumerLocalServiceUtil.setBeanIdentifier((java.lang.String) arguments[0]); return null; } if (_methodName47.equals(name) && Arrays.deepEquals(_methodParameterTypes47, parameterTypes)) { return OAuthConsumerLocalServiceUtil.addOAuthConsumer( ((Long) arguments[0]).longValue(), (java.lang.String) arguments[1], (java.lang.String) arguments[2], (java.lang.String) arguments[3], (java.lang.String) arguments[4], (java.lang.String) arguments[5]); } if (_methodName48.equals(name) && Arrays.deepEquals(_methodParameterTypes48, parameterTypes)) { return OAuthConsumerLocalServiceUtil.deleteOAuthConsumer(((Long) arguments[0]).longValue()); } if (_methodName49.equals(name) && Arrays.deepEquals(_methodParameterTypes49, parameterTypes)) { return OAuthConsumerLocalServiceUtil.deleteOAuthConsumer( (com.liferay.opensocial.model.OAuthConsumer) arguments[0]); } if (_methodName50.equals(name) && Arrays.deepEquals(_methodParameterTypes50, parameterTypes)) { OAuthConsumerLocalServiceUtil.deleteOAuthConsumers((java.lang.String) arguments[0]); return null; } if (_methodName51.equals(name) && Arrays.deepEquals(_methodParameterTypes51, parameterTypes)) { return OAuthConsumerLocalServiceUtil.fetchOAuthConsumer( (java.lang.String) arguments[0], (java.lang.String) arguments[1]); } if (_methodName52.equals(name) && Arrays.deepEquals(_methodParameterTypes52, parameterTypes)) { return OAuthConsumerLocalServiceUtil.getOAuthConsumer( (java.lang.String) arguments[0], (java.lang.String) arguments[1]); } if (_methodName53.equals(name) && Arrays.deepEquals(_methodParameterTypes53, parameterTypes)) { return OAuthConsumerLocalServiceUtil.getOAuthConsumers((java.lang.String) arguments[0]); } if (_methodName54.equals(name) && Arrays.deepEquals(_methodParameterTypes54, parameterTypes)) { return OAuthConsumerLocalServiceUtil.getOAuthConsumers( (java.lang.String) arguments[0], ((Integer) arguments[1]).intValue(), ((Integer) arguments[2]).intValue()); } if (_methodName55.equals(name) && Arrays.deepEquals(_methodParameterTypes55, parameterTypes)) { return OAuthConsumerLocalServiceUtil.getOAuthConsumersCount((java.lang.String) arguments[0]); } if (_methodName56.equals(name) && Arrays.deepEquals(_methodParameterTypes56, parameterTypes)) { return OAuthConsumerLocalServiceUtil.updateOAuthConsumer( ((Long) arguments[0]).longValue(), (java.lang.String) arguments[1], (java.lang.String) arguments[2], (java.lang.String) arguments[3], (java.lang.String) arguments[4], (java.lang.String) arguments[5]); } throw new UnsupportedOperationException(); }