forked from IQSS/dataverse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from IQSS/develop
test
- Loading branch information
Showing
17 changed files
with
457 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/main/java/edu/harvard/iq/dataverse/export/SchemaDotOrgExporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package edu.harvard.iq.dataverse.export; | ||
|
||
import com.google.auto.service.AutoService; | ||
import edu.harvard.iq.dataverse.DatasetVersion; | ||
import edu.harvard.iq.dataverse.export.spi.Exporter; | ||
import edu.harvard.iq.dataverse.util.BundleUtil; | ||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
import java.io.StringReader; | ||
import java.util.logging.Logger; | ||
import javax.json.Json; | ||
import javax.json.JsonObject; | ||
import javax.json.JsonReader; | ||
|
||
@AutoService(Exporter.class) | ||
public class SchemaDotOrgExporter implements Exporter { | ||
|
||
private static final Logger logger = Logger.getLogger(SchemaDotOrgExporter.class.getCanonicalName()); | ||
|
||
public static final String NAME = "schema.org"; | ||
|
||
@Override | ||
public void exportDataset(DatasetVersion version, JsonObject json, OutputStream outputStream) throws ExportException { | ||
String jsonLdAsString = version.getJsonLd(); | ||
StringReader stringReader = new StringReader(jsonLdAsString); | ||
JsonReader jsonReader = Json.createReader(stringReader); | ||
JsonObject jsonLdJsonObject = jsonReader.readObject(); | ||
try { | ||
outputStream.write(jsonLdJsonObject.toString().getBytes("UTF8")); | ||
} catch (IOException ex) { | ||
logger.info("IOException calling outputStream.write: " + ex); | ||
} | ||
try { | ||
outputStream.flush(); | ||
} catch (IOException ex) { | ||
logger.info("IOException calling outputStream.flush: " + ex); | ||
} | ||
} | ||
|
||
@Override | ||
public String getProviderName() { | ||
return NAME; | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return BundleUtil.getStringFromBundle("dataset.exportBtn.itemLabel.schemaDotOrg"); | ||
} | ||
|
||
@Override | ||
public Boolean isXMLFormat() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public Boolean isHarvestable() { | ||
// Defer harvesting because the current effort was estimated as a "2": https://github.com/IQSS/dataverse/issues/3700 | ||
return false; | ||
} | ||
|
||
@Override | ||
public Boolean isAvailableToUsers() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getXMLNameSpace() throws ExportException { | ||
throw new ExportException(SchemaDotOrgExporter.class.getSimpleName() + ": not an XML format."); | ||
} | ||
|
||
@Override | ||
public String getXMLSchemaLocation() throws ExportException { | ||
throw new ExportException(SchemaDotOrgExporter.class.getSimpleName() + ": not an XML format."); | ||
} | ||
|
||
@Override | ||
public String getXMLSchemaVersion() throws ExportException { | ||
throw new ExportException(SchemaDotOrgExporter.class.getSimpleName() + ": not an XML format."); | ||
} | ||
|
||
@Override | ||
public void setParam(String name, Object value) { | ||
// this exporter doesn't need/doesn't currently take any parameters | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.