http://git-wip-us.apache.org/repos/asf/camel/blob/b490a90c/components/camel-linkedin/camel-linkedin-api/src/main/resources/linkedin-api-wadl.xml ---------------------------------------------------------------------- diff --git a/components/camel-linkedin/camel-linkedin-api/src/main/resources/linkedin-api-wadl.xml b/components/camel-linkedin/camel-linkedin-api/src/main/resources/linkedin-api-wadl.xml new file mode 100644 index 0000000..f784a45 --- /dev/null +++ b/components/camel-linkedin/camel-linkedin-api/src/main/resources/linkedin-api-wadl.xml @@ -0,0 +1,1045 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> +<wadl:application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:wadl="http://wadl.dev.java.net/2009/02" + xmlns:tns="http://camel.apache.org/component/linkedin/api/model" + xsi:schemaLocation="http://camel.apache.org/component/linkedin/api/model linkedin-api-schema.xsd + http://wadl.dev.java.net/2009/02 http://www.w3.org/Submission/wadl/wadl.xsd"> + + <wadl:grammars> + <wadl:include href="linkedin-api-schema.xsd"/> + </wadl:grammars> + + <wadl:resources base="http://api.linkedin.com/v1/"> + + <!-- People --> + <wadl:resource path="people" id="People"> + + <wadl:resource path="~{fields}"> + <wadl:doc><![CDATA[https://developer.linkedin.com/documents/profile-api]]></wadl:doc> + <wadl:method name="GET" id="getPerson"> + <wadl:request> + <wadl:param href="#fields-selector"/> + <wadl:param href="#secure-urls"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#person"/> + </wadl:response> + </wadl:method> + + </wadl:resource> + + <wadl:resource path="~/connections{fields}"> + <wadl:doc><![CDATA[https://developer.linkedin.com/documents/connections-api]]></wadl:doc> + <wadl:method name="GET" id="getConnections"> + <wadl:request> + <wadl:param href="#fields-selector"/> + <wadl:param href="#secure-urls"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#connections"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="~/shares"> + <wadl:method name="POST" id="share"> + <wadl:request> + <wadl:representation mediaType="application/xml" element="tns:share"/> + </wadl:request> + <wadl:response> + <wadl:representation mediaType="application/xml" element="tns:update"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="~/network"> + <wadl:doc><![CDATA[https://developer.linkedin.com/documents/get-network-updates-and-statistics-api]]></wadl:doc> + + <wadl:resource path="updates{fields}"> + <wadl:param href="#scope"/> + <wadl:param href="#type"/> + <wadl:param href="#count"/> + <wadl:param href="#start"/> + <wadl:param href="#after"/> + <wadl:param href="#before"/> + <wadl:param href="#show-hidden-members"/> + + <wadl:method name="GET" id="getNetworkUpdates"> + <wadl:request> + <wadl:param href="#fields-selector"/> + <wadl:param href="#secure-urls"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#updates"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="updates/key={update-key}"> + <wadl:resource path="update-comments{fields}"> + <wadl:method name="GET" id="getUpdateComments"> + <wadl:request> + <wadl:param href="#update-key"/> + <wadl:param href="#fields-selector"/> + <wadl:param href="#secure-urls"/> + </wadl:request> + <wadl:response> + <wadl:representation mediaType="application/xml" element="tns:comments"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="update-comments"> + <wadl:method name="POST" id="addUpdateComment"> + <wadl:request> + <wadl:param href="#update-key"/> + <wadl:representation mediaType="application/xml" element="tns:updatecomment"/> + </wadl:request> + </wadl:method> + </wadl:resource> + + <wadl:resource path="likes{fields}"> + <wadl:method name="GET" id="getUpdateLikes"> + <wadl:request> + <wadl:param href="#update-key"/> + <wadl:param href="#fields-selector"/> + <wadl:param href="#secure-urls"/> + </wadl:request> + <wadl:response> + <wadl:representation mediaType="application/xml" element="tns:likes"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="is-liked"> + <wadl:method name="PUT" id="likeUpdate"> + <wadl:request> + <wadl:param href="#update-key"/> + <wadl:representation href="#is-liked"/> + </wadl:request> + </wadl:method> + </wadl:resource> + + </wadl:resource> + + <wadl:resource path="network-stats"> + <wadl:method name="GET" id="getNetworkStats"> + <wadl:response> + <wadl:representation mediaType="application/xml" element="tns:networkstats"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + </wadl:resource> + + <wadl:resource path="~/person-activities"> + <wadl:method name="POST" id="addActivity"> + <wadl:request> + <wadl:representation mediaType="application/xml" element="tns:activity"/> + </wadl:request> + </wadl:method> + </wadl:resource> + + <wadl:resource path="~/mailbox"> + <wadl:doc><![CDATA[https://developer.linkedin.com/documents/invitation-api]]></wadl:doc> + <wadl:method name="POST" id="addInvite"> + <wadl:request> + <wadl:representation mediaType="application/xml" element="tns:mailboxitem"/> + </wadl:request> + </wadl:method> + </wadl:resource> + + <wadl:resource path="~/group-memberships{fields}"> + <wadl:param name="membership-state" style="query" type="tns:membershipstate"/> + <wadl:param href="#fields-selector"/> + <wadl:method name="GET" id="getGroupMemberships"> + <wadl:request> + <wadl:param href="#count"/> + <wadl:param href="#start"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#groupmemberships"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="~/group-memberships"> + <wadl:method name="POST" id="addGroupMembership"> + <wadl:request> + <wadl:representation href="#groupmembership"/> + </wadl:request> + </wadl:method> + </wadl:resource> + + <wadl:resource path="~/group-memberships/{group-id}{fields}"> + <wadl:method name="GET" id="getGroupMembershipSettings"> + <wadl:request> + <wadl:param href="#group-id"/> + <wadl:param href="#fields-selector"/> + <wadl:param href="#count"/> + <wadl:param href="#start"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#groupmemberships"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="~/group-memberships/{group-id}"> + <wadl:method name="PUT" id="updateGroupMembership"> + <wadl:request> + <wadl:param href="#group-id"/> + <wadl:representation href="#groupmembership"/> + </wadl:request> + </wadl:method> + + <wadl:method name="DELETE" id="removeGroupMembership"> + <wadl:request> + <wadl:param href="#group-id"/> + </wadl:request> + </wadl:method> + + <wadl:resource path="posts{fields}"> + <wadl:method name="GET" id="getPosts"> + <wadl:request> + <wadl:param href="#group-id"/> + <wadl:param href="#start"/> + <wadl:param href="#count"/> + <wadl:param href="#order"/> + <wadl:param href="#role"/> + <wadl:param href="#category"/> + <wadl:param href="#modified-since"/> + <wadl:param href="#fields-selector"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#posts"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + </wadl:resource> + + <wadl:resource path="~/job-bookmarks"> + + <wadl:method name="GET" id="getJobBookmarks"> + <wadl:response> + <wadl:representation href="#job-bookmarks"/> + </wadl:response> + </wadl:method> + + <wadl:method name="POST" id="addJobBookmark"> + <wadl:request> + <wadl:representation href="#job-bookmark"/> + </wadl:request> + </wadl:method> + + <wadl:resource path="{job-id}"> + <wadl:method name="DELETE" id="removeJobBookmark"> + <wadl:request> + <wadl:param href="#job-id"/> + </wadl:request> + </wadl:method> + </wadl:resource> + </wadl:resource> + + <wadl:resource path="~/suggestions"> + + <wadl:resource path="groups{fields}"> + <wadl:method name="GET" id="getSuggestedGroups"> + <wadl:request> + <wadl:param href="#fields-selector"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#groups"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="groups"> + + <wadl:resource path="{group-id}"> + <wadl:method name="DELETE" id="removeGroupSuggestion"> + <wadl:request> + <wadl:param href="#group-id"/> + </wadl:request> + </wadl:method> + + <wadl:resource path="posts{fields}"> + <wadl:method name="GET" id="getSuggestedGroupPosts"> + <wadl:request> + <wadl:param href="#group-id"/> + <wadl:param href="#start"/> + <wadl:param href="#count"/> + <wadl:param href="#order"/> + <wadl:param href="#role"/> + <wadl:param href="#category"/> + <wadl:param href="#modified-since"/> + <wadl:param href="#fields-selector"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#posts"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + </wadl:resource> + </wadl:resource> + + <wadl:resource path="to-follow/companies{fields}"> + <wadl:method name="GET" id="getSuggestedCompanies"> + <wadl:request> + <wadl:param href="#fields-selector"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#companies"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="job-suggestions{fields}"> + <wadl:method name="GET" id="getSuggestedJobs"> + <wadl:request> + <wadl:param href="#fields-selector"/> + </wadl:request> + <wadl:response> + <wadl:representation mediaType="application/xml" element="tns:jobsuggestions"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + </wadl:resource> + + <wadl:resource path="~/following/companies{fields}"> + <wadl:method name="GET" id="getFollowedCompanies"> + <wadl:request> + <wadl:param href="#fields-selector"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#companies"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="~/following/companies"> + <wadl:method name="POST" id="followCompany"> + <wadl:request> + <wadl:representation href="#company"/> + </wadl:request> + </wadl:method> + </wadl:resource> + + <wadl:resource path="~/following/companies/id={company-id}"> + <wadl:method name="DELETE" id="stopFollowingCompany"> + <wadl:request> + <wadl:param href="#company-id"/> + </wadl:request> + </wadl:method> + </wadl:resource> + + <wadl:resource path="id={person-id}{fields}"> + <wadl:method name="GET" id="getPersonById"> + <wadl:request> + <wadl:param href="#person-id"/> + <wadl:param href="#fields-selector"/> + <wadl:param href="#secure-urls"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#person"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="id={person-id}/connections{fields}"> + <wadl:method name="GET" id="getConnectionsById"> + <wadl:request> + <wadl:param href="#person-id"/> + <wadl:param href="#fields-selector"/> + <wadl:param href="#secure-urls"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#connections"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="id={person-id}/network/updates{fields}"> + <wadl:param href="#scope"/> + <wadl:param href="#type"/> + <wadl:param href="#count"/> + <wadl:param href="#start"/> + <wadl:param href="#after"/> + <wadl:param href="#before"/> + <wadl:param href="#show-hidden-members"/> + <wadl:method name="GET" id="getNetworkUpdatesById"> + <wadl:request> + <wadl:param href="#person-id"/> + <wadl:param href="#fields-selector"/> + <wadl:param href="#secure-urls"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#updates"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="url={public-profile-url}{fields}"> + <wadl:method name="GET" id="getPersonByUrl"> + <wadl:request> + <wadl:param href="#public-profile-url"/> + <wadl:param href="#fields-selector"/> + <wadl:param href="#secure-urls"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#person"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="url={public-profile-url}/connections{fields}"> + <wadl:method name="GET" id="getConnectionsByUrl"> + <wadl:request> + <wadl:param href="#public-profile-url"/> + <wadl:param href="#fields-selector"/> + <wadl:param href="#secure-urls"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#connections"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + </wadl:resource> + + <!-- Groups Resource --> + <wadl:resource path="groups" id="Groups"> + <wadl:doc><![CDATA[https://developer.linkedin.com/documents/groups-api]]></wadl:doc> + + <wadl:resource path="{group-id}{fields}"> + <wadl:method name="GET" id="getGroup"> + <wadl:request> + <wadl:param href="#group-id"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#group"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="{group-id}"> + + <wadl:resource path="posts{fields}" type="tns:get-posts"/> + + <wadl:resource path="posts"> + <wadl:method name="POST" id="addPost"> + <wadl:request> + <wadl:param href="#group-id"/> + <wadl:representation href="#post"/> + </wadl:request> + </wadl:method> + </wadl:resource> + </wadl:resource> + + </wadl:resource> + + <!-- Posts Resource --> + <wadl:resource path="posts" id="Posts"> + <wadl:doc><![CDATA[https://developer.linkedin.com/documents/commenting-reading-comments-and-likes-network-updates]]></wadl:doc> + + <wadl:resource path="{post-id}{fields}"> + <wadl:method name="GET" id="getPost"> + <wadl:request> + <wadl:param href="#post-id"/> + <wadl:param href="#count"/> + <wadl:param href="#start"/> + <wadl:param href="#fields-selector"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#post"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="{post-id}/relation-to-viewer/is-liked"> + <wadl:method name="PUT" id="likePost"> + <wadl:request> + <wadl:param href="#post-id"/> + <wadl:representation href="#is-liked"/> + </wadl:request> + </wadl:method> + </wadl:resource> + + <wadl:resource path="{post-id}/relation-to-viewer/is-following"> + <wadl:method name="PUT" id="followPost"> + <wadl:request> + <wadl:param href="#post-id"/> + <wadl:representation href="#is-following"/> + </wadl:request> + </wadl:method> + </wadl:resource> + + <wadl:resource path="{post-id}/category/code"> + <wadl:method name="PUT" id="flagCategory"> + <wadl:request> + <wadl:param href="#post-id"/> + <wadl:representation mediaType="application/xml" element="tns:postcategorycode"/> + </wadl:request> + </wadl:method> + </wadl:resource> + + <wadl:resource path="{post-id}"> + <wadl:method name="DELETE" id="removePost"> + <wadl:request> + <wadl:param href="#post-id"/> + </wadl:request> + </wadl:method> + </wadl:resource> + + <wadl:resource path="{post-id}/comments{fields}"> + <wadl:method name="GET" id="getPostComments"> + <wadl:request> + <wadl:param href="#post-id"/> + <wadl:param href="#count"/> + <wadl:param href="#start"/> + <wadl:param href="#fields-selector"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#comments"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="{post-id}/comments"> + <wadl:method name="POST" id="addComment"> + <wadl:request> + <wadl:param href="#post-id"/> + <wadl:representation href="#comment"/> + </wadl:request> + </wadl:method> + </wadl:resource> + + </wadl:resource> + + <!-- Comments Resource --> + <wadl:resource path="comments" id="Comments"> + <wadl:doc><![CDATA[https://developer.linkedin.com/documents/commenting-reading-comments-and-likes-network-updates]]></wadl:doc> + + <wadl:resource path="{comment-id}{fields}"> + <wadl:method name="GET" id="getComment"> + <wadl:request> + <wadl:param href="#comment-id"/> + <wadl:param href="#fields-selector"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#comment"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="{comment-id}"> + <wadl:method name="DELETE" id="removeComment"> + <wadl:request> + <wadl:param href="#comment-id"/> + </wadl:request> + </wadl:method> + </wadl:resource> + + </wadl:resource> + + <!--Companies Resource --> + <wadl:resource id="Companies"> + <wadl:doc><![CDATA[https://developer.linkedin.com/documents/companies]]></wadl:doc> + + <wadl:resource path="companies{fields}"> + <wadl:method name="GET" id="getCompanies"> + <wadl:request> + <wadl:param href="#fields-selector"/> + <wadl:param name="email-domain" style="query"/> + <wadl:param name="is-company-admin" style="query" type="xsd:boolean"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#companies"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="companies"> + + <wadl:resource path="{company-id}{fields}"> + <wadl:method name="GET" id="getCompanyById"> + <wadl:request> + <wadl:param href="#company-id"/> + <wadl:param href="#fields-selector"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#company"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="universal-name={universal-name}{fields}"> + <wadl:method name="GET" id="getCompanyByName"> + <wadl:request> + <wadl:param name="universal-name" style="template"/> + <wadl:param href="#fields-selector"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#company"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="{company-id}"> + + <!-- Company updates --> + <wadl:resource path="updates{fields}"> + <wadl:method name="GET" id="getCompanyUpdates"> + <wadl:request> + <wadl:param href="#company-id"/> + <wadl:param href="#fields-selector"/> + <wadl:param href="#event-type"/> + <wadl:param href="#start"/> + <wadl:param href="#count"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#updates"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="updates/key={update-key}"> + <wadl:resource path="update-comments{fields}"> + <wadl:method name="GET" id="getCompanyUpdateComments"> + <wadl:request> + <wadl:param href="#company-id"/> + <wadl:param href="#update-key"/> + <wadl:param href="#fields-selector"/> + <wadl:param href="#secure-urls"/> + </wadl:request> + <wadl:response> + <wadl:representation mediaType="application/xml" element="tns:comments"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="update-comments"> + <wadl:method name="POST" id="addCompanyUpdateComment"> + <wadl:request> + <wadl:param href="#company-id"/> + <wadl:param href="#update-key"/> + <wadl:representation href="#update-comment"/> + </wadl:request> + </wadl:method> + </wadl:resource> + + <wadl:resource path="update-comments-as-company"> + <wadl:method name="POST" id="addCompanyUpdateCommentAsCompany"> + <wadl:request> + <wadl:param href="#company-id"/> + <wadl:param href="#update-key"/> + <wadl:representation href="#update-comment"/> + </wadl:request> + </wadl:method> + </wadl:resource> + + <wadl:resource path="likes{fields}"> + <wadl:method name="GET" id="getCompanyUpdateLikes"> + <wadl:request> + <wadl:param href="#company-id"/> + <wadl:param href="#update-key"/> + <wadl:param href="#fields-selector"/> + <wadl:param href="#secure-urls"/> + </wadl:request> + <wadl:response> + <wadl:representation mediaType="application/xml" element="tns:likes"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="is-liked"> + <wadl:method name="PUT" id="likeCompanyUpdate"> + <wadl:request> + <wadl:param href="#company-id"/> + <wadl:param href="#update-key"/> + <wadl:representation href="#is-liked"/> + </wadl:request> + </wadl:method> + </wadl:resource> + + </wadl:resource> + + <!-- Company shares --> + <wadl:resource path="shares"> + <wadl:doc><![CDATA[https://developer.linkedin.com/documents/share-api]]></wadl:doc> + <wadl:method name="POST" id="addShare"> + <wadl:request> + <wadl:param href="#company-id"/> + <wadl:representation mediaType="application/xml" element="tns:share"/> + </wadl:request> + </wadl:method> + </wadl:resource> + + <wadl:resource path="is-company-share-enabled"> + <wadl:method name="GET" id="isShareEnabled"> + <wadl:request> + <wadl:param href="#company-id"/> + </wadl:request> + <wadl:response> + <wadl:representation mediaType="application/xml" element="tns:iscompanyshareenabled"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="relation-to-viewer/is-company-share-enabled"> + <wadl:method name="GET" id="isViewerShareEnabled"> + <wadl:request> + <wadl:param href="#company-id"/> + </wadl:request> + <wadl:response> + <wadl:representation mediaType="application/xml" element="tns:iscompanyshareenabled"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <!-- Company Analytics --> + <wadl:resource path="historical-follow-statistics"> + <wadl:method name="GET" id="getHistoricalFollowStatistics"> + <wadl:request> + <wadl:param href="#company-id"/> + <wadl:param href="#start-timestamp"/> + <wadl:param href="#end-timestamp"/> + <wadl:param href="#time-granularity"/> + </wadl:request> + <wadl:response> + <wadl:representation mediaType="application/xml" element="tns:historicalfollowstatistics"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="historical-status-update-statistics"> + <wadl:method name="GET" id="getHistoricalStatusUpdateStatistics"> + <wadl:request> + <wadl:param href="#company-id"/> + <wadl:param href="#start-timestamp"/> + <wadl:param href="#end-timestamp"/> + <wadl:param href="#time-granularity"/> + <wadl:param name="update-key" style="query"/> + </wadl:request> + <wadl:response> + <wadl:representation mediaType="application/xml" element="tns:historicalstatusupdatestatistics"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="company-statistics"> + <wadl:method name="GET" id="getStatistics"> + <wadl:request> + <wadl:param href="#company-id"/> + </wadl:request> + <wadl:response> + <wadl:representation mediaType="application/xml" element="tns:companystatistics"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="num-followers"> + <wadl:method name="GET" id="getNumberOfFollowers"> + <wadl:request> + <wadl:param href="#company-id"/> + <wadl:param name="geos" style="query" repeating="true"/> + <wadl:param name="companySizes" style="query" repeating="true"/> + <wadl:param name="jobFunc" style="query" repeating="true"/> + <wadl:param name="industries" style="query" repeating="true"/> + <wadl:param name="seniorities" style="query" repeating="true"/> + </wadl:request> + <wadl:response> + <wadl:representation mediaType="application/xml" element="tns:numfollowers"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + </wadl:resource> + + </wadl:resource> + + </wadl:resource> + + <!-- Jobs --> + <wadl:resource path="jobs" id="Jobs"> + <wadl:doc><![CDATA[https://developer.linkedin.com/documents/jobs]]></wadl:doc> + + <wadl:method name="POST" id="addJob"> + <wadl:request> + <wadl:representation mediaType="application/xml" element="tns:job"/> + </wadl:request> + </wadl:method> + + <wadl:resource path="{job-id}${fields}"> + <wadl:method name="GET" id="getJob"> + <wadl:request> + <wadl:param href="#job-id"/> + <wadl:param href="#fields-selector"/> + </wadl:request> + <wadl:response> + <wadl:representation mediaType="application/xml" element="tns:job"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <wadl:resource path="partner-job-id={partner-job-id}"> + + <wadl:method name="PUT" id="editJob"> + <wadl:request> + <wadl:param href="#partner-job-id"/> + <wadl:representation mediaType="application/xml" element="tns:job"/> + </wadl:request> + </wadl:method> + + <wadl:method name="DELETE" id="removeJob"> + <wadl:request> + <wadl:param href="#partner-job-id"/> + </wadl:request> + </wadl:method> + + </wadl:resource> + + </wadl:resource> + + <!-- Search --> + <wadl:resource id="SearchResource"> + + <!-- People Search --> + <wadl:resource path="people-search{fields}"> + <wadl:doc><![CDATA[https://developer.linkedin.com/documents/people-search-api]]></wadl:doc> + <wadl:method name="GET" id="searchPeople"> + <wadl:request> + <wadl:param href="#fields-selector"/> + <wadl:param href="#keywords"/> + <wadl:param name="first-name" style="query" type="tns:first-name"/> + <wadl:param name="last-name" style="query" type="tns:last-name"/> + <wadl:param href="#company-name"/> + <wadl:param name="current-company" style="query" type="tns:current-company"/> + <wadl:param name="title" style="query" type="tns:title"/> + <wadl:param name="current-title" style="query" type="tns:current-title"/> + <wadl:param name="school-name" style="query" type="tns:school-name"/> + <wadl:param name="current-school" style="query" type="tns:current-school"/> + <wadl:param href="#country-code"/> + <wadl:param href="#postal-code"/> + <wadl:param href="#distance"/> + <wadl:param href="#facet"/> + <wadl:param href="#facets"/> + <wadl:param href="#start"/> + <wadl:param href="#count"/> + <wadl:param name="sort" style="query"/> + </wadl:request> + <wadl:response> + <wadl:representation mediaType="application/xml" element="tns:peoplesearch"/> + </wadl:response> + </wadl:method> + + </wadl:resource> + + <!-- Company Search --> + <wadl:resource path="company-search{fields}"> + <wadl:doc><![CDATA[https://developer.linkedin.com/documents/company-search]]></wadl:doc> + <wadl:method name="GET" id="searchCompanies"> + <wadl:request> + <wadl:param href="#fields-selector"/> + <wadl:param href="#keywords"/> + <wadl:param name="hq-only" style="query"/> + <wadl:param href="#facet"/> + <wadl:param href="#facets"/> + <wadl:param href="#start"/> + <wadl:param href="#count"/> + <wadl:param name="sort" style="query"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#company-search"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + <!-- Job Search --> + <wadl:resource path="job-search{fields}"> + <wadl:doc><![CDATA[https://developer.linkedin.com/documents/job-search-api]]></wadl:doc> + <wadl:method name="GET" id="searchJobs"> + <wadl:request> + <wadl:param href="#fields-selector"/> + <wadl:param href="#keywords"/> + <wadl:param href="#company-name"/> + <wadl:param name="job-title" style="query"/> + <wadl:param href="#country-code"/> + <wadl:param href="#postal-code"/> + <wadl:param href="#distance"/> + <wadl:param href="#facet"/> + <wadl:param href="#facets"/> + <wadl:param href="#start"/> + <wadl:param href="#count"/> + <wadl:param name="sort" style="query"/> + </wadl:request> + <wadl:response> + <wadl:representation href="#job-search"/> + </wadl:response> + </wadl:method> + </wadl:resource> + + </wadl:resource> + + </wadl:resources> + + <!-- id path param --> + <wadl:param name="person-id" style="template" required="true" id="person-id"/> + + <!-- field selector suffix --> + <wadl:param name="fields" style="template" id="fields-selector"/> + + <!-- return secure urls in profile --> + <wadl:param name="secure-urls" style="query" type="xsd:boolean" id="secure-urls"/> + + <!-- public profile url param --> + <wadl:param name="public-profile-url" style="template" type="xsd:anyURI" id="public-profile-url"/> + + <!-- group Id param --> + <wadl:param name="group-id" style="template" type="xsd:integer" required="true" id="group-id"/> + + <!-- post Id param --> + <wadl:param name="post-id" style="template" required="true" id="post-id"/> + + <!-- comment Id param --> + <wadl:param name="comment-id" style="template" required="true" id="comment-id"/> + + <!-- company Id param --> + <wadl:param name="company-id" style="template" type="xsd:integer" required="true" id="company-id"/> + + <!-- job Id param --> + <wadl:param name="job-id" style="template" type="xsd:integer" required="true" id="job-id"/> + + <!-- partner-job Id param --> + <wadl:param name="partner-job-id" style="template" type="xsd:integer" required="true" id="partner-job-id"/> + + <!-- posts params --> + <wadl:param name="order" style="query" id="order"> + <wadl:option value="recency"/> + <wadl:option value="popularity"/> + </wadl:param> + + <wadl:param name="role" style="query" id="role"> + <wadl:option value="creator"/> + <wadl:option value="commenter"/> + <wadl:option value="follower"/> + </wadl:param> + + <wadl:param name="category" style="query" id="category"> + <wadl:option value="discussion"/> + </wadl:param> + + <wadl:param name="modified-since" style="query" id="modified-since" type="xsd:integer"/> + + <wadl:param name="scope" style="query" type="tns:scope" id="scope"/> + + <wadl:param name="type" style="query" id="type"> + <wadl:option value="APPS"/> + <wadl:option value="CMPY"/> + <wadl:option value="CONN"/> + <wadl:option value="JOBS"/> + <wadl:option value="JGRP"/> + <wadl:option value="PICT"/> + <wadl:option value="PFOL"/> + <wadl:option value="PRFX"/> + <wadl:option value="RECU"/> + <wadl:option value="PRFU"/> + <wadl:option value="SHAR"/> + <wadl:option value="STAT"/> + <wadl:option value="VIRL"/> + </wadl:param> + + <wadl:param name="keywords" style="query" type="tns:keywords" id="keywords"/> + + <wadl:param name="facet" style="query" id="facet"/> + + <wadl:param name="facets" style="query" id="facets"/> + + <wadl:param name="start" style="query" type="xsd:integer" id="start"/> + + <wadl:param name="count" style="query" type="xsd:integer" id="count"/> + + <wadl:param name="company-name" style="query" type="tns:company-name" id="company-name"/> + + <wadl:param name="country-code" style="query" type="tns:country-code" id="country-code"/> + + <wadl:param name="postal-code" style="query" type="tns:postal-code" id="postal-code"/> + + <wadl:param name="distance" style="query" type="tns:distance" id="distance"/> + + <wadl:param name="after" style="query" type="xsd:integer" id="after"/> + + <wadl:param name="before" style="query" type="xsd:integer" id="before"/> + + <wadl:param name="show-hidden-members" style="query" type="xsd:boolean" id="show-hidden-members"/> + + <!-- update-key path param --> + <wadl:param name="update-key" style="template" id="update-key"/> + + <wadl:param name="event-type" style="query" id="event-type"> + <wadl:option value="job-posting"/> + <wadl:option value="new-product"/> + <wadl:option value="status-update"/> + </wadl:param> + + <wadl:param name="start-timestamp" style="query" type="xsd:integer" id="start-timestamp"/> + <wadl:param name="end-timestamp" style="query" type="xsd:integer" id="end-timestamp"/> + <wadl:param name="time-granularity" style="query" id="time-granularity"> + <wadl:option value="day"/> + <wadl:option value="month"/> + </wadl:param> + + <!-- representation types --> + <wadl:representation mediaType="application/xml" element="tns:person" id="person"/> + + <wadl:representation mediaType="application/xml" element="tns:connections" id="connections"/> + + <wadl:representation mediaType="application/xml" element="tns:updates" id="updates"/> + + <wadl:representation mediaType="application/xml" element="tns:groupmembership" id="groupmembership"/> + <wadl:representation mediaType="application/xml" element="tns:groupmemberships" id="groupmemberships"/> + + <wadl:representation mediaType="application/xml" element="tns:group" id="group"/> + <wadl:representation mediaType="application/xml" element="tns:groups" id="groups"/> + + <wadl:representation mediaType="application/xml" element="tns:post" id="post"/> + <wadl:representation mediaType="application/xml" element="tns:posts" id="posts"/> + + <wadl:representation mediaType="application/xml" element="tns:comment" id="comment"/> + <wadl:representation mediaType="application/xml" element="tns:comments" id="comments"/> + + <wadl:representation mediaType="application/xml" element="tns:company" id="company"/> + <wadl:representation mediaType="application/xml" element="tns:companies" id="companies"/> + <wadl:representation mediaType="application/xml" element="tns:companysearch" id="company-search"/> + + <wadl:representation mediaType="application/xml" element="tns:isliked" id="is-liked"/> + + <wadl:representation mediaType="application/xml" element="tns:isfollowing" id="is-following"/> + + <wadl:representation mediaType="application/xml" element="tns:updatecomment" id="update-comment"/> + + <wadl:representation mediaType="application/xml" element="tns:jobbookmark" id="job-bookmark"/> + <wadl:representation mediaType="application/xml" element="tns:jobbookmarks" id="job-bookmarks"/> + <wadl:representation mediaType="application/xml" element="tns:jobsearch" id="job-search"/> + +</wadl:application> \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/b490a90c/components/camel-linkedin/camel-linkedin-api/src/main/resources/wadl.xsd ---------------------------------------------------------------------- diff --git a/components/camel-linkedin/camel-linkedin-api/src/main/resources/wadl.xsd b/components/camel-linkedin/camel-linkedin-api/src/main/resources/wadl.xsd new file mode 100644 index 0000000..1f71474 --- /dev/null +++ b/components/camel-linkedin/camel-linkedin-api/src/main/resources/wadl.xsd @@ -0,0 +1,263 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://wadl.dev.java.net/2009/02" + xmlns:tns="http://wadl.dev.java.net/2009/02" + xmlns:xml="http://www.w3.org/XML/1998/namespace" + elementFormDefault="qualified"> + + <xs:import namespace="http://www.w3.org/XML/1998/namespace" + schemaLocation="http://www.w3.org/2001/xml.xsd"/> + + <xs:element name="application"> + <xs:complexType> + <xs:sequence> + <xs:element ref="tns:doc" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="tns:grammars" minOccurs="0"/> + <xs:element ref="tns:resources" minOccurs="0" + maxOccurs="unbounded"/> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element ref="tns:resource_type"/> + <xs:element ref="tns:method"/> + <xs:element ref="tns:representation"/> + <xs:element ref="tns:param"/> + </xs:choice> + <xs:any namespace="##other" processContents="lax" minOccurs="0" + maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="doc"> + <xs:complexType mixed="true"> + <xs:sequence> + <xs:any namespace="##other" processContents="lax" minOccurs="0" + maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="title" type="xs:string"/> + <xs:attribute ref="xml:lang"/> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:complexType> + </xs:element> + + <xs:element name="grammars"> + <xs:complexType> + <xs:sequence> + <xs:element ref="tns:doc" minOccurs="0" maxOccurs="unbounded"/> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="tns:include"/> + <xs:any namespace="##other" processContents="lax" minOccurs="0" + maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="resources"> + <xs:complexType> + <xs:sequence> + <xs:element ref="tns:doc" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="tns:resource" maxOccurs="unbounded"/> + <xs:any namespace="##other" processContents="lax" minOccurs="0" + maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="base" type="xs:anyURI"/> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:complexType> + </xs:element> + + <xs:element name="resource"> + <xs:complexType> + <xs:sequence> + <xs:element ref="tns:doc" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="tns:param" minOccurs="0" maxOccurs="unbounded"/> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element ref="tns:method"/> + <xs:element ref="tns:resource"/> + </xs:choice> + <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other" + processContents="lax"/> + </xs:sequence> + <xs:attribute name="id" type="xs:ID"/> + <xs:attribute name="type" type="tns:resource_type_list"/> + <xs:attribute name="queryType" type="xs:string" + default="application/x-www-form-urlencoded"/> + <xs:attribute name="path" type="xs:string"/> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:complexType> + </xs:element> + + <xs:simpleType name="resource_type_list"> + <xs:list itemType="xs:anyURI"/> + </xs:simpleType> + + <xs:element name="resource_type"> + <xs:complexType> + <xs:sequence> + <xs:element ref="tns:doc" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="tns:param" minOccurs="0" maxOccurs="unbounded"/> + <xs:choice minOccurs="0" maxOccurs="unbounded"> + <xs:element ref="tns:method"/> + <xs:element ref="tns:resource"/> + </xs:choice> + <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##other" + processContents="lax"/> + </xs:sequence> + <xs:attribute name="id" type="xs:ID"/> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:complexType> + </xs:element> + + <xs:element name="method"> + <xs:complexType> + <xs:sequence> + <xs:element ref="tns:doc" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="tns:request" minOccurs="0"/> + <xs:element ref="tns:response" minOccurs="0" + maxOccurs="unbounded"/> + <xs:any namespace="##other" processContents="lax" minOccurs="0" + maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="id" type="xs:ID"/> + <xs:attribute name="name" type="tns:Method"/> + <xs:attribute name="href" type="xs:anyURI"/> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:complexType> + </xs:element> + + <xs:simpleType name="Method"> + <xs:union memberTypes="tns:HTTPMethods xs:NMTOKEN"/> + </xs:simpleType> + + <xs:simpleType name="HTTPMethods"> + <xs:restriction base="xs:NMTOKEN"> + <xs:enumeration value="GET"/> + <xs:enumeration value="POST"/> + <xs:enumeration value="PUT"/> + <xs:enumeration value="HEAD"/> + <xs:enumeration value="DELETE"/> + </xs:restriction> + </xs:simpleType> + + <xs:element name="include"> + <xs:complexType> + <xs:sequence> + <xs:element ref="tns:doc" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="href" type="xs:anyURI"/> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:complexType> + </xs:element> + + <xs:element name="request"> + <xs:complexType> + <xs:sequence> + <xs:element ref="tns:doc" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="tns:param" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="tns:representation" minOccurs="0" + maxOccurs="unbounded"/> + <xs:any namespace="##other" processContents="lax" minOccurs="0" + maxOccurs="unbounded"/> + </xs:sequence> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:complexType> + </xs:element> + + <xs:element name="response"> + <xs:complexType> + <xs:sequence> + <xs:element ref="tns:doc" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="tns:param" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="tns:representation" minOccurs="0" + maxOccurs="unbounded"/> + <xs:any namespace="##other" processContents="lax" minOccurs="0" + maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="status" type="tns:statusCodeList"/> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:complexType> + </xs:element> + + <xs:simpleType name="uriList"> + <xs:list itemType="xs:anyURI"/> + </xs:simpleType> + + <xs:element name="representation"> + <xs:complexType> + <xs:sequence> + <xs:element ref="tns:doc" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="tns:param" minOccurs="0" maxOccurs="unbounded"/> + <xs:any namespace="##other" processContents="lax" minOccurs="0" + maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="id" type="xs:ID"/> + <xs:attribute name="element" type="xs:QName"/> + <xs:attribute name="mediaType" type="xs:string"/> + <xs:attribute name="href" type="xs:anyURI"/> + <xs:attribute name="profile" type="tns:uriList"/> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:complexType> + </xs:element> + + <xs:simpleType name="statusCodeList"> + <xs:list itemType="xs:unsignedInt"/> + </xs:simpleType> + + <xs:simpleType name="ParamStyle"> + <xs:restriction base="xs:string"> + <xs:enumeration value="plain"/> + <xs:enumeration value="query"/> + <xs:enumeration value="matrix"/> + <xs:enumeration value="header"/> + <xs:enumeration value="template"/> + </xs:restriction> + </xs:simpleType> + + <xs:element name="param"> + <xs:complexType> + <xs:sequence> + <xs:element ref="tns:doc" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="tns:option" minOccurs="0" maxOccurs="unbounded"/> + <xs:element ref="tns:link" minOccurs="0"/> + <xs:any namespace="##other" processContents="lax" minOccurs="0" + maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="href" type="xs:anyURI"/> + <xs:attribute name="name" type="xs:NMTOKEN"/> + <xs:attribute name="style" type="tns:ParamStyle"/> + <xs:attribute name="id" type="xs:ID"/> + <xs:attribute name="type" type="xs:QName" default="xs:string"/> + <xs:attribute name="default" type="xs:string"/> + <xs:attribute name="required" type="xs:boolean" default="false"/> + <xs:attribute name="repeating" type="xs:boolean" default="false"/> + <xs:attribute name="fixed" type="xs:string"/> + <xs:attribute name="path" type="xs:string"/> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:complexType> + </xs:element> + + <xs:element name="option"> + <xs:complexType> + <xs:sequence> + <xs:element ref="tns:doc" minOccurs="0" maxOccurs="unbounded"/> + <xs:any namespace="##other" processContents="lax" minOccurs="0" + maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="value" type="xs:string" use="required"/> + <xs:attribute name="mediaType" type="xs:string"/> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:complexType> + </xs:element> + + <xs:element name="link"> + <xs:complexType> + <xs:sequence> + <xs:element ref="tns:doc" minOccurs="0" maxOccurs="unbounded"/> + <xs:any namespace="##other" processContents="lax" minOccurs="0" + maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="resource_type" type="xs:anyURI"/> + <xs:attribute name="rel" type="xs:token"/> + <xs:attribute name="rev" type="xs:token"/> + <xs:anyAttribute namespace="##other" processContents="lax"/> + </xs:complexType> + </xs:element> + +</xs:schema> http://git-wip-us.apache.org/repos/asf/camel/blob/b490a90c/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/AbstractResourceIntegrationTest.java ---------------------------------------------------------------------- diff --git a/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/AbstractResourceIntegrationTest.java b/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/AbstractResourceIntegrationTest.java new file mode 100644 index 0000000..1d4c536 --- /dev/null +++ b/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/AbstractResourceIntegrationTest.java @@ -0,0 +1,125 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.linkedin.api; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; +import javax.ws.rs.WebApplicationException; + +import org.apache.camel.component.linkedin.api.model.Error; +import org.apache.cxf.jaxrs.client.JAXRSClientFactory; +import org.apache.cxf.jaxrs.client.WebClient; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Base class for resource tests. + */ +public class AbstractResourceIntegrationTest extends Assert { + + protected static final Logger LOG = LoggerFactory.getLogger(PeopleResourceIntegrationTest.class); + protected static final String DEFAULT_FIELDS = ""; + + protected static LinkedInOAuthRequestFilter requestFilter; + private static Properties properties; + private static OAuthToken token; + private static List<Object> resourceList = new ArrayList<Object>(); + + @BeforeClass + public static void beforeClass() throws Exception { + properties = new Properties(); + properties.load(PeopleResourceIntegrationTest.class.getResourceAsStream("/test-options.properties")); + + requestFilter = createOAuthHelper(); + } + + private static LinkedInOAuthRequestFilter createOAuthHelper() throws IOException { + final String userName = properties.getProperty("userName"); + final String userPassword = properties.getProperty("userPassword"); + final String clientId = properties.getProperty("clientId"); + final String clientSecret = properties.getProperty("clientSecret"); + final String redirectUri = properties.getProperty("redirectUri"); + + final OAuthScope[] scopes; + final String scope = properties.getProperty("scope"); + if (scope != null) { + scopes = OAuthScope.fromValues(scope.split(",")); + } else { + scopes = null; + } + + final OAuthSecureStorage secureStorage = new OAuthSecureStorage() { + @Override + public OAuthToken getOAuthToken() { + return token; + } + + @Override + public void saveOAuthToken(OAuthToken newToken) { + token = newToken; + } + }; + + final OAuthParams oAuthParams = new OAuthParams(userName, userPassword, secureStorage, + clientId, clientSecret, redirectUri, scopes); + return new LinkedInOAuthRequestFilter(oAuthParams, null, false); + } + + @AfterClass + public static void afterClass() throws Exception { + // close all proxies + for (Object resource : resourceList) { + try { + WebClient.client(resource).close(); + } catch (Exception ignore) { + } + } + if (requestFilter != null) { + requestFilter.close(); + } + // TODO save and load token from test-options.properties + } + + protected static <T> T getResource(Class<T> resourceClass) { + if (requestFilter == null) { + throw new IllegalStateException(AbstractResourceIntegrationTest.class.getName() + + ".beforeClass must be invoked before getResource"); + } + final T resource = JAXRSClientFactory.create(LinkedInOAuthRequestFilter.BASE_ADDRESS, resourceClass, +// Arrays.asList(new Object[] { requestFilter, new LinkedInExceptionResponseFilter() } )); + Arrays.asList(new Object[]{requestFilter})); + resourceList.add(resource); + return resource; + } + + protected void execute(Runnable runnable) { + try { + runnable.run(); + } catch (WebApplicationException e) { + final org.apache.camel.component.linkedin.api.model.Error error = e.getResponse().readEntity(Error.class); + assertNotNull(error); + LOG.error("Error: {}", error.getMessage()); + throw new LinkedInException(error, e.getResponse()); + } + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/b490a90c/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/PeopleResourceIntegrationTest.java ---------------------------------------------------------------------- diff --git a/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/PeopleResourceIntegrationTest.java b/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/PeopleResourceIntegrationTest.java new file mode 100644 index 0000000..6256b6a --- /dev/null +++ b/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/PeopleResourceIntegrationTest.java @@ -0,0 +1,99 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.linkedin.api; + +import java.util.Date; + +import org.apache.camel.component.linkedin.api.model.JobSuggestions; +import org.apache.camel.component.linkedin.api.model.Person; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Integration test for {@link PeopleResource}. + */ +public class PeopleResourceIntegrationTest extends AbstractResourceIntegrationTest { + + private static PeopleResource peopleResource; + + @BeforeClass + public static void beforeClass() throws Exception { + AbstractResourceIntegrationTest.beforeClass(); + + final Class<PeopleResource> resourceClass = PeopleResource.class; + PeopleResourceIntegrationTest.peopleResource = getResource(resourceClass); + } + + @Test + public void testGetPerson() throws Exception { + execute(new Runnable() { + @Override + public void run() { + final Person person = peopleResource.getPerson(":(id)", true); + assertNotNull(person); + assertNotNull(person.getId()); + LOG.debug("getPerson result: " + person); + } + }); + } + + @Test(expected = LinkedInException.class) + public void testLinkedInError() throws Exception { + execute(new Runnable() { + @Override + public void run() { + peopleResource.getPerson("bad_fields_selector", true); + } + }); + } + + @Ignore("CXF swallows application exceptions from ClientResponseFilters") + @Test(expected = LinkedInException.class) + public void testLinkedInException() throws Exception { + try { + peopleResource.getPerson("bad_fields_selector", true); + } catch (LinkedInException e) { + assertNotNull(e.getError()); + LOG.debug("getPerson error: " + e.getMessage()); + throw e; + } + } + + @Test + public void testOAuthTokenRefresh() throws Exception { + peopleResource.getPerson("", false); + + // mark OAuth token as expired + final OAuthToken oAuthToken = requestFilter.getOAuthToken(); + oAuthToken.setExpiryTime(new Date().getTime()); + + peopleResource.getPerson("", false); + } + + @Test + public void testGetSuggestedJobs() throws Exception { + execute(new Runnable() { + @Override + public void run() { + final JobSuggestions suggestedJobs = peopleResource.getSuggestedJobs(DEFAULT_FIELDS); + assertNotNull(suggestedJobs); + LOG.debug("Suggested Jobs " + suggestedJobs.getJobs()); + } + }); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/b490a90c/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/SearchResourceIntegrationTest.java ---------------------------------------------------------------------- diff --git a/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/SearchResourceIntegrationTest.java b/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/SearchResourceIntegrationTest.java new file mode 100644 index 0000000..002000b --- /dev/null +++ b/components/camel-linkedin/camel-linkedin-api/src/test/java/org/apache/camel/component/linkedin/api/SearchResourceIntegrationTest.java @@ -0,0 +1,47 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.linkedin.api; + +import org.apache.camel.component.linkedin.api.model.CompanySearch; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Integration test for {@link org.apache.camel.component.linkedin.api.SearchResource} + */ +public class SearchResourceIntegrationTest extends AbstractResourceIntegrationTest { + + private static SearchResource searchResource; + + @BeforeClass + public static void beforeClass() throws Exception { + AbstractResourceIntegrationTest.beforeClass(); + searchResource = getResource(SearchResource.class); + } + + @Test + public void testSearchCompanies() { + execute(new Runnable() { + @Override + public void run() { + final CompanySearch companySearch = searchResource.searchCompanies(DEFAULT_FIELDS, "linkedin", null, null, + null, null, null, null); + assertNotNull(companySearch); + } + }); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/b490a90c/components/camel-linkedin/camel-linkedin-component/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-linkedin/camel-linkedin-component/pom.xml b/components/camel-linkedin/camel-linkedin-component/pom.xml new file mode 100644 index 0000000..42311e2 --- /dev/null +++ b/components/camel-linkedin/camel-linkedin-component/pom.xml @@ -0,0 +1,280 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.camel.component.linkedin</groupId> + <artifactId>camel-linkedin-parent</artifactId> + <version>2.14-SNAPSHOT</version> + </parent> + + <artifactId>camel-linkedin</artifactId> + <packaging>bundle</packaging> + <name>Camel LinkedIn Component</name> + <description>Camel Component for LinkedIn</description> + + <properties> + <schemeName>linkedin</schemeName> + <componentName>LinkedIn</componentName> + <componentPackage>org.apache.camel.component.linkedin</componentPackage> + <outPackage>org.apache.camel.component.linkedin.internal</outPackage> + + <camel.osgi.export.pkg>${componentPackage}</camel.osgi.export.pkg> + <camel.osgi.private.pkg>${outPackage}</camel.osgi.private.pkg> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.component.linkedin</groupId> + <artifactId>camel-linkedin-api</artifactId> + <version>${project.version}</version> + </dependency> + + <!-- Camel annotations in runtime scope to avoid compile errors in IDEs --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>spi-annotations</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + + <!-- Component API javadoc in provided scope to read API signatures --> + <dependency> + <groupId>org.apache.camel.component.linkedin</groupId> + <artifactId>camel-linkedin-api</artifactId> + <version>${project.version}</version> + <classifier>javadoc</classifier> + <scope>provided</scope> + </dependency> + + <!-- logging --> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <scope>test</scope> + </dependency> + + <!-- testing --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-test</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + + <!-- generate Component source and test source --> + <plugin> + <groupId>org.apache.camel</groupId> + <artifactId>camel-api-component-maven-plugin</artifactId> + <executions> + <execution> + <id>generate-test-component-classes</id> + <goals> + <goal>fromApis</goal> + </goals> + <configuration> + <apis> + <api> + <apiName>comments</apiName> + <proxyClass>org.apache.camel.component.linkedin.api.CommentsResource</proxyClass> + <fromJavadoc/> + </api> + <api> + <apiName>companies</apiName> + <proxyClass>org.apache.camel.component.linkedin.api.CompaniesResource</proxyClass> + <fromJavadoc/> + <nullableOptions> + <nullableOption>companySizes</nullableOption> + <nullableOption>count</nullableOption> + <nullableOption>email_domain</nullableOption> + <nullableOption>end_timestamp</nullableOption> + <nullableOption>event_type</nullableOption> + <nullableOption>geos</nullableOption> + <nullableOption>industries</nullableOption> + <nullableOption>is_company_admin</nullableOption> + <nullableOption>jobFunc</nullableOption> + <nullableOption>secure_urls</nullableOption> + <nullableOption>seniorities</nullableOption> + <nullableOption>start</nullableOption> + <nullableOption>start_timestamp</nullableOption> + <nullableOption>time_granularity</nullableOption> + </nullableOptions> + </api> + <api> + <apiName>groups</apiName> + <proxyClass>org.apache.camel.component.linkedin.api.GroupsResource</proxyClass> + <fromJavadoc/> + </api> + <api> + <apiName>jobs</apiName> + <proxyClass>org.apache.camel.component.linkedin.api.JobsResource</proxyClass> + <fromJavadoc/> + </api> + <api> + <apiName>people</apiName> + <proxyClass>org.apache.camel.component.linkedin.api.PeopleResource</proxyClass> + <fromJavadoc/> + <nullableOptions> + <nullableOption>after</nullableOption> + <nullableOption>before</nullableOption> + <nullableOption>category</nullableOption> + <nullableOption>count</nullableOption> + <nullableOption>membership_state</nullableOption> + <nullableOption>modified_since</nullableOption> + <nullableOption>order</nullableOption> + <nullableOption>public_profile_url</nullableOption> + <nullableOption>role</nullableOption> + <nullableOption>scope</nullableOption> + <nullableOption>secure_urls</nullableOption> + <nullableOption>show_hidden_members</nullableOption> + <nullableOption>start</nullableOption> + <nullableOption>type</nullableOption> + </nullableOptions> + </api> + <api> + <apiName>posts</apiName> + <proxyClass>org.apache.camel.component.linkedin.api.PostsResource</proxyClass> + <fromJavadoc/> + <nullableOptions> + <nullableOption>count</nullableOption> + <nullableOption>start</nullableOption> + </nullableOptions> + </api> + <api> + <apiName>search</apiName> + <proxyClass>org.apache.camel.component.linkedin.api.SearchResource</proxyClass> + <fromJavadoc/> + <nullableOptions> + <nullableOption>company_name</nullableOption> + <nullableOption>count</nullableOption> + <nullableOption>country_code</nullableOption> + <nullableOption>current_company</nullableOption> + <nullableOption>current_school</nullableOption> + <nullableOption>current_title</nullableOption> + <nullableOption>distance</nullableOption> + <nullableOption>facet</nullableOption> + <nullableOption>facets</nullableOption> + <nullableOption>first_name</nullableOption> + <nullableOption>hq_only</nullableOption> + <nullableOption>job_title</nullableOption> + <nullableOption>keywords</nullableOption> + <nullableOption>last_name</nullableOption> + <nullableOption>postal_code</nullableOption> + <nullableOption>school_name</nullableOption> + <nullableOption>sort</nullableOption> + <nullableOption>start</nullableOption> + <nullableOption>title</nullableOption> + </nullableOptions> + </api> + </apis> + <aliases> + <alias> + <methodPattern>(add|get|remove|search)(.+)</methodPattern> + <methodAlias>$2</methodAlias> + </alias> + </aliases> + </configuration> + </execution> + </executions> + </plugin> + + <!-- add generated source and test source to build --> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-generated-sources</id> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>${project.build.directory}/generated-sources/camel-component</source> + </sources> + </configuration> + </execution> + <execution> + <id>add-generated-test-sources</id> + <goals> + <goal>add-test-source</goal> + </goals> + <configuration> + <sources> + <source>${project.build.directory}/generated-test-sources/camel-component</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + + </plugins> + + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.camel</groupId> + <artifactId>camel-api-component-maven-plugin</artifactId> + <version>${project.version}</version> + <configuration> + <scheme>${schemeName}</scheme> + <componentName>${componentName}</componentName> + <componentPackage>${componentPackage}</componentPackage> + <outPackage>${outPackage}</outPackage> + </configuration> + </plugin> + </plugins> + </pluginManagement> + + </build> + + <reporting> + <plugins> + <plugin> + <groupId>org.apache.camel</groupId> + <artifactId>camel-api-component-maven-plugin</artifactId> + <version>${project.version}</version> + <configuration> + <scheme>${schemeName}</scheme> + <componentName>${componentName}</componentName> + <componentPackage>${componentPackage}</componentPackage> + <outPackage>${outPackage}</outPackage> + </configuration> + </plugin> + </plugins> + </reporting> + +</project> http://git-wip-us.apache.org/repos/asf/camel/blob/b490a90c/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInComponent.java b/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInComponent.java new file mode 100644 index 0000000..4434f8c --- /dev/null +++ b/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInComponent.java @@ -0,0 +1,106 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.linkedin; + +import org.apache.camel.CamelContext; +import org.apache.camel.Endpoint; +import org.apache.camel.component.linkedin.api.LinkedInOAuthRequestFilter; +import org.apache.camel.component.linkedin.api.OAuthParams; +import org.apache.camel.component.linkedin.internal.CachingOAuthSecureStorage; +import org.apache.camel.component.linkedin.internal.LinkedInApiCollection; +import org.apache.camel.component.linkedin.internal.LinkedInApiName; +import org.apache.camel.spi.UriEndpoint; +import org.apache.camel.util.component.AbstractApiComponent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Represents the component that manages {@link LinkedInEndpoint}. + */ +@UriEndpoint(scheme = "linkedin", consumerClass = LinkedInConsumer.class, consumerPrefix = "consumer") +public class LinkedInComponent extends AbstractApiComponent<LinkedInApiName, LinkedInConfiguration, LinkedInApiCollection> { + + private static final Logger LOG = LoggerFactory.getLogger(LinkedInComponent.class); + + private LinkedInOAuthRequestFilter requestFilter; + + public LinkedInComponent() { + super(LinkedInEndpoint.class, LinkedInApiName.class, LinkedInApiCollection.getCollection()); + } + + public LinkedInComponent(CamelContext context) { + super(context, LinkedInEndpoint.class, LinkedInApiName.class, LinkedInApiCollection.getCollection()); + } + + @Override + protected LinkedInApiName getApiName(String apiNameStr) throws IllegalArgumentException { + return LinkedInApiName.fromValue(apiNameStr); + } + + @Override + protected Endpoint createEndpoint(String uri, String methodName, LinkedInApiName apiName, + LinkedInConfiguration endpointConfiguration) { + return new LinkedInEndpoint(uri, this, apiName, methodName, endpointConfiguration); + } + + public synchronized LinkedInOAuthRequestFilter getRequestFilter(LinkedInConfiguration endpointConfiguration) { + if (endpointConfiguration.equals(configuration)) { + if (requestFilter == null) { + requestFilter = createRequestFilter(this.configuration); + } + return requestFilter; + } else { + return createRequestFilter(endpointConfiguration); + } + } + + private static LinkedInOAuthRequestFilter createRequestFilter(LinkedInConfiguration configuration) { + // validate configuration + configuration.validate(); + + return new LinkedInOAuthRequestFilter(getOAuthParams(configuration), + configuration.getHttpParams(), configuration.isLazyAuth()); + } + + private static OAuthParams getOAuthParams(LinkedInConfiguration configuration) { + return new OAuthParams(configuration.getUserName(), configuration.getUserPassword(), + new CachingOAuthSecureStorage(configuration.getSecureStorage()), configuration.getClientId(), configuration.getClientSecret(), + configuration.getRedirectUri(), configuration.getScopes()); + } + + @Override + protected void doStop() throws Exception { + if (requestFilter != null) { + closeLogException(requestFilter); + } + } + + protected void closeRequestFilter(LinkedInOAuthRequestFilter requestFilter) { + // only close if not a shared filter + if (this.requestFilter != requestFilter) { + closeLogException(requestFilter); + } + } + + private void closeLogException(LinkedInOAuthRequestFilter requestFilter) { + try { + requestFilter.close(); + } catch (Exception e) { + LOG.warn("Error closing OAuth2 request filter: " + e.getMessage(), e); + } + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/b490a90c/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInConfiguration.java b/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInConfiguration.java new file mode 100644 index 0000000..8dd9fa1 --- /dev/null +++ b/components/camel-linkedin/camel-linkedin-component/src/main/java/org/apache/camel/component/linkedin/LinkedInConfiguration.java @@ -0,0 +1,155 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.linkedin; + +import java.util.Arrays; +import java.util.Map; + +import org.apache.camel.component.linkedin.api.OAuthScope; +import org.apache.camel.component.linkedin.api.OAuthSecureStorage; +import org.apache.camel.spi.UriParams; +import org.apache.camel.util.ObjectHelper; +import org.apache.commons.lang3.builder.HashCodeBuilder; + +/** + * Component configuration for LinkedIn component. + */ +@UriParams +public class LinkedInConfiguration { + + private String userName; + private String userPassword; + + private OAuthSecureStorage secureStorage; + + private String clientId; + private String clientSecret; + + private OAuthScope[] scopes; + private String redirectUri; + + + private Map<String, Object> httpParams; + + private boolean lazyAuth = true; + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getUserPassword() { + return userPassword; + } + + public void setUserPassword(String userPassword) { + this.userPassword = userPassword; + } + + public OAuthSecureStorage getSecureStorage() { + return secureStorage; + } + + public void setSecureStorage(OAuthSecureStorage secureStorage) { + this.secureStorage = secureStorage; + } + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getClientSecret() { + return clientSecret; + } + + public void setClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + } + + public OAuthScope[] getScopes() { + return scopes; + } + + public void setScopes(OAuthScope[] scopes) { + this.scopes = scopes; + } + + public String getRedirectUri() { + return redirectUri; + } + + public void setRedirectUri(String redirectUri) { + this.redirectUri = redirectUri; + } + + public Map<String, Object> getHttpParams() { + return httpParams; + } + + public void setHttpParams(Map<String, Object> httpParams) { + this.httpParams = httpParams; + } + + public boolean isLazyAuth() { + return lazyAuth; + } + + public void setLazyAuth(boolean lazyAuth) { + this.lazyAuth = lazyAuth; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof LinkedInConfiguration) { + final LinkedInConfiguration other = (LinkedInConfiguration) obj; + return (userName == null ? other.userName == null : userName.equals(other.userName)) + && (userPassword == null ? other.userPassword == null : userPassword.equals(other.userPassword)) + && secureStorage == other.secureStorage + && (clientId == null ? other.clientId == null : clientId.equals(other.clientId)) + && (clientSecret == null ? other.clientSecret == null : clientSecret.equals(other.clientSecret)) + && (redirectUri == null ? other.redirectUri == null : redirectUri.equals(other.redirectUri)) + && Arrays.equals(scopes, other.scopes) + && (httpParams == null ? other.httpParams == null : httpParams.equals(other.httpParams)) + && (lazyAuth == other.lazyAuth); + } + return false; + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(userName).append(userPassword).append(secureStorage) + .append(clientId).append(clientSecret) + .append(redirectUri).append(scopes).append(httpParams).append(lazyAuth).toHashCode(); + } + + public void validate() throws IllegalArgumentException { + ObjectHelper.notEmpty(userName, "userName"); + if (ObjectHelper.isEmpty(userPassword) && secureStorage == null) { + throw new IllegalArgumentException("Property userPassword or secureStorage is required"); + } + ObjectHelper.notEmpty(clientId, "clientId"); + ObjectHelper.notEmpty(clientSecret, "clientSecret"); + ObjectHelper.notEmpty(redirectUri, "redirectUri"); + } +}