View Javadoc
1   /*
2    * This file is part of ***  M y C o R e  ***
3    * See http://www.mycore.de/ for details.
4    *
5    * MyCoRe is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    *
10   * MyCoRe is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with MyCoRe.  If not, see <http://www.gnu.org/licenses/>.
17   */
18  
19  package org.mycore.orcid;
20  
21  import java.io.IOException;
22  
23  import org.jdom2.JDOMException;
24  import org.mycore.orcid.works.MCRWorksFetcher;
25  import org.mycore.orcid.works.MCRWorksPublisher;
26  import org.mycore.orcid.works.MCRWorksSection;
27  import org.xml.sax.SAXException;
28  
29  import jakarta.ws.rs.client.WebTarget;
30  
31  /**
32   * Represents the profile of a given ORCID ID.
33   *
34   * @author Frank L\u00FCtzenkirchen
35   */
36  public class MCRORCIDProfile {
37  
38      private String orcid;
39  
40      /** The base target of the REST api for this ORCID profile */
41      private WebTarget target;
42  
43      private MCRWorksSection worksSection;
44  
45      private MCRWorksPublisher publisher = new MCRWorksPublisher(this);
46  
47      private MCRWorksFetcher fetcher = new MCRWorksFetcher(this);
48  
49      /** The access token required to modify entries in this ORCID profile */
50      private String accessToken;
51  
52      public MCRORCIDProfile(String orcid) {
53          this.orcid = orcid;
54          this.target = MCRORCIDClient.instance().getBaseTarget().path(orcid);
55      }
56  
57      public String getORCID() {
58          return orcid;
59      }
60  
61      public MCRWorksPublisher getPublisher() {
62          return publisher;
63      }
64  
65      public MCRWorksFetcher getFetcher() {
66          return fetcher;
67      }
68  
69      /** Returns the base web target of the REST API for this ORCID profile */
70      public WebTarget getWebTarget() {
71          return target;
72      }
73  
74      /** Sets the access token required to modify entries in this ORCID profile */
75      public void setAccessToken(String token) {
76          this.accessToken = token;
77      }
78  
79      /** Returns the access token required to modify entries in this ORCID profile */
80      public String getAccessToken() {
81          return accessToken;
82      }
83  
84      /** Returns the "works" section of the ORCID profile, which holds the publication data */
85      public synchronized MCRWorksSection getWorksSection() throws JDOMException, IOException, SAXException {
86          if (worksSection == null) {
87              worksSection = new MCRWorksSection(this);
88          }
89          return worksSection;
90      }
91  }