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

RSDEV-271: Integration with Digital Commons Data #66

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1951,6 +1951,25 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.rspace-os</groupId>
<artifactId>rspace-digital-commons-data-adapter</artifactId>
<version>0.0.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>com.github.rspace-os</groupId>
<artifactId>repository-spi</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.rspace-os</groupId>
<artifactId>protocols-java-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,5 +269,7 @@ public interface IPropertyHolder extends Versionable {

String getZenodoApiUrl();

String getDigitalCommonsDataApiUrl();

boolean isAsposeEnabled();
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ public class PropertyHolder implements IMutablePropertyHolder {
@Value("${zenodo.url}")
private String zenodoApiUrl;

@Value("${dcd.api.base.url}")
private String digitalCommonsDataApiUrl;

@Value("${aspose.enabled:true}")
private String asposeEnabled;

Expand Down Expand Up @@ -318,6 +321,11 @@ public String getZenodoApiUrl() {
return this.zenodoApiUrl;
}

@Override
public String getDigitalCommonsDataApiUrl() {
return this.digitalCommonsDataApiUrl;
}

public Integer getMinUsernameLength() {
return minUsernameLength;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ public interface IntegrationsHandler {
String PROTOCOLS_IO_APP_NAME = "PROTOCOLS_IO";
String PYRAT_APP_NAME = "PYRAT";
String DMPTOOL_APP_NAME = "DMPTOOL";
String DIGITAL_COMMONS_DATA_APP_NAME = "DIGITAL_COMMONS_DATA";
String CLUSTERMARKET_APP_NAME = "CLUSTERMARKET";
String OMERO_APP_NAME = "OMERO";
String JOVE_APP_NAME = "JOVE";
String DRYAD_APP_NAME = "DRYAD";
String ARGOS_APP_NAME = "ARGOS";
String ZENODO_APP_NAME = "ZENODO";
String DMPONLINE_APP_NAME = "DMPONLINE";

String PYRAT_USER_TOKEN = "PYRAT_USER_TOKEN";
String ZENODO_USER_TOKEN = "ZENODO_USER_TOKEN";
String DIGITAL_COMMONS_DATA_USER_TOKEN = "DIGITAL_COMMONS_DATA_USER_TOKEN";
String EGNYTE_DOMAIN_SETTING = "EGNYTE_DOMAIN";
String ACCESS_TOKEN_SETTING = "ACCESS_TOKEN";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ void postProcessInfo(IntegrationInfo info, User user) {
case ZENODO_APP_NAME:
setSingleUserToken(info, user, ZENODO_APP_NAME, ZENODO_USER_TOKEN);
return;
case DIGITAL_COMMONS_DATA_APP_NAME:
setSingleUserToken(
info, user, DIGITAL_COMMONS_DATA_APP_NAME, DIGITAL_COMMONS_DATA_USER_TOKEN);
return;
default:
}
}
Expand Down Expand Up @@ -319,6 +323,11 @@ private void saveConfigOptionsForAppsWithSingleOptionSet(User user, IntegrationI
} else if (ZENODO_APP_NAME.equals(newInfo.getName())) {
saveNewUserConnectionForSingleOptionApp(
newInfo.getOptions().get(ZENODO_USER_TOKEN).toString(), user, ZENODO_APP_NAME);
} else if (DIGITAL_COMMONS_DATA_APP_NAME.equals(newInfo.getName())) {
saveNewUserConnectionForSingleOptionApp(
newInfo.getOptions().get(DIGITAL_COMMONS_DATA_USER_TOKEN).toString(),
user,
DIGITAL_COMMONS_DATA_APP_NAME);
} else if (JOVE_APP_NAME.equals(newInfo.getName())) {
/**
* Jove doesnt currently fit well into our existing integration handler, so we just get the
Expand Down Expand Up @@ -418,6 +427,7 @@ private boolean isSingleOptionSetAppConfigIntegration(String integrationName) {
case PYRAT_APP_NAME:
case JOVE_APP_NAME:
case DMPONLINE_APP_NAME:
case DIGITAL_COMMONS_DATA_APP_NAME:
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.researchspace.service.UserAppConfigManager;
import com.researchspace.service.UserConnectionManager;
import com.researchspace.service.UserManager;
import com.researchspace.webapp.controller.repositories.DigitalCommonsDataUIConnectionConfig;
import com.researchspace.webapp.controller.repositories.DryadUIConnectionConfig;
import com.researchspace.webapp.controller.repositories.FigshareUIConnectionConfig;
import com.researchspace.webapp.controller.repositories.RSDataverseConnectionConfig;
Expand Down Expand Up @@ -131,6 +132,10 @@ private RepositoryConfig getRepoConnectionInfo(
ZenodoUIConnectionConfig zenodoUIConnectionConfig =
new ZenodoUIConnectionConfig(userConnectionManager, subject, this.propertyHolder);
repoCfg = repoCfgFactory.createRepositoryConfigFromAppCfg(zenodoUIConnectionConfig, subject);
} else if (app.getName().equalsIgnoreCase(App.APP_DIGITAL_COMMONS_DATA)) {
DigitalCommonsDataUIConnectionConfig dcdUIConnectionConfig =
new DigitalCommonsDataUIConnectionConfig(userConnectionManager, subject, this.propertyHolder);
repoCfg = repoCfgFactory.createRepositoryConfigFromAppCfg(dcdUIConnectionConfig, subject);
} else {
throw new IllegalArgumentException("Unknown or unconfigured repository: " + app.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static com.researchspace.service.IntegrationsHandler.ARGOS_APP_NAME;
import static com.researchspace.service.IntegrationsHandler.CLUSTERMARKET_APP_NAME;
import static com.researchspace.service.IntegrationsHandler.DATAVERSE_APP_NAME;
import static com.researchspace.service.IntegrationsHandler.DIGITAL_COMMONS_DATA_APP_NAME;
import static com.researchspace.service.IntegrationsHandler.DMPONLINE_APP_NAME;
import static com.researchspace.service.IntegrationsHandler.DMPTOOL_APP_NAME;
import static com.researchspace.service.IntegrationsHandler.DRYAD_APP_NAME;
Expand Down Expand Up @@ -138,6 +139,9 @@ private Map<String, IntegrationInfo> getAll(User user) {
rc.put(ARGOS_APP_NAME, integrationsHandler.getIntegration(user, ARGOS_APP_NAME));
rc.put(ZENODO_APP_NAME, integrationsHandler.getIntegration(user, ZENODO_APP_NAME));
rc.put(OMERO_APP_NAME, integrationsHandler.getIntegration(user, OMERO_APP_NAME));
rc.put(
DIGITAL_COMMONS_DATA_APP_NAME,
integrationsHandler.getIntegration(user, DIGITAL_COMMONS_DATA_APP_NAME));
return rc;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.researchspace.webapp.controller.repositories;

import static com.researchspace.service.IntegrationsHandler.DIGITAL_COMMONS_DATA_APP_NAME;

import com.researchspace.model.User;
import com.researchspace.properties.IPropertyHolder;
import com.researchspace.service.UserConnectionManager;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Optional;

public class DigitalCommonsDataUIConnectionConfig implements RSpaceRepoConnectionConfig {

private User subject;
private UserConnectionManager source;
private IPropertyHolder propertyHolder;

public DigitalCommonsDataUIConnectionConfig(
UserConnectionManager source, User subject, IPropertyHolder propertyHolder) {
this.subject = subject;
this.source = source;
this.propertyHolder = propertyHolder;
}

@Override
public Optional<URL> getRepositoryURL() throws MalformedURLException {
try {
return Optional.of(new URL(this.propertyHolder.getDigitalCommonsDataApiUrl()));
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Couldn't create Digital Commons Data repositoryURL " + e.getMessage());
}
}

@Override
public String getApiKey() {
return source
.findByUserNameProviderName(subject.getUsername(), DIGITAL_COMMONS_DATA_APP_NAME)
.orElseThrow(
() -> new IllegalArgumentException("No UserConnection exists for: " + DIGITAL_COMMONS_DATA_APP_NAME))
.getAccessToken();
}
}
Loading
Loading