-
Notifications
You must be signed in to change notification settings - Fork 4
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 #17 from texttechnologylab/0.0.2
added REST Client
- Loading branch information
Showing
24 changed files
with
913 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> | ||
<wb-module deploy-name="textimager-client"> | ||
<wb-resource deploy-path="/" source-path="/src/main/java"/> | ||
<wb-resource deploy-path="/" source-path="/src/main/resources"/> | ||
</wb-module> | ||
</project-modules> |
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,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<faceted-project> | ||
<installed facet="java" version="1.8"/> | ||
<installed facet="jst.utility" version="1.0"/> | ||
</faceted-project> |
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,2 @@ | ||
disabled=06target | ||
eclipse.preferences.version=1 |
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
16 changes: 16 additions & 0 deletions
16
src/main/java/org/hucompute/textimager/client/rest/CasError.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,16 @@ | ||
package org.hucompute.textimager.client.rest; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class CasError { | ||
String docId; | ||
String status; | ||
Map<String, String> exceptions; | ||
|
||
public CasError(String docId, String status) { | ||
this.docId = docId; | ||
this.status = status; | ||
this.exceptions = new HashMap<>(); | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
src/main/java/org/hucompute/textimager/client/rest/ExceptionCollectorListener.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,98 @@ | ||
package org.hucompute.textimager.client.rest; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.apache.uima.aae.UimaASApplicationEvent.EventTrigger; | ||
import org.apache.uima.aae.client.UimaASProcessStatus; | ||
import org.apache.uima.aae.client.UimaAsBaseCallbackListener; | ||
import org.apache.uima.cas.CAS; | ||
import org.apache.uima.collection.EntityProcessStatus; | ||
|
||
import de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData; | ||
import org.codehaus.plexus.util.ExceptionUtils; | ||
|
||
|
||
public class ExceptionCollectorListener extends UimaAsBaseCallbackListener{ | ||
private Map<String, CasError> errors; | ||
|
||
public boolean hasErrors() { | ||
return !errors.isEmpty(); | ||
} | ||
|
||
public Map<String, CasError> getErrors() { | ||
return errors; | ||
} | ||
|
||
public ExceptionCollectorListener() { | ||
super(); | ||
errors = new HashMap<>(); | ||
} | ||
|
||
@Override | ||
public void entityProcessComplete(CAS aCas, EntityProcessStatus aStatus) { | ||
super.entityProcessComplete(aCas, aStatus); | ||
|
||
if (aStatus.isException()) { | ||
String docId = DocumentMetaData.get(aCas).getDocumentId(); | ||
CasError casError = new CasError(docId, aStatus.getStatusMessage()); | ||
|
||
for (Exception ex : aStatus.getExceptions()) { | ||
String name = "Unknown Error"; | ||
String fullst = ExceptionUtils.getFullStackTrace(ex); | ||
|
||
ex.printStackTrace(); | ||
|
||
// Provide specific error names on known problems... | ||
if (fullst.contains("Unable to load resource")) { | ||
name = "Service Language Error"; | ||
} | ||
else if (fullst.contains("org.apache.uima.aae.error.UimaASProcessCasTimeout")) { | ||
name = "Service Unavailable Error"; | ||
} | ||
|
||
casError.exceptions.put(name, fullst); | ||
} | ||
|
||
errors.put(docId, casError); | ||
} | ||
} | ||
|
||
@Override | ||
public void collectionProcessComplete(EntityProcessStatus aStatus) { | ||
super.collectionProcessComplete(aStatus); | ||
//System.out.println("collectionProcessComplete"); | ||
}; | ||
|
||
@Override | ||
public void onBeforeMessageSend(UimaASProcessStatus status) { | ||
super.onBeforeMessageSend(status); | ||
//System.out.println("onBeforeMessageSend"); | ||
} | ||
|
||
@Override | ||
public void onBeforeProcessCAS(UimaASProcessStatus status, String nodeIP, String pid) { | ||
super.onBeforeProcessCAS(status, nodeIP, pid); | ||
//System.out.println("onBeforeProcessCAS"); | ||
} | ||
|
||
@Override | ||
public void onBeforeProcessMeta(String nodeIP, String pid) { | ||
super.onBeforeProcessMeta(nodeIP, pid); | ||
//System.out.println("onBeforeProcessMeta"); | ||
} | ||
|
||
@Override | ||
public void onUimaAsServiceExit(EventTrigger cause) { | ||
super.onUimaAsServiceExit(cause); | ||
//System.out.println("onUimaAsServiceExit"); | ||
} | ||
|
||
@Override | ||
public void initializationComplete(EntityProcessStatus aStatus) { | ||
super.initializationComplete(aStatus); | ||
System.out.println(aStatus); | ||
//System.out.println("initializationComplete"); | ||
} | ||
|
||
} |
Oops, something went wrong.