Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#550 Submit publications to HISinOne #551

Draft
wants to merge 129 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
e22e224
#550 Added class PublicationHisResTransformer and configured transfor…
Possommi Feb 20, 2024
416948e
#550 Map languages and extent
Possommi Jun 12, 2024
1e3e04a
#550 Added template stub mycoreobject-mods-resolve-his-keys.xsl and d…
Possommi Jun 12, 2024
1c759f1
#550 Created new package .his and moved related class files to it
Possommi Jun 12, 2024
de146dd
#550 Added HISInOneClient
Possommi Jun 12, 2024
1d04c86
#550 Removed setter methods from Token and LanguageValue
Possommi Jun 13, 2024
2187ecd
#550 Added class PublicationTypeValue
Possommi Jun 13, 2024
206a12a
#550 Map ubo genre to his:publicationType (defaults to 'Sonstiger Pub…
Possommi Jun 13, 2024
0c8fe9b
#550 Map publication state, introduced abstract CommonType
Possommi Jun 13, 2024
b47491a
#550 Added class VisibilityValue
Possommi Jun 14, 2024
a8c0607
#550 Add his/res status value as mods:classification
Possommi Jun 14, 2024
a28865f
#550 Add his/res visibilityValue value as mods:classification
Possommi Jun 14, 2024
026947b
#550 Moved HISInOneClient related classes to de.uni_jena.thunibib.his…
Possommi Jun 14, 2024
222e1a6
#550 Added publicationCreatorType
Possommi Jun 14, 2024
78e2ae6
#550 Cache fetched ids
Possommi Jun 14, 2024
1ddcd38
#550 Added mapping of fachreferate/destatis with SubjectAreaValue
Possommi Jun 14, 2024
6f67711
#550 Simplified mapping of fachreferate/destatis with SubjectAreaValue
Possommi Jun 14, 2024
740a1c0
#550 Map subjectAreas from origin as well
Possommi Jun 14, 2024
5e0dc54
#550 Refactored mycoreobject-mods-resolve-his-keys.xsl
Possommi Jun 17, 2024
0c89dba
#550 Added researchAreaKdsfValue.xml
Possommi Jun 17, 2024
3306bfe
#550 Updated researchAreaKdsf.xml, added description and x-uri label
Possommi Jun 17, 2024
56edc0a
#550 Included sample input field for research areas (KDSF) with defau…
Possommi Jun 17, 2024
4e0c2c0
#550 Map researchArea in mycoreobject-mods-resolve-his-keys.xsl to de…
Possommi Jun 17, 2024
aec6d2d
#550 Map qualificationThesisValue
Possommi Jun 17, 2024
8fddf4a
#550 Short values in contains() in PublicationHisResTransformer
Possommi Jun 17, 2024
bcf94c7
#550 Let HISinOneResolver produce SysValue rather than int values
Possommi Jun 17, 2024
225f4c2
#550 Map to monograph as default publication type
Possommi Jun 17, 2024
b0f926e
#550 Map documentType, defaults to Monograph
Possommi Jun 18, 2024
0b607e1
#550 Map globalIdentifiers
Possommi Jun 18, 2024
218ddf7
#550 Added class de.uni_jena.thunibib.HISinOneCommands
Possommi Jun 18, 2024
f96c32f
#550 Updated categ ids in researchAreaKdsf.xml
Possommi Jun 18, 2024
277fca8
#550 Resolve researchAreaKdsfValue
Possommi Jun 18, 2024
9df6a44
#550 Added EmptySysValue
Possommi Jun 18, 2024
5e97ad7
#550 Added static public String getPath() to classes extending SysValue
Possommi Jun 18, 2024
0475620
#550 Added javadoc to HISinOneResolver#resolveIdentifierType
Possommi Jun 18, 2024
c1825c2
#550 Added class PublicationAccessTypeValue and uri related uri part
Possommi Jun 19, 2024
b20d9b6
#550 Write publicationAccessTypeValue to json
Possommi Jun 19, 2024
bc01bdb
#550 Write xml comments
Possommi Jun 19, 2024
6aea39b
#550 Do not die on error when fetching token
Possommi Jun 19, 2024
7ba0702
#550 Map peer review, let SysValue and LanguageValue implement interf…
Possommi Jun 19, 2024
9ebae30
#550 Added javadocs to HISinOneResolver#resolvePeerReviewedType
Possommi Jun 19, 2024
cfaac2e
#550 Code format
Possommi Jun 19, 2024
47d5d1b
#550 Map keywords in PublicationHisResTransformer
Possommi Jun 20, 2024
587f95a
#550 Map keywords in PublicationHisResTransformer, added Override ann…
Possommi Jun 20, 2024
8c9a280
#550 Fixed mapping of mods:extent
Possommi Jun 20, 2024
698fcda
#550 Adopted all xpath to not to be applied to elements being a child…
Possommi Jun 20, 2024
611428a
#550 Allow parameters in interface HISInOneClient
Possommi Jul 16, 2024
2d3d343
#550 Resolve publisher
Possommi Jul 16, 2024
1ee80a0
#550 Added xsl stub for creating missing entities in HISinOne. Added …
Possommi Jul 16, 2024
4926bd9
#550 Added resolve and create mode to HISinOneResolver
Possommi Jul 16, 2024
30011ef
#550 Create Publisher in HISinOne
Possommi Jul 17, 2024
09b2864
#550 Updated javadoc for class HISinOneResolver
Possommi Jul 17, 2024
ab93b1d
#550 Added comments to ubogenre.xml express mapping of ubogenre to HI…
Possommi Jul 17, 2024
8cee94a
#550 Changed enum value genre to publicationType
Possommi Jul 17, 2024
1a1e456
#550 Added class stub PublicationAndDocTypeMapper
Possommi Jul 17, 2024
79faae8
#550 Provided default publication type mapping in ubogenre.xml
Possommi Jul 18, 2024
1e4fce9
#550 Map document type.
Possommi Jul 18, 2024
8e3f943
#550 Map book
Possommi Jul 18, 2024
cf5ff1f
#550 Added mapping for thesis types, distinguish between mapping for …
Possommi Jul 18, 2024
d6a05b4
#550 Updated javadoc in PublicationAndDocTypeMapper
Possommi Jul 18, 2024
063ec19
#550 Updated maven-pr.yml
Possommi Jul 18, 2024
672fc73
#550 Added mappings as provided in FSU-Cloud
Possommi Jul 18, 2024
a376716
#550 Simplified logging in PublicationAndDocTypeMapper
Possommi Jul 18, 2024
24651af
#550 Read possible document types from both /article and /book endpoint
Possommi Jul 18, 2024
e8545d4
#550 Added javadoc to HISinOneResolver
Possommi Jul 18, 2024
6176dad
#550 Removed duplicates from documentType list
Possommi Jul 18, 2024
12d48a5
#550 Generate test creator
Possommi Jul 19, 2024
972c914
#550 Fixed mapping of peer reviewed
Possommi Jul 19, 2024
0992cdf
#550 Implemented command for publishing document at HISinOne/RES
Possommi Jul 19, 2024
2e10eea
#580 Do not publish document twice in command "publish {0}"
Possommi Jul 19, 2024
ef27293
#580 Added class HISInOneServiceFlag
Possommi Jul 19, 2024
4cfe7ba
#580 Add id and lockVersion fields to json
Possommi Jul 19, 2024
730747c
#580 Allow to update publication in HISinOne/RES
Possommi Jul 19, 2024
3bf7956
#550 Added PublicationResourceValue
Possommi Jul 22, 2024
9d4901e
#550 Added mapping in typeOfResource.xml
Possommi Jul 22, 2024
2e0d47b
#550 Map publicationResourceValue in PublicationHisResTransformer
Possommi Jul 22, 2024
2b6cbf7
#550 Let LanguageValue extent SysValue
Possommi Jul 22, 2024
d60f3c2
#550 Introduced uri part support for specifying a desired field to re…
Possommi Jul 22, 2024
89afa2b
#550 Removed interface HisValue from source
Possommi Jul 22, 2024
4eab84a
#550 Map //mods:mods/mods:part/mods:detail[@type='volume']/mods:number
Possommi Jul 22, 2024
ccb6a3f
#550 Fixed compile error (do not catch not thrown SAXException)
Possommi Aug 26, 2024
38455e9
#550 Fixed includes of stylesheets
Possommi Aug 26, 2024
80a35d6
#550 Do not die on unresolvable language
Possommi Aug 26, 2024
5051cd3
#550 Updated ubogenre.xml
Possommi Aug 27, 2024
7e69b42
#550 Add repository id, decode value in HISinOneResolver
Possommi Aug 27, 2024
d7a378e
#550 Improved removing of any unresolved values
Possommi Aug 27, 2024
b98b17d
#550 Check for id > 0 after publishing to HISinOne
Possommi Aug 27, 2024
eb62b5b
#550 Always provide value for peer reviewed (defaults to 'keine Angabe')
Possommi Aug 28, 2024
b57ddeb
#550 Added method addId() for testing
Possommi Aug 28, 2024
37706aa
#550 Resolve relatedItem of type Journal
Possommi Aug 28, 2024
f50b6bd
#550 HISinOne treats journals and newspaper the same way
Possommi Aug 28, 2024
6cea696
#550 Add stub for creating journals in HISinOne
Possommi Aug 28, 2024
e7cf498
#550 Let PublicationAndDocTypeMapper return null rather than throw an…
Possommi Aug 29, 2024
93a1000
#550 Added JournalHisResTransformer
Possommi Aug 29, 2024
f2a8c9f
#550 Create journals at HISinOne
Possommi Aug 29, 2024
a3f51d0
#550 Check for status in HISinOneCommands#update
Possommi Aug 29, 2024
ab2a44f
#550 Check for genre in PublicationHisResTransformer
Possommi Aug 29, 2024
1763460
#550 Fixed determination of lockversion in mycoreobject-mods-resolve-…
Possommi Aug 29, 2024
04a0dc2
#550 Add lockversion and id to JSON output in JournalHisResTransformer
Possommi Aug 29, 2024
29dc1ee
#550 Added Class HISinOneCommandConfiguration
Possommi Aug 29, 2024
a34b2da
#550 Unified resolving of lockVersion
Possommi Aug 30, 2024
84ef424
#550 Improved resolving of host
Possommi Sep 2, 2024
8042ff2
#550 Unified creation of journals and arbitrary parent objects
Possommi Sep 2, 2024
4f02132
#550 Log api errors from HISinOne to error log
Possommi Sep 2, 2024
36c16f5
#550 Refactored HISinOneCommands
Possommi Sep 3, 2024
029e2a1
#550 Refactored HISinOneResolver
Possommi Sep 3, 2024
9ea745f
#550 Fetch project data from HISinOne
Possommi Sep 4, 2024
c44480e
#550 Include project data in JSON sent to HISinOne
Possommi Sep 5, 2024
1c488d5
#550 Added additional transformer configuration 'mods-resolve-his-key…
Possommi Sep 9, 2024
270943e
#550 Added Response post(String path, String body, Map<String, String…
Possommi Sep 9, 2024
af4162f
#550 Added resolving of PersonIdentifiers
Possommi Sep 9, 2024
da26547
#550 Removed default case
Possommi Sep 9, 2024
2206127
#550 Avoid reading from possible closed response
Possommi Sep 10, 2024
25335ab
#550 Made type of HISinOne servflag configurable
Possommi Sep 10, 2024
4121214
#550 Unified logging of errors
Possommi Sep 10, 2024
a6195f4
#550 Improved logging when publishing or updating
Possommi Sep 10, 2024
527444f
#550 Fixed line break in messages_en.properties
Possommi Sep 10, 2024
7e94f8c
#550 Do not omit token in requests in HISinOneProjectsResource to ret…
Possommi Sep 10, 2024
925821e
#550 Removed unused field in HISInOneClientDefaultImpl
Possommi Sep 10, 2024
05dc4aa
#550 Added @JsonIgnoreProperties(ignoreUnknown = true) to Token
Possommi Sep 10, 2024
9783266
#550 Check return code of respone in HISinOneProjectsResource. Trunca…
Possommi Sep 10, 2024
16e578c
#550 Changed label format in project autocomplete
Possommi Sep 10, 2024
32536a8
#550 Provide placeholder text in project search input element
Possommi Sep 10, 2024
ade1b48
#550 Added label thunibib.editor.hisinone.id
Possommi Sep 11, 2024
9948e66
#550 Added personId field to PersonIdentifier and updated javadoc
Possommi Sep 30, 2024
2e86c8c
#550 Refactored getFieldValue(...) in HISinOneResolver
Possommi Sep 30, 2024
5e33401
#550 Updated addCreators(...)
Possommi Sep 30, 2024
9e5de0b
#550 Do not rely on exceptions for flow control in HISinOneResolver#g…
Possommi Sep 30, 2024
d193e9c
#550 Updated resolving of destatis/subjectArea (reflect migration of …
Possommi Nov 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/maven-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Build with Maven
run: mvn -B package --file pom.xml
run: mvn -B package -Dmaven.javadoc.skip=true --file pom.xml
24 changes: 24 additions & 0 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
<name>ThUniBib Common Files</name>

<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
Expand All @@ -20,6 +32,18 @@
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-sse</artifactId>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
</dependency>
<dependency>
<groupId>org.mycore</groupId>
<artifactId>mycore-base</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package de.uni_jena.thunibib;

import de.uni_jena.thunibib.his.api.v1.cs.sys.values.SysValue;
import de.uni_jena.thunibib.his.api.v1.fs.res.publication.Journal;
import de.uni_jena.thunibib.his.api.v1.fs.res.publication.Publication;
import org.jdom2.filter.Filters;
import org.mycore.common.config.MCRConfiguration2;
import org.mycore.datamodel.metadata.MCRObject;

import static org.mycore.common.MCRConstants.MODS_NAMESPACE;
import static org.mycore.common.MCRConstants.XPATH_FACTORY;

/**
* Class can be used to determine and store configuration values for publishing and updating publications in HISinOne.
*
* @author shermann (Silvio Hermann)
*/
class HISinOneCommandConfiguration {
static final String PUBLICATION_TRANSFORMER = MCRConfiguration2.getStringOrThrow(
"ThUniBib.HISinOne.Publication.Transformer.Name");

static final String JOURNAL_TRANSFORMER = MCRConfiguration2.getStringOrThrow(
"ThUniBib.HISinOne.Journal.Transformer.Name");

final private boolean isJournal;

public HISinOneCommandConfiguration(MCRObject obj) {
isJournal = XPATH_FACTORY.compile(
"//mods:mods/mods:genre[@type='intern'][contains('journal newspaper', substring-after(@valueURI, '#'))]",
Filters.element(), null, MODS_NAMESPACE)
.evaluateFirst(obj.createXML()) != null;
}

/**
* Determines the name of the required transformer for building the JSON object.
* */
public String getTransformerName() {
if (isJournal) {
return JOURNAL_TRANSFORMER;
}
return PUBLICATION_TRANSFORMER;
}

/**
* Determines the path for posting the JSON to.
* */
public String getPath() {
if (isJournal) {
return Journal.getPath();
}
return Publication.getPath();
}

/**
* Determines the class to read the response to.
* */
public Class<? extends SysValue> getResponseEntityClass() {
if (isJournal) {
return Journal.class;
}
return Publication.class;
}
}
147 changes: 147 additions & 0 deletions common/src/main/java/de/uni_jena/thunibib/HISinOneCommands.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
package de.uni_jena.thunibib;

import de.uni_jena.thunibib.his.api.client.HISInOneClient;
import de.uni_jena.thunibib.his.api.client.HISinOneClientFactory;
import de.uni_jena.thunibib.his.api.v1.cs.sys.values.SysValue;
import de.uni_jena.thunibib.his.xml.HISInOneServiceFlag;
import jakarta.ws.rs.core.Response;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mycore.access.MCRAccessException;
import org.mycore.datamodel.metadata.MCRMetadataManager;
import org.mycore.datamodel.metadata.MCRObject;
import org.mycore.datamodel.metadata.MCRObjectID;
import org.mycore.frontend.cli.annotation.MCRCommand;
import org.mycore.frontend.cli.annotation.MCRCommandGroup;

import java.io.IOException;
import java.util.Optional;

import static de.uni_jena.thunibib.his.api.client.HISInOneClient.HIS_IN_ONE_BASE_URL;

@MCRCommandGroup(name = "HISinOne Commands")
public class HISinOneCommands {
private static final Logger LOGGER = LogManager.getLogger(HISinOneCommands.class);

@MCRCommand(syntax = "publish {0}", help = "Publishes the object given by its id to HISinOne")
public static SysValue publish(String mcrid) {
LOGGER.info("Publishing {}", mcrid);

Optional<SysValue> sysVal = isValid(mcrid);
if (sysVal.isPresent()) {
return sysVal.get();
}

MCRObject mcrObject = MCRMetadataManager.retrieveMCRObject(MCRObjectID.getInstance(mcrid));
if (mcrObject.getService().getFlags(HISInOneServiceFlag.getName()).size() > 0) {
LOGGER.warn("{} is already published. Try command 'update {0}' instead?", mcrid);
return SysValue.ErroneousSysValue;
}

HISinOneCommandConfiguration conf = new HISinOneCommandConfiguration(mcrObject);

try {
String json = Utilities.transform(mcrObject, conf.getTransformerName());
LOGGER.debug("JSON: {}", json);

try (HISInOneClient client = HISinOneClientFactory.create();
Response response = client.post(conf.getPath(), json)) {

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
LOGGER.error("{}: {}", conf.getPath(), response.readEntity(String.class));
return SysValue.ErroneousSysValue;
}

SysValue publication = response.readEntity(conf.getResponseEntityClass());
if (publication.getId() == 0) {
LOGGER.error("MCRObject {} was not published at {} with id {}", mcrid,
HIS_IN_ONE_BASE_URL + conf.getPath(), publication.getId());
return SysValue.ErroneousSysValue;
}

LOGGER.info("MCRObject {} published at {} with id {}", mcrid, HIS_IN_ONE_BASE_URL + conf.getPath(),
publication.getId());

// Update MCRObject
mcrObject.getService().addFlag(HISInOneServiceFlag.getName(), String.valueOf(publication.getId()));
MCRMetadataManager.update(mcrObject);

return publication;
}
} catch (IOException | MCRAccessException e) {
LOGGER.error("Could not publish {} to {}", mcrid, HIS_IN_ONE_BASE_URL, e);
}

return SysValue.UnresolvedSysValue;
}

@MCRCommand(syntax = "update {0}", help = "Updates the object given by its id in HISinOne")
public static SysValue update(String mcrid) {
LOGGER.info("Updating {}", mcrid);
Optional<SysValue> sysVal = isValid(mcrid);
if (sysVal.isPresent()) {
return sysVal.get();
}

MCRObject mcrObject = MCRMetadataManager.retrieveMCRObject(MCRObjectID.getInstance(mcrid));
if (mcrObject.getService().getFlags(HISInOneServiceFlag.getName()).size() == 0) {
LOGGER.warn("{} is not published. Try command 'publish {0}' first", mcrid);
return SysValue.ErroneousSysValue;
}

HISinOneCommandConfiguration conf = new HISinOneCommandConfiguration(mcrObject);
try {
String hisId = mcrObject.getService().getFlags(HISInOneServiceFlag.getName()).get(0);
String json = Utilities.transform(mcrObject, conf.getTransformerName());

try (HISInOneClient client = HISinOneClientFactory.create();
Response response = client.put(conf.getPath() + "/" + hisId, json)) {

if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
LOGGER.error("{}: {}", conf.getPath(), response.readEntity(String.class));
return SysValue.ErroneousSysValue;
}

SysValue p = response.readEntity(conf.getResponseEntityClass());
if (p.getId() == 0) {
LOGGER.error("MCRObject {} was not updated at {} with id {}", mcrid,
HIS_IN_ONE_BASE_URL + conf.getPath(), p.getId());
return SysValue.ErroneousSysValue;
}
LOGGER.info("MCRObject {} updated at {} with id {} and new lockVersion {}", mcrid,
HIS_IN_ONE_BASE_URL + conf.getPath(), hisId, p.getLockVersion());
return p;
}
} catch (IOException e) {
LOGGER.error("Could not update {} to {}", mcrid, HIS_IN_ONE_BASE_URL, e);
}
return SysValue.ErroneousSysValue;
}

@MCRCommand(syntax = "delete {0}", help = "Deletes the object given by its id from HISinOne")
public static void delete(String mcrid) {
LOGGER.info("Deleting {}", mcrid);
}

/**
* Checks if the provided mcr id is valid and the related mycoreobject actually exists.
*
* @param mcrid the id of the mycoreobject
*
* @return either an empty {@link Optional} or an {@link Optional} wrapping a {@link SysValue}
*/
protected final static Optional<SysValue> isValid(String mcrid) {
if (!MCRObjectID.isValid(mcrid)) {
LOGGER.error("{} is not a valid {}", mcrid, MCRObjectID.class.getSimpleName());
return Optional.of(SysValue.ErroneousSysValue);
}

MCRObjectID mcrObjectID = MCRObjectID.getInstance(mcrid);
if (!MCRMetadataManager.exists(mcrObjectID)) {
LOGGER.error("{} does not exist", mcrid);
return Optional.of(SysValue.UnresolvedSysValue);
}

return Optional.empty();
}
}
23 changes: 23 additions & 0 deletions common/src/main/java/de/uni_jena/thunibib/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,25 @@
import jakarta.persistence.criteria.SetJoin;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jdom2.Document;
import org.mycore.backend.jpa.MCREntityManagerProvider;
import org.mycore.common.config.MCRConfiguration2;
import org.mycore.common.content.MCRContent;
import org.mycore.common.content.MCRJDOMContent;
import org.mycore.common.content.transformer.MCRContentTransformer;
import org.mycore.common.content.transformer.MCRContentTransformerFactory;
import org.mycore.datamodel.classifications2.MCRCategory;
import org.mycore.datamodel.classifications2.MCRCategoryDAO;
import org.mycore.datamodel.classifications2.MCRCategoryDAOFactory;
import org.mycore.datamodel.classifications2.MCRCategoryID;
import org.mycore.datamodel.classifications2.MCRLabel;
import org.mycore.datamodel.metadata.MCRObject;
import org.mycore.user2.MCRUser;
import org.mycore.user2.MCRUserAttribute;
import org.mycore.user2.MCRUserAttribute_;
import org.mycore.user2.MCRUser_;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
Expand All @@ -39,6 +46,22 @@ public static String toLowerCase(String s) {
return s.toLowerCase(Locale.ROOT);
}

/**
* Transforms a given {@link MCRObject} to JSON suitable for HISinOne/RES.
*
* @param mcrObject the object to transform
* @param transformerName the name of the transformer to user
*
* @return a {@link String} as transformation result
* */
public static String transform(MCRObject mcrObject, String transformerName) throws IOException {
Document mods = mcrObject.createXML();
MCRContentTransformer transformer = MCRContentTransformerFactory.getTransformer(transformerName);
MCRContent transformed = transformer.transform(new MCRJDOMContent(mods));

return transformed.asString();
}

/**
* Gets the lead for a given other name identifier for a MCRUser.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package de.uni_jena.thunibib.his.api.client;

import jakarta.ws.rs.core.Response;
import org.mycore.common.config.MCRConfiguration2;
import org.mycore.common.events.MCRShutdownHandler;

import java.util.Map;

public interface HISInOneClient extends MCRShutdownHandler.Closeable, AutoCloseable {

String HIS_IN_ONE_BASE_URL = MCRConfiguration2.getStringOrThrow("ThUniBib.HISinOne.BaseURL");
String API_PATH = MCRConfiguration2.getStringOrThrow("ThUniBib.HISinOne.BaseURL.API.Path");

enum AuthType {
Basic, Bearer
}

default Response get(String path) {
return get(path, false);
}

default Response get(String path, Map<String, String> params) {
return get(path, params, false);
}

default Response get(String path, boolean omitToken) {
return get(path, null, omitToken);
}

default Response post(String path, String body) {
return post(path, body, null);
}

Response get(String path, Map<String, String> params, boolean omitToken);

Response post(String path, String body, Map<String, String> params);

Response put(String path, String body);
}
Loading
Loading