001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.oauth;
016    
017    import com.liferay.portal.kernel.oauth.OAuthException;
018    import com.liferay.portal.kernel.oauth.OAuthRequest;
019    import com.liferay.portal.kernel.oauth.OAuthResponse;
020    import com.liferay.portal.kernel.oauth.Verb;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class OAuthRequestImpl implements OAuthRequest {
026    
027            public OAuthRequestImpl(org.scribe.model.OAuthRequest oAuthRequest) {
028                    _oAuthRequest = oAuthRequest;
029            }
030    
031            @Override
032            public void addBodyParameter(String key, String value) {
033                    _oAuthRequest.addBodyParameter(key, value);
034            }
035    
036            @Override
037            public String getURL() {
038                    return _oAuthRequest.getUrl();
039            }
040    
041            @Override
042            public Verb getVerb() {
043                    return VerbTranslator.translate(_oAuthRequest.getVerb());
044            }
045    
046            @Override
047            public Object getWrappedOAuthRequest() {
048                    return _oAuthRequest;
049            }
050    
051            @Override
052            public OAuthResponse send() throws OAuthException {
053                    try {
054                            return new OAuthResponseImpl(_oAuthRequest.send());
055                    }
056                    catch (Exception e) {
057                            throw new OAuthException(e);
058                    }
059            }
060    
061            private org.scribe.model.OAuthRequest _oAuthRequest;
062    
063    }