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

Minor change to enable calling apps to be aware of exceptions #523

Closed
wants to merge 11 commits into from
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Java CI

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8, 11 ]

steps:
- uses: actions/checkout@v2

- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}

- name: Restore dependency cache
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-${{ matrix.java }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-${{ matrix.java }}-m2

- name: Run tests
run: mvn --batch-mode --update-snapshots verify

- name: Submit test coverage to Coveralls
run: mvn jacoco:report coveralls:report -DrepoToken=${{ secrets.COVERALLS_TOKEN }} -DpullRequest=${{ github.event.number }} -DserviceBuildNumber=${{ env.GITHUB_RUN_ID }}
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Wikidata Toolkit
================

[![Build Status](https://travis-ci.org/Wikidata/Wikidata-Toolkit.png?branch=master)](https://travis-ci.org/Wikidata/Wikidata-Toolkit)
![Build status](https://github.com/Wikidata/Wikidata-Toolkit/workflows/Java%20CI/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/Wikidata/Wikidata-Toolkit/badge.svg?branch=master)](https://coveralls.io/github/Wikidata/Wikidata-Toolkit?branch=master)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.wikidata.wdtk/wdtk-parent/badge.svg)](http://search.maven.org/#search|ga|1|g%3A%22org.wikidata.wdtk%22)
[![Project Stats](https://www.openhub.net/p/Wikidata-Toolkit/widgets/project_thin_badge.gif)](https://www.openhub.net/p/Wikidata-Toolkit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ public static LexemeDocument makeLexemeDocument(LexemeIdValue lexemeIdValue,
* Creates a {@link FormDocument}.
*
* If you plan to add this form to a specific lexeme,
* it might be easier to use {@link LexemeDocument#createForm}.
* it might be easier to use {@link LexemeDocument#createForm(List)}.
*
* @param formIdValue
* the id of the form that data is about
Expand All @@ -914,7 +914,7 @@ public static FormDocument makeFormDocument(FormIdValue formIdValue,
* Creates a {@link SenseDocument}.
*
* If you plan to add this sense to a specific lexeme,
* it might be easier to use {@link LexemeDocument#createSense)}.
* it might be easier to use {@link LexemeDocument#createSense(List)} )}.
*
* @param senseIdValue
* the id of the form that data is about
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public JsonDeserializer(String siteIri) {
}

/**
* Deserializes a JSON string into an {@class ItemDocument}.
* Deserializes a JSON string into an {@link ItemDocument}.
* @throws IOException
if the JSON payload is invalid
*/
Expand All @@ -80,7 +80,7 @@ public ItemDocument deserializeItemDocument(String json) throws IOException {
}

/**
* Deserializes a JSON string into a {@class PropertyDocument}.
* Deserializes a JSON string into a {@link PropertyDocument}.
* @throws IOException
if the JSON payload is invalid
*/
Expand All @@ -89,7 +89,7 @@ public PropertyDocument deserializePropertyDocument(String json) throws IOExcept
}

/**
* Deserializes a JSON string into a {@class LexemeDocument}.
* Deserializes a JSON string into a {@link LexemeDocument}.
* @throws IOException
if the JSON payload is invalid
*/
Expand All @@ -98,7 +98,7 @@ public LexemeDocument deserializeLexemeDocument(String json) throws IOException
}

/**
* Deserializes a JSON string into a {@class MediaInfoDocument}.
* Deserializes a JSON string into a {@link MediaInfoDocument}.
* @throws IOException
if the JSON payload is invalid
*/
Expand All @@ -107,7 +107,7 @@ public MediaInfoDocument deserializeMediaInfoDocument(String json) throws IOExce
}

/**
* Deserializes a JSON string into a {@class EntityDocument}.
* Deserializes a JSON string into a {@link EntityDocument}.
* @throws IOException
if the JSON payload is invalid
*/
Expand All @@ -116,7 +116,7 @@ public EntityDocument deserializeEntityDocument(String json) throws IOException
}

/**
* Deserializes a JSON string into a {@class EntityRedirectDocument}.
* Deserializes a JSON string into a {@link EntityRedirectDocument}.
* @throws IOException
if the JSON payload is invalid
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public interface StatementGroup extends Collection<Statement> {

/**
* Get the best statements of this group.
* These are the statements with rank {@link StatementRank::PREFERRED }
* if they exists or the one with rank {@link StatementRank::NORMAL }
* These are the statements with rank {@link StatementRank#PREFERRED}
* if they exists or the one with rank {@link StatementRank#NORMAL}
*
* @return a subset of the current StatementGroup, or null if there are no best statements
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ public Sites getSitesInformation() throws IOException {
* @see DumpProcessingController#processDump(MwDumpFile)
* @see DumpProcessingController#getMostRecentDump(DumpContentType)
*/
public void processAllRecentRevisionDumps() {
public void processAllRecentRevisionDumps()
throws IOException, FileAlreadyExistsException {
WmfDumpFileManager wmfDumpFileManager = getWmfDumpFileManager();
if (wmfDumpFileManager == null) {
return;
Expand Down Expand Up @@ -403,7 +404,8 @@ public void processAllRecentRevisionDumps() {
* in WDTK 0.5
*/
@Deprecated
public void processMostRecentDailyDump() {
public void processMostRecentDailyDump()
throws IOException, FileAlreadyExistsException {
processDump(getMostRecentDump(DumpContentType.JSON));
}

Expand All @@ -417,7 +419,8 @@ public void processMostRecentDailyDump() {
*
* @see DumpProcessingController#processAllRecentRevisionDumps()
*/
public void processMostRecentMainDump() {
public void processMostRecentMainDump()
throws IOException, FileAlreadyExistsException {
DumpContentType dumpContentType;
if (this.preferCurrent) {
dumpContentType = DumpContentType.CURRENT;
Expand All @@ -438,7 +441,8 @@ public void processMostRecentMainDump() {
*
* @see DumpProcessingController#processAllRecentRevisionDumps()
*/
public void processMostRecentJsonDump() {
public void processMostRecentJsonDump()
throws IOException, FileAlreadyExistsException {
processDump(getMostRecentDump(DumpContentType.JSON));
}

Expand All @@ -453,7 +457,8 @@ public void processMostRecentJsonDump() {
* @param dumpFile
* the dump to process
*/
public void processDump(MwDumpFile dumpFile) {
public void processDump(MwDumpFile dumpFile)
throws IOException, FileAlreadyExistsException {
if (dumpFile == null) {
return;
}
Expand Down Expand Up @@ -495,7 +500,8 @@ public void processDump(MwDumpFile dumpFile) {
*/
@Deprecated
public void processMostRecentDump(DumpContentType dumpContentType,
MwDumpFileProcessor dumpFileProcessor) {
MwDumpFileProcessor dumpFileProcessor)
throws IOException, FileAlreadyExistsException {
MwDumpFile dumpFile = getMostRecentDump(dumpContentType);
if (dumpFile != null) {
processDumpFile(dumpFile, dumpFileProcessor);
Expand Down Expand Up @@ -536,18 +542,23 @@ public MwDumpFile getMostRecentDump(DumpContentType dumpContentType) {
* the dump file processor to use
*/
void processDumpFile(MwDumpFile dumpFile,
MwDumpFileProcessor dumpFileProcessor) {
MwDumpFileProcessor dumpFileProcessor)
throws IOException, FileAlreadyExistsException {
try (InputStream inputStream = dumpFile.getDumpFileStream()) {
dumpFileProcessor.processDumpFileContents(inputStream, dumpFile);
} catch (FileAlreadyExistsException e) {
logger.error("Dump file "
String errorMessage = "Dump file "
+ dumpFile.toString()
+ " could not be processed since file "
+ e.getFile()
+ " already exists. Try deleting the file or dumpfile directory to attempt a new download.");
+ " already exists. Try deleting the file or dumpfile directory to attempt a new download.";
logger.error(errorMessage);
throw new FileAlreadyExistsException(errorMessage);
} catch (IOException e) {
logger.error("Dump file " + dumpFile.toString()
+ " could not be processed: " + e.toString());
String errorMessage = "Dump file " + dumpFile.toString()
+ " could not be processed: " + e.toString();
logger.error(errorMessage);
throw new IOException(errorMessage);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.wikidata.wdtk.util.CompressionType;
import org.wikidata.wdtk.util.DirectoryManager;
import org.wikidata.wdtk.util.DirectoryManagerFactory;
import org.wikidata.wdtk.dumpfiles.wmf.WmfDumpFile;

/**
* Class for representing dump files that are found at arbitrary (local) file
Expand Down Expand Up @@ -199,7 +200,7 @@ public InputStream getDumpFileStream() throws IOException {
+ "\" is not available for reading.");
}
return this.directoryManager.getInputStreamForFile(this.dumpFileName,
MwLocalDumpFile.COMPRESSION_TYPE.get(this.dumpContentType));
WmfDumpFile.getDumpFileCompressionType(dumpFileName));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,8 @@ public int compare(
* Main method. Processes the whole dump using this processor. To change
* which dump file to use and whether to run in offline mode, modify the
* settings in {@link ExampleHelpers}.
*
* @param args
* @throws IOException
*/
public static void main(String[] args) {
public static void main(String[] args) throws IOException {
ExampleHelpers.configureLogging();
ClassPropertyUsageAnalyzer.printDocumentation();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static class UsageStatistics {
*
* @param args
*/
public static void main(String[] args) {
public static void main(String[] args) throws IOException {
ExampleHelpers.configureLogging();
EntityStatisticsProcessor.printDocumentation();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public static void configureLogging() {
* the object to use for processing entities in this dump
*/
public static void processEntitiesFromWikidataDump(
EntityDocumentProcessor entityDocumentProcessor) {
EntityDocumentProcessor entityDocumentProcessor) throws IOException {

// Controller object for processing dumps:
DumpProcessingController dumpProcessingController = new DumpProcessingController(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,8 @@ public int compare(SiteRecord o1, SiteRecord o2) {
* Main method. Processes the whole dump using this processor and writes the
* results to a file. To change which dump file to use and whether to run in
* offline mode, modify the settings in {@link ExampleHelpers}.
*
* @param args
* @throws IOException
*/
public static void main(String[] args) {
public static void main(String[] args) throws IOException {
ExampleHelpers.configureLogging();
GenderRatioProcessor.printDocumentation();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,6 @@ public static void printDocumentation() {
/**
* Closes the output. Should be called after the JSON serialization was
* finished.
*
* @throws IOException
* if there was a problem closing the output
*/
public void close() {
System.out.println("Serialized "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class LifeExpectancyProcessor implements EntityDocumentProcessor {
* offline mode, modify the settings in {@link ExampleHelpers}.
*
*/
public static void main(String[] args) {
public static void main(String[] args) throws IOException {
ExampleHelpers.configureLogging();
LifeExpectancyProcessor.printDocumentation();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class LocalDumpFileExample {
*/
private final static String DUMP_FILE = "./src/resources/sample-dump-20150815.json.gz";

public static void main(String[] args) {
public static void main(String[] args) throws IOException {
ExampleHelpers.configureLogging();
LocalDumpFileExample.printDocumentation();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* #L%
*/

import java.io.IOException;

import org.wikidata.wdtk.datamodel.interfaces.EntityDocumentProcessor;
import org.wikidata.wdtk.dumpfiles.DumpProcessingController;
import org.wikidata.wdtk.dumpfiles.MwRevision;
Expand All @@ -41,7 +43,7 @@
*/
public class TutorialExample {

public static void main(String[] args) {
public static void main(String[] args) throws IOException {
ExampleHelpers.configureLogging();

// Controller object for processing dumps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public class WorldMapProcessor implements EntityDocumentProcessor {
*
* @param args
*/
public static void main(String[] args) {
public static void main(String[] args) throws IOException {
ExampleHelpers.configureLogging();
WorldMapProcessor.printDocumentation();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,6 @@ public class SetLabelsForNumbersBot implements EntityDocumentProcessor {

/**
* Main method to run the bot.
*
* @param args
* @throws LoginFailedException
* @throws IOException
* @throws MediaWikiApiErrorException
*/
public static void main(String[] args) throws LoginFailedException, IOException {
ExampleHelpers.configureLogging();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ public String getPropertyUriPattern(PropertyIdValue propertyIdValue) {
* Returns the IRI of the primitive Type of an Property for
* {@link EntityIdValue} objects.
*
* @todo this really ought to be exposed by the wdtk-datamodel
* module and reused here. The same heuristic is implemented in {@class EntityIdValueImpl}.
* TODO: this really ought to be exposed by the wdtk-datamodel
* module and reused here. The same heuristic is implemented in {@link EntityIdValueImpl}.
* @param propertyIdValue
* @param value
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ private JsonNode performAPIAction(
}

/**
* @todo TO BE REFACTORED
* TODO: TO BE REFACTORED
* @param root
* @return
* @throws IOException
Expand Down
Loading