You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(33) |
Nov
(96) |
Dec
(173) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(45) |
Feb
(46) |
Mar
(58) |
Apr
(83) |
May
(11) |
Jun
(62) |
Jul
(79) |
Aug
(62) |
Sep
(42) |
Oct
(105) |
Nov
(57) |
Dec
(73) |
2007 |
Jan
(187) |
Feb
(60) |
Mar
(313) |
Apr
(174) |
May
(74) |
Jun
(99) |
Jul
(132) |
Aug
(62) |
Sep
(65) |
Oct
(83) |
Nov
(63) |
Dec
(41) |
2008 |
Jan
(83) |
Feb
(82) |
Mar
(42) |
Apr
(88) |
May
(68) |
Jun
(67) |
Jul
(37) |
Aug
(69) |
Sep
(52) |
Oct
(85) |
Nov
(65) |
Dec
(49) |
2009 |
Jan
(50) |
Feb
(70) |
Mar
(95) |
Apr
(69) |
May
(122) |
Jun
(44) |
Jul
(217) |
Aug
(397) |
Sep
(307) |
Oct
(302) |
Nov
(131) |
Dec
(104) |
2010 |
Jan
(87) |
Feb
(102) |
Mar
(105) |
Apr
(141) |
May
(110) |
Jun
(85) |
Jul
(80) |
Aug
(110) |
Sep
(56) |
Oct
(63) |
Nov
(65) |
Dec
(45) |
2011 |
Jan
(58) |
Feb
(93) |
Mar
(86) |
Apr
(177) |
May
(82) |
Jun
(182) |
Jul
(91) |
Aug
(72) |
Sep
(70) |
Oct
(124) |
Nov
(154) |
Dec
(251) |
2012 |
Jan
(414) |
Feb
(211) |
Mar
(153) |
Apr
(69) |
May
(139) |
Jun
(50) |
Jul
(80) |
Aug
(48) |
Sep
(61) |
Oct
(101) |
Nov
(192) |
Dec
(52) |
2013 |
Jan
(48) |
Feb
(47) |
Mar
(75) |
Apr
(43) |
May
(32) |
Jun
(14) |
Jul
(39) |
Aug
(80) |
Sep
(128) |
Oct
(77) |
Nov
(105) |
Dec
(61) |
2014 |
Jan
(61) |
Feb
(224) |
Mar
(265) |
Apr
(154) |
May
(130) |
Jun
(88) |
Jul
(98) |
Aug
(57) |
Sep
(81) |
Oct
(58) |
Nov
(57) |
Dec
(34) |
2015 |
Jan
(38) |
Feb
(37) |
Mar
(26) |
Apr
(43) |
May
(73) |
Jun
(76) |
Jul
(38) |
Aug
(44) |
Sep
(39) |
Oct
(51) |
Nov
(36) |
Dec
(41) |
2016 |
Jan
(35) |
Feb
(51) |
Mar
(16) |
Apr
(106) |
May
(121) |
Jun
(58) |
Jul
(40) |
Aug
(71) |
Sep
(53) |
Oct
(100) |
Nov
(127) |
Dec
(66) |
2017 |
Jan
(130) |
Feb
(48) |
Mar
(1) |
Apr
(8) |
May
(16) |
Jun
(19) |
Jul
(12) |
Aug
(4) |
Sep
(2) |
Oct
(2) |
Nov
(4) |
Dec
(3) |
2018 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
(2) |
May
(3) |
Jun
(3) |
Jul
|
Aug
(1) |
Sep
|
Oct
(1) |
Nov
(2) |
Dec
(1) |
2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(4) |
2023 |
Jan
|
Feb
(2) |
Mar
(1) |
Apr
(2) |
May
(3) |
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
|
2024 |
Jan
(1) |
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(4) |
Sep
|
Oct
(4) |
Nov
|
Dec
|
From: <mar...@us...> - 2017-01-31 11:42:36
|
Revision: 20025 http://sourceforge.net/p/gate/code/20025 Author: markagreenwood Date: 2017-01-31 11:42:34 +0000 (Tue, 31 Jan 2017) Log Message: ----------- helps if you update the subclasses as well Modified Paths: -------------- gate/branches/sawdust2/plugins/Tools/src/main/java/gate/creole/VPChunker.java Modified: gate/branches/sawdust2/plugins/Tools/src/main/java/gate/creole/VPChunker.java =================================================================== --- gate/branches/sawdust2/plugins/Tools/src/main/java/gate/creole/VPChunker.java 2017-01-31 11:30:47 UTC (rev 20024) +++ gate/branches/sawdust2/plugins/Tools/src/main/java/gate/creole/VPChunker.java 2017-01-31 11:42:34 UTC (rev 20025) @@ -70,7 +70,7 @@ defaultValue = "resources/VP/VerbGroups.jape" ) @Override - public void setGrammarURL(java.net.URL newGrammarURL) { + public void setGrammarURL(ResourceReference newGrammarURL) { super.setGrammarURL(newGrammarURL); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2017-01-31 11:30:49
|
Revision: 20024 http://sourceforge.net/p/gate/code/20024 Author: markagreenwood Date: 2017-01-31 11:30:47 +0000 (Tue, 31 Jan 2017) Log Message: ----------- Gazetteers now use ResourceReferences instead of URLs as well Modified Paths: -------------- gate/branches/sawdust2/plugins/ANNIE/src/main/java/com/ontotext/gate/gazetteer/HashGazetteer.java gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/AbstractGazetteer.java gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/DefaultGazetteer.java gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/Gazetteer.java gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/gui/GazetteerEditor.java Modified: gate/branches/sawdust2/plugins/ANNIE/src/main/java/com/ontotext/gate/gazetteer/HashGazetteer.java =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/com/ontotext/gate/gazetteer/HashGazetteer.java 2017-01-31 11:13:40 UTC (rev 20023) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/com/ontotext/gate/gazetteer/HashGazetteer.java 2017-01-31 11:30:47 UTC (rev 20024) @@ -23,6 +23,7 @@ import gate.util.InvalidOffsetException; import gate.util.LuckyException; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -55,7 +56,12 @@ try { mapsList = new HashMap[1000]; definition = new LinearDefinition(); - definition.setURL(listsURL); + try { + definition.setURL(listsURL.toURL()); + } + catch (IOException e) { + throw new ResourceInstantiationException(e); + } definition.load(); int i = definition.size(); listsByNode = definition.loadLists(); Modified: gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/AbstractGazetteer.java =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/AbstractGazetteer.java 2017-01-31 11:13:40 UTC (rev 20023) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/AbstractGazetteer.java 2017-01-31 11:30:47 UTC (rev 20024) @@ -15,16 +15,17 @@ */ package gate.creole.gazetteer; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + import gate.creole.AbstractLanguageAnalyser; import gate.creole.ResourceInstantiationException; +import gate.creole.ResourceReference; import gate.creole.metadata.CreoleParameter; import gate.creole.metadata.Optional; import gate.creole.metadata.RunTime; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - /**AbstractGazetteer * This class implements the common-for-all methods of the Gazetteer interface*/ public abstract class AbstractGazetteer @@ -46,7 +47,7 @@ * The value of this property is the URL that will be used for reading the * lists that define this Gazetteer */ - protected java.net.URL listsURL; + protected ResourceReference listsURL; /** * Should this gazetteer be case sensitive. The default value is true. @@ -112,13 +113,13 @@ } @Override - public java.net.URL getListsURL() { + public ResourceReference getListsURL() { return listsURL; } @Override @CreoleParameter(comment="The URL to the file with list of lists", suffixes="def", defaultValue="resources/gazetteer/lists.def") - public void setListsURL(java.net.URL newListsURL) { + public void setListsURL(ResourceReference newListsURL) { listsURL = newListsURL; } Modified: gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/DefaultGazetteer.java =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/DefaultGazetteer.java 2017-01-31 11:13:40 UTC (rev 20023) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/DefaultGazetteer.java 2017-01-31 11:30:47 UTC (rev 20024) @@ -17,6 +17,8 @@ */ package gate.creole.gazetteer; +import java.io.IOException; +import java.io.IOException; import java.io.Serializable; import java.util.Arrays; import java.util.HashSet; @@ -115,7 +117,13 @@ } definition = new LinearDefinition(); definition.setSeparator(Strings.unescape(gazetteerFeatureSeparator)); - definition.setURL(listsURL); + try { + definition.setURL(listsURL.toURL()); + } + catch (IOException e) { + throw new ResourceInstantiationException(e); + } + definition.load(); int linesCnt = definition.size(); listsByNode = definition.loadLists(); Modified: gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/Gazetteer.java =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/Gazetteer.java 2017-01-31 11:13:40 UTC (rev 20023) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/Gazetteer.java 2017-01-31 11:30:47 UTC (rev 20024) @@ -17,6 +17,8 @@ import java.util.Set; +import gate.creole.ResourceReference; + /**The Gazetteer interface defines the mandatory methods of a gazetteer PR. */ public interface Gazetteer extends gate.LanguageAnalyser,gate.ProcessingResource { @@ -47,11 +49,11 @@ /**Gets the url of the lists.def file * @return the url of the lists.def file */ - public java.net.URL getListsURL() ; + public ResourceReference getListsURL() ; /**Sets the url of the lists.def file * @param newListsURL the url of the lists.def file to be set */ - public void setListsURL(java.net.URL newListsURL) ; + public void setListsURL(ResourceReference newListsURL) ; /**Triggers case sensitive * @param newCaseSensitive turn on or off case sensitivity */ Modified: gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/gui/GazetteerEditor.java =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/gui/GazetteerEditor.java 2017-01-31 11:13:40 UTC (rev 20023) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/gui/GazetteerEditor.java 2017-01-31 11:30:47 UTC (rev 20024) @@ -825,8 +825,15 @@ } // update file list name in the drop down list - File gazetteerDirectory = new File( - Files.fileFromURL(gazetteer.getListsURL()).getParent()); + File defFile = null; + try { + Files.fileFromURL(gazetteer.getListsURL().toURL()); + } + catch (IOException ioe) { + ioe.printStackTrace(); + return; + } + File gazetteerDirectory = new File(defFile.getParent()); File[] files = gazetteerDirectory.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2017-01-31 11:13:42
|
Revision: 20023 http://sourceforge.net/p/gate/code/20023 Author: markagreenwood Date: 2017-01-31 11:13:40 +0000 (Tue, 31 Jan 2017) Log Message: ----------- JAPE grammars are now created from ResourceReference instances and not URLs Modified Paths: -------------- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/ANNIETransducer.java gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/Transducer.java gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/gui/jape/JapeViewer.java gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/Compiler.java Modified: gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/ANNIETransducer.java =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/ANNIETransducer.java 2017-01-31 10:41:20 UTC (rev 20022) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/ANNIETransducer.java 2017-01-31 11:13:40 UTC (rev 20023) @@ -67,7 +67,7 @@ defaultValue = "resources/NE/main.jape" ) @Override - public void setGrammarURL(java.net.URL newGrammarURL) { + public void setGrammarURL(ResourceReference newGrammarURL) { super.setGrammarURL(newGrammarURL); } Modified: gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/Transducer.java =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/Transducer.java 2017-01-31 10:41:20 UTC (rev 20022) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/Transducer.java 2017-01-31 11:13:40 UTC (rev 20023) @@ -114,7 +114,7 @@ } } else if(grammarURL != null) { if(encoding != null) { - batch = new Batch(grammarURL, encoding, new InternalStatusListener()); + batch = new Batch(grammarURL.toURL(), encoding, new InternalStatusListener()); if(enableDebugging != null) { batch.setEnableDebugging(enableDebugging.booleanValue()); } else { @@ -349,7 +349,7 @@ disjunction = "grammar", priority = 1 ) - public void setGrammarURL(java.net.URL newGrammarURL) { + public void setGrammarURL(ResourceReference newGrammarURL) { grammarURL = newGrammarURL; } @@ -358,7 +358,7 @@ * * @return a {@link java.net.URL} pointing to the grammar file. */ - public java.net.URL getGrammarURL() { + public ResourceReference getGrammarURL() { return grammarURL; } @@ -504,7 +504,7 @@ /** * The URL to the jape file used as grammar by this transducer. */ - protected java.net.URL grammarURL; + protected ResourceReference grammarURL; /** * The URL to the serialized jape file used as grammar by this transducer. Modified: gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/gui/jape/JapeViewer.java =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/gui/jape/JapeViewer.java 2017-01-31 10:41:20 UTC (rev 20022) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/gui/jape/JapeViewer.java 2017-01-31 11:13:40 UTC (rev 20023) @@ -6,6 +6,7 @@ import gate.creole.AbstractProcessingResource; import gate.creole.AbstractVisualResource; import gate.creole.ResourceInstantiationException; +import gate.creole.ResourceReference; import gate.creole.metadata.CreoleResource; import gate.creole.metadata.GuiType; import gate.event.ProgressListener; @@ -223,9 +224,9 @@ URL japeFileURL = null; try { - japeFileURL = (URL)transducer.getParameterValue("grammarURL"); + japeFileURL = ((ResourceReference)transducer.getParameterValue("grammarURL")).toURL(); } - catch (ResourceInstantiationException rie) { + catch (ResourceInstantiationException | IOException rie) { //ignore this for now and let the null catch take over rie.printStackTrace(); } Modified: gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/Compiler.java =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/Compiler.java 2017-01-31 10:41:20 UTC (rev 20022) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/jape/Compiler.java 2017-01-31 11:13:40 UTC (rev 20023) @@ -19,6 +19,7 @@ import java.io.*; import java.net.URL; import gate.Gate; +import gate.creole.ResourceReference; import gate.creole.Transducer; /** @@ -70,7 +71,7 @@ public static void compile(URL jape, File ser) throws Exception { Transducer transducer = new Transducer(); - transducer.setGrammarURL(jape); + transducer.setGrammarURL(new ResourceReference(jape)); transducer.setEncoding(defaultEncoding); transducer.init(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2017-01-31 10:41:22
|
Revision: 20022 http://sourceforge.net/p/gate/code/20022 Author: markagreenwood Date: 2017-01-31 10:41:20 +0000 (Tue, 31 Jan 2017) Log Message: ----------- another test to check none file URLs are persisted properly inside ResourceReference instances Modified Paths: -------------- gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java Modified: gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java =================================================================== --- gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-31 10:39:06 UTC (rev 20021) +++ gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-31 10:41:20 UTC (rev 20022) @@ -210,6 +210,9 @@ rr = new ResourceReference(creolePlugin,"resources/file.txt"); checkPersistence(xgappFile, rr, "creole://group;artifact;version/resources/file.txt"); + + rr = new ResourceReference(new URL("http://gate.ac.uk/resource/file.txt")); + checkPersistence(xgappFile, rr, "http://gate.ac.uk/resource/file.txt"); } public void checkPersistence(File xgappFile, ResourceReference rr1, String expected) throws Exception { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2017-01-31 10:39:09
|
Revision: 20021 http://sourceforge.net/p/gate/code/20021 Author: markagreenwood Date: 2017-01-31 10:39:06 +0000 (Tue, 31 Jan 2017) Log Message: ----------- I should do test driven development more often, I'd forgotten just how easy it made things. Anyway added another test and fixed an bug I'd missed when adding the URI based RRPersistence Modified Paths: -------------- gate/branches/sawdust2/gate-core/src/main/java/gate/util/persistence/PersistenceManager.java gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/util/persistence/PersistenceManager.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/util/persistence/PersistenceManager.java 2017-01-31 02:23:33 UTC (rev 20020) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/util/persistence/PersistenceManager.java 2017-01-31 10:39:06 UTC (rev 20021) @@ -205,7 +205,7 @@ } // if protocol is file else { // protocol was not file: - uriString = ((URI)source).toString(); + uriString = ((ResourceReference)source).toExternalForm(); } } catch(ClassCastException | URISyntaxException e) { Modified: gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java =================================================================== --- gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-31 02:23:33 UTC (rev 20020) +++ gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-31 10:39:06 UTC (rev 20021) @@ -200,19 +200,23 @@ } public void testPersistence() throws Exception { - + File xgappFile = File.createTempFile("rr-test", ".xgapp"); + xgappFile.deleteOnExit(); + + File txtFile = new File(xgappFile.getParentFile(),"test-file.txt"); + txtFile.deleteOnExit(); + ResourceReference rr = new ResourceReference(txtFile.toURI()); + checkPersistence(xgappFile, rr, "$relpath$test-file.txt"); + + rr = new ResourceReference(creolePlugin,"resources/file.txt"); + checkPersistence(xgappFile, rr, "creole://group;artifact;version/resources/file.txt"); + } + + public void checkPersistence(File xgappFile, ResourceReference rr1, String expected) throws Exception { Resource resource = null, restored = null; - - File xgappFile = null; - File txtFile = null; try { - xgappFile = File.createTempFile("rr-test", ".xgapp"); - txtFile = new File(xgappFile.getParentFile(),"test-file.txt"); - - ResourceReference rr1 = new ResourceReference(txtFile.toURI()); - FeatureMap params = Factory.newFeatureMap(); params.put("param", rr1); resource = Factory.createResource(TestResource.class.getName(),params); @@ -230,9 +234,8 @@ assertNotNull("We couldn't find the RRPersistence wrapper",value); - assertEquals("The URI was not as expected","$relpath$test-file.txt", value.getChildText("uriString")); + assertEquals("The URI was not as expected",expected, value.getChildText("uriString")); - //System.out.println(IOUtils.toString(xgappFile.toURI().toURL().openStream())); restored = (Resource)PersistenceManager.loadObjectFromFile(xgappFile); ResourceReference rr2 = (ResourceReference)restored.getParameterValue("param"); @@ -250,6 +253,5 @@ Factory.deleteResource(restored); } } - } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gat...@us...> - 2017-01-31 02:23:36
|
Revision: 20020 http://sourceforge.net/p/gate/code/20020 Author: gate-project Date: 2017-01-31 02:23:33 +0000 (Tue, 31 Jan 2017) Log Message: ----------- Build number update (build 5729) Modified Paths: -------------- gate/trunk/build/build.properties gate/trunk/build/build.txt Modified: gate/trunk/build/build.properties =================================================================== --- gate/trunk/build/build.properties 2017-01-30 17:25:24 UTC (rev 20019) +++ gate/trunk/build/build.properties 2017-01-31 02:23:33 UTC (rev 20020) @@ -1,4 +1,4 @@ #Build Number for ANT. Do not edit! -#Mon Jan 30 02:09:46 GMT 2017 +#Tue Jan 31 02:10:06 GMT 2017 cvs.version=$Id\: build.properties 7542 2006-07-17 14\:26\:51Z ian_roberts $ -build.number=5729 +build.number=5730 Modified: gate/trunk/build/build.txt =================================================================== --- gate/trunk/build/build.txt 2017-01-30 17:25:24 UTC (rev 20019) +++ gate/trunk/build/build.txt 2017-01-31 02:23:33 UTC (rev 20020) @@ -1 +1 @@ -5728 \ No newline at end of file +5729 \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2017-01-30 17:25:27
|
Revision: 20019 http://sourceforge.net/p/gate/code/20019 Author: markagreenwood Date: 2017-01-30 17:25:24 +0000 (Mon, 30 Jan 2017) Log Message: ----------- don't try and create a ResourceReference instance from a string if the string is either null or empty Modified Paths: -------------- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Parameter.java gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Parameter.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Parameter.java 2017-01-30 17:14:03 UTC (rev 20018) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Parameter.java 2017-01-30 17:25:24 UTC (rev 20019) @@ -261,10 +261,12 @@ } } else if (typeName.equals("gate.creole.ResourceReference")) { - try { - value = new ResourceReference(plugin, stringValue); - } catch(URISyntaxException e) { - throw new ParameterException("Malformed ResourceReference parameter value: "+stringValue,e); + if (stringValue != null && !stringValue.equals("")) { + try { + value = new ResourceReference(plugin, stringValue); + } catch(URISyntaxException e) { + throw new ParameterException("Malformed ResourceReference parameter value: "+stringValue,e); + } } } // java builtin types - for numeric types, we don't attempt to parse an Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java 2017-01-30 17:14:03 UTC (rev 20018) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java 2017-01-30 17:25:24 UTC (rev 20019) @@ -61,9 +61,9 @@ public ResourceReference(Plugin plugin, String path) throws URISyntaxException { - if (path == null) path = ""; - - if(plugin != null) { + if(path == null) path = ""; + + if(plugin != null) { uri = plugin.getBaseURI().resolve(path); } else { uri = new URI(path); @@ -149,7 +149,7 @@ throw new IOException("Unable to locate URI: " + uri); } - public URI toURI() throws URISyntaxException { + public URI toURI() { return uri; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2017-01-30 17:14:05
|
Revision: 20018 http://sourceforge.net/p/gate/code/20018 Author: markagreenwood Date: 2017-01-30 17:14:03 +0000 (Mon, 30 Jan 2017) Log Message: ----------- running the updates on the EDT explicitly seems to be causeing problems, as it seems that the events are being triggered by the EDT anyway. No matter how much I work on classloaders I still hate them.... possibly more than maven and git combined! Modified Paths: -------------- gate/branches/sawdust2/gate-core/src/main/java/gate/gui/MainFrame.java Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/gui/MainFrame.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/gui/MainFrame.java 2017-01-30 16:16:25 UTC (rev 20017) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/gui/MainFrame.java 2017-01-30 17:14:03 UTC (rev 20018) @@ -1946,9 +1946,9 @@ final Resource res = e.getResource(); if(Gate.getHiddenAttribute(res.getFeatures()) || res instanceof VisualResource) return; - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { + //SwingUtilities.invokeLater(new Runnable() { + // @Override + // public void run() { NameBearerHandle handle = null; @@ -1970,8 +1970,8 @@ if (handle != null) handle.addProgressListener(MainFrame.this); if (handle != null) handle.addStatusListener(MainFrame.this); - } - }); + // } + //}); // JPopupMenu popup = handle.getPopup(); // This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2017-01-30 16:16:27
|
Revision: 20017 http://sourceforge.net/p/gate/code/20017 Author: markagreenwood Date: 2017-01-30 16:16:25 +0000 (Mon, 30 Jan 2017) Log Message: ----------- if the path is null make it the empty string to aviod an NPE later Modified Paths: -------------- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java 2017-01-30 16:05:37 UTC (rev 20016) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java 2017-01-30 16:16:25 UTC (rev 20017) @@ -61,7 +61,9 @@ public ResourceReference(Plugin plugin, String path) throws URISyntaxException { - if(plugin != null) { + if (path == null) path = ""; + + if(plugin != null) { uri = plugin.getBaseURI().resolve(path); } else { uri = new URI(path); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2017-01-30 16:05:39
|
Revision: 20016 http://sourceforge.net/p/gate/code/20016 Author: markagreenwood Date: 2017-01-30 16:05:37 +0000 (Mon, 30 Jan 2017) Log Message: ----------- loading of persisted ResourceReference instances now works (or at least my test passes) with proper handling of $ etc. This is done by gerneralizing the way URLs are handled so the same code now works with URLs and URIs. So if something stops working with a URL this is probably where I should look for the bug Modified Paths: -------------- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java gate/branches/sawdust2/gate-core/src/main/java/gate/util/persistence/PersistenceManager.java gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java 2017-01-30 11:33:40 UTC (rev 20015) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java 2017-01-30 16:05:37 UTC (rev 20016) @@ -128,10 +128,6 @@ public URL toURL() throws IOException { - if(!uri.isAbsolute()) - throw new IOException( - "Unable to access relative resource reference: " + uri); - if(!uri.getScheme().equals("creole")) return uri.toURL(); try { Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/util/persistence/PersistenceManager.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/util/persistence/PersistenceManager.java 2017-01-30 11:33:40 UTC (rev 20015) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/util/persistence/PersistenceManager.java 2017-01-30 16:05:37 UTC (rev 20016) @@ -162,7 +162,9 @@ } public static class RRPersistence implements Persistence { - + + private static final long serialVersionUID = 6543151074741224114L; + String uriString; @Override @@ -214,10 +216,10 @@ @Override public Object createObject() throws PersistenceException, ResourceInstantiationException { - // TODO Auto-generated method stub - return null; - } - + + return URLHolder.unpackPersistentRepresentation(uriString); + + } } /** @@ -452,13 +454,20 @@ * supposed to be a copy for the original object used as source for * data extraction. */ - // TODO: this always uses the one-argument constructor for URL. This may not always - // do the right thing though, we should test this (e.g. when the URL contains %-encoded parts) @Override public Object createObject() throws PersistenceException { try { - if(urlString.startsWith(relativePathMarker)) { - URL context = currentPersistenceURL(); + return unpackPersistentRepresentation(urlString).toURL(); + } catch(MalformedURLException e) { + throw new PersistenceException(e); + } + } + + public static URI unpackPersistentRepresentation(String persistent) throws PersistenceException { + try { + + if(persistent.startsWith(relativePathMarker)) { + URI context = currentPersistenceURL().toURI(); // If the part after the $relpath$ marker is empty, the normal method // would get us the URL of the context which will be the URL of the pipeline, not // of the directory where the pipeline is located. @@ -471,37 +480,37 @@ // If the relative part is starting with a slash, we remove that //URL ret = new URL(context, urlString.substring(relativePathMarker // .length())); - URL ret = combineContextAndRelative(context, urlString.substring(relativePathMarker + URI ret = combineContextAndRelative(context, persistent.substring(relativePathMarker .length()), true); logger.debug("CurrentPresistenceURL is "+context+" created="+ret); return ret; - } else if(urlString.startsWith(gatehomePathMarker)) { + } else if(persistent.startsWith(gatehomePathMarker)) { URL gatehome = getCanonicalFileIfPossible(getGateHomePath()).toURI().toURL(); //return new URL(gatehome, urlString.substring(gatehomePathMarker.length())); - return combineContextAndRelative(gatehome, urlString.substring(gatehomePathMarker.length()),false); - } else if(urlString.startsWith(gatepluginsPathMarker)) { + return combineContextAndRelative(gatehome.toURI(), persistent.substring(gatehomePathMarker.length()),false); + } else if(persistent.startsWith(gatepluginsPathMarker)) { URL gateplugins = Gate.getPluginsHome().toURI().toURL(); //return new URL(gateplugins, urlString.substring(gatepluginsPathMarker.length())); - return combineContextAndRelative(gateplugins, urlString.substring(gatepluginsPathMarker.length()),false); - } else if(urlString.startsWith(resourceshomePathMarker)) { + return combineContextAndRelative(gateplugins.toURI(), persistent.substring(gatepluginsPathMarker.length()),false); + } else if(persistent.startsWith(resourceshomePathMarker)) { if(getResourceshomePath() == null) { - throw new GateRuntimeException("Cannot restore URL "+urlString+ + throw new GateRuntimeException("Cannot restore URL "+persistent+ "property "+resourceshomePropertyName+" is not set"); } URL resourceshomeurl = getResourceshomePath().toURI().toURL(); //return new URL(resourceshomeurl, urlString.substring(resourceshomePathMarker.length())); - return combineContextAndRelative(resourceshomeurl, urlString.substring(resourceshomePathMarker.length()),false); - } else if(urlString.startsWith(syspropMarker)) { - String urlRestString = urlString.substring(syspropMarker.length()); + return combineContextAndRelative(resourceshomeurl.toURI(), persistent.substring(resourceshomePathMarker.length()),false); + } else if(persistent.startsWith(syspropMarker)) { + String urlRestString = persistent.substring(syspropMarker.length()); int dollarindex = urlRestString.indexOf("$"); if(dollarindex > 0) { String syspropname = urlRestString.substring(0,dollarindex); String propvalue = System.getProperty(syspropname); if(propvalue == null) { - throw new PersistenceException("Property '"+syspropname+"' is null in "+urlString); + throw new PersistenceException("Property '"+syspropname+"' is null in "+persistent); } // TODO: we should only assume a file if what we get does not start with a protocol - URL propuri = (new File(propvalue)).toURI().toURL(); + URI propuri = (new File(propvalue)).toURI(); if(dollarindex == urlRestString.length()) { return propuri; } else { @@ -509,15 +518,15 @@ return combineContextAndRelative(propuri, urlRestString.substring(dollarindex+1),false); } } else if(dollarindex == 0) { - throw new PersistenceException("No property name after '"+syspropMarker+"' in "+urlString); + throw new PersistenceException("No property name after '"+syspropMarker+"' in "+persistent); } else { - throw new PersistenceException("No ending $ after '"+syspropMarker+"' in "+urlString); + throw new PersistenceException("No ending $ after '"+syspropMarker+"' in "+persistent); } } else { - return new URL(urlString); + return new URI(persistent); } } - catch(MalformedURLException mue) { + catch(MalformedURLException | URISyntaxException mue) { throw new PersistenceException(mue); } } @@ -526,7 +535,7 @@ //******** Helper methods just used inside the URLHolder class - private URL combineContextAndRelative(URL context, String relative, boolean contextIsFile) { + private static URI combineContextAndRelative(URI context, String relative, boolean contextIsFile) { // make sure we always have a proper string if(relative==null) relative = ""; // we always want to interpret the part after the marker as a relative path, so @@ -538,7 +547,7 @@ if(relative.isEmpty()) { if(!contextIsFile) return context; // context is file, get the parent and return that - URI tmpUri; + /*URI tmpUri; try { tmpUri = context.toURI(); } catch (URISyntaxException ex) { @@ -550,17 +559,18 @@ context = tmpUri.toURL(); } catch (Exception ex) { throw new GateRuntimeException("Could not convert context URI to URL: "+tmpUri,ex); - } - return context; + }*/ + return context.resolve("."); } else { // use the URL constructor to splice the two parts together - URL tmpUrl; + /*URL tmpUrl; try { tmpUrl = new URL(context,relative); } catch (Exception ex) { throw new GateRuntimeException("Could not create a URL from context "+context+" and relative part "+relative,ex); } - return tmpUrl; + return tmpUrl;*/ + return context.resolve(relative); } } @@ -1274,8 +1284,8 @@ try { if (anUrl instanceof URL) Gate.getCreoleRegister().registerPlugin(new Plugin.Directory((URL)anUrl),false); - else - Gate.getCreoleRegister().registerPlugin((Plugin)anUrl, false); + else if (anUrl instanceof Plugin) + Gate.getCreoleRegister().registerPlugin((Plugin)anUrl, false); } catch(GateException ge) { System.out.println("We've hit an error!"); Modified: gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java =================================================================== --- gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-30 11:33:40 UTC (rev 20015) +++ gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-30 16:05:37 UTC (rev 20016) @@ -6,7 +6,6 @@ import java.net.URL; import org.apache.commons.io.IOUtils; -import org.jdom.Content; import org.jdom.Document; import org.jdom.Element; import org.jdom.JDOMException; @@ -39,40 +38,46 @@ @CreoleParameter(defaultValue = "resources/file.txt") public void setParam(ResourceReference rr) { this.rr = rr; + } + } + + public static class TestPlugin extends Plugin.Maven { + + public TestPlugin() { + super("group", "artifact", "version"); } - } + @Override + public URL getBaseURL() { + try { + return new URL(TestDocument.getTestServerName() + "tests/"); + } catch(Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public Document getCreoleXML() throws Exception, JDOMException { + Document doc = new Document(); + Element element = null; + doc.addContent(element = new Element("CREOLE-DIRECTORY")); + + element.addContent(element = new Element("CREOLE")); + element.addContent(element = new Element("RESOURCE")); + Element classElement = new Element("CLASS"); + classElement.setText(TestResource.class.getName()); + element.addContent(classElement); + return doc; + } + }; + @Override public void setUp() throws Exception { // Initialise the GATE library and creole register Gate.init(); + + creolePlugin = new TestPlugin(); - creolePlugin = new Plugin.Maven("group", "artifact", "version") { - - @Override - public URL getBaseURL() { - try { - return new URL(TestDocument.getTestServerName() + "tests/"); - } catch(Exception e) { - throw new RuntimeException(e); - } - } - - @Override - public Document getCreoleXML() throws Exception, JDOMException { - Document doc = new Document(); - Element element = null; - doc.addContent(element = new Element("CREOLE-DIRECTORY")); - - element.addContent(element = new Element("CREOLE")); - element.addContent(element = new Element("RESOURCE")); - Element classElement = new Element("CLASS"); - classElement.setText(TestResource.class.getName()); - element.addContent(classElement); - return doc; - } - }; - Gate.getCreoleRegister().registerPlugin(creolePlugin); } @@ -196,19 +201,20 @@ public void testPersistence() throws Exception { - Resource resource = null; + Resource resource = null, restored = null; File xgappFile = null; File txtFile = null; try { xgappFile = File.createTempFile("rr-test", ".xgapp"); - xgappFile.createNewFile(); - + txtFile = new File(xgappFile.getParentFile(),"test-file.txt"); + ResourceReference rr1 = new ResourceReference(txtFile.toURI()); + FeatureMap params = Factory.newFeatureMap(); - params.put("param", new ResourceReference(txtFile.toURI())); + params.put("param", rr1); resource = Factory.createResource(TestResource.class.getName(),params); PersistenceManager.saveObjectToFile(resource, xgappFile); @@ -218,7 +224,7 @@ Element entry = doc.getRootElement().getChild("application").getChild("initParams").getChild("localMap").getChild("entry"); - assertEquals("couldn't find a param entry", "param",entry.getChildText("string")); + assertEquals("couldn't find the paramameter entry", "param",entry.getChildText("string")); Element value = entry.getChild("gate.util.persistence.PersistenceManager-RRPersistence"); @@ -226,6 +232,13 @@ assertEquals("The URI was not as expected","$relpath$test-file.txt", value.getChildText("uriString")); + //System.out.println(IOUtils.toString(xgappFile.toURI().toURL().openStream())); + restored = (Resource)PersistenceManager.loadObjectFromFile(xgappFile); + + ResourceReference rr2 = (ResourceReference)restored.getParameterValue("param"); + + assertEquals(rr1, rr2); + } finally { if (xgappFile != null) xgappFile.deleteOnExit(); @@ -233,7 +246,9 @@ Factory.deleteResource(resource); } - + if(restored != null) { + Factory.deleteResource(restored); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2017-01-30 11:33:42
|
Revision: 20015 http://sourceforge.net/p/gate/code/20015 Author: markagreenwood Date: 2017-01-30 11:33:40 +0000 (Mon, 30 Jan 2017) Log Message: ----------- much easier to see if we are reading the right things back from disk if we have sensible equality tests Modified Paths: -------------- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java 2017-01-30 11:28:58 UTC (rev 20014) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java 2017-01-30 11:33:40 UTC (rev 20015) @@ -39,6 +39,26 @@ this.uri = uri; } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((uri == null) ? 0 : uri.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if(this == obj) return true; + if(obj == null) return false; + if(getClass() != obj.getClass()) return false; + ResourceReference other = (ResourceReference)obj; + if(uri == null) { + if(other.uri != null) return false; + } else if(!uri.equals(other.uri)) return false; + return true; + } + public ResourceReference(Plugin plugin, String path) throws URISyntaxException { if(plugin != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2017-01-30 11:29:00
|
Revision: 20014 http://sourceforge.net/p/gate/code/20014 Author: markagreenwood Date: 2017-01-30 11:28:58 +0000 (Mon, 30 Jan 2017) Log Message: ----------- ResourceReference params can now be persisted into xgapp files and any that refer to objects by file URL are handled in the same was as saving file: URLs already are so $ etc. works. Note that reading these back doesn't work yet Modified Paths: -------------- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java gate/branches/sawdust2/gate-core/src/main/java/gate/util/persistence/PersistenceManager.java gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java 2017-01-30 02:23:19 UTC (rev 20013) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java 2017-01-30 11:28:58 UTC (rev 20014) @@ -16,6 +16,7 @@ import java.io.IOException; import java.io.InputStream; +import java.io.Serializable; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; @@ -24,8 +25,10 @@ import gate.Gate; -public class ResourceReference { +public class ResourceReference implements Serializable { + private static final long serialVersionUID = 2526144106607856721L; + private URI uri; public ResourceReference(URL url) throws URISyntaxException { Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/util/persistence/PersistenceManager.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/util/persistence/PersistenceManager.java 2017-01-30 02:23:19 UTC (rev 20013) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/util/persistence/PersistenceManager.java 2017-01-30 11:28:58 UTC (rev 20014) @@ -76,6 +76,7 @@ import gate.creole.ConditionalSerialAnalyserController; import gate.creole.Plugin; import gate.creole.ResourceInstantiationException; +import gate.creole.ResourceReference; import gate.creole.SerialAnalyserController; import gate.event.ProgressListener; import gate.event.StatusListener; @@ -159,7 +160,66 @@ static final long serialVersionUID = -8665414981783519937L; } + + public static class RRPersistence implements Persistence { + + String uriString; + + @Override + public String toString() { + return uriString; + } + @Override + public void extractDataFromSource(Object source) + throws PersistenceException { + + try { + URI uri = null; + + if (source instanceof ResourceReference) { + uri = ((ResourceReference)source).toURI(); + } + + if (uri == null) throw new UnsupportedOperationException("Whatever you are trying to persist isn't a URL"); + + if(uri.getScheme() != null && uri.getScheme().equals("file")) { + // url is what we want to convert to something that is relative to $relpath$, + // $resourceshome$ or $gatehome$ + + // The file in which the URL should get persisted, the directory this file is in + // is the location to which we want to make the URL relative, unless we want to + // use $gatehome$ or $resourceshome$ + File outFile = currentPersistenceFile(); + //File outFileReal = getCanonicalFileIfPossible(outFile); + + File urlFile = new File(uri);//Files.fileFromURL(url); + //File urlFileReal = getCanonicalFileIfPossible(urlFile); + + //logger.debug("Trying to persist "+uri+" for "+outFile); + + uriString = URLHolder.relativize(outFile, urlFile); + + } // if protocol is file + else { + // protocol was not file: + uriString = ((URI)source).toString(); + } + } + catch(ClassCastException | URISyntaxException e) { + throw new PersistenceException(e); + } + } + + @Override + public Object createObject() + throws PersistenceException, ResourceInstantiationException { + // TODO Auto-generated method stub + return null; + } + + } + /** * URLs get upset when serialised and deserialised so we need to * convert them to strings for storage. @@ -198,6 +258,152 @@ * from the original source object. */ static final Logger logger = Logger.getLogger(URLHolder.class); + + public static String relativize(File outFile, File urlFile) throws URISyntaxException { + + File outFileReal = getCanonicalFileIfPossible(outFile); + File urlFileReal = getCanonicalFileIfPossible(urlFile); + // Note: the outDir will be correct if the application file itself is not a link + // If the application file is a link than its parent is the parent of the real + // path. + File outDir = outFile.getParentFile(); + File outDirReal = getCanonicalFileIfPossible(outDir); + File outDirOfReal = getCanonicalFileIfPossible(outFileReal.getParentFile()); + + + logger.debug("urlFile="+urlFile+", urlFileReal"+urlFileReal); + logger.debug("outDir="+outDir+", outDirReal"+outDirReal); + + // by default, use just the relative path + String pathMarker = relativePathMarker; + + // - this returns the canonical path to GATE_HOME + File gateHomePathReal = getGateHomePath(); + + // get the canonical path of the resources home directory, if set, otherwise null + File resourceshomeDirReal = getResourceshomePath(); + + // Only if we actually *want* to consider GATE_HOME and other special directories, + // do all of this ... + // Note: the semantics of this has slightly changed to what it was before: we only + // do this is the use gatehome flag is set, not if it is not set but the warn flag + // is set (previsouly, the warn flag alone was sufficient too). + if(currentUseGateHome()) { + // First of all, check if we want to use GATE_HOME instead: this happens + // if the real location of the url is inside the real location of GATE_HOME + // and the location of the outfile is outside of GATE_HOME + + if (!isContainedWithin(outFileReal, gateHomePathReal) && + isContainedWithin(urlFileReal, gateHomePathReal)) { + logger.debug("Setting path marker to "+gatehomePathMarker); + if(currentWarnAboutGateHome()) { + if(!currentHaveWarnedAboutGateHome().getValue()) { + logger.warn( + "\nYour application is using some of the resources/plugins "+ + "distributed with GATE, and may not work as expected "+ + "with different versions of GATE. You should consider "+ + "making private local copies of the plug-ins, and "+ + "distributing those with your application."); + currentHaveWarnedAboutGateHome().setValue(true); + } + // the actual URL is shown every time + //logger.warn("GATE resource referenced: "+url); + } + if(currentUseGateHome()) { + pathMarker = gatehomePathMarker; + } + } else + // Otherwise, do the same check for the resources home path, but only if it + // is actuallys set + if(resourceshomeDirReal != null && + !isContainedWithin(outFileReal, resourceshomeDirReal) && + isContainedWithin(urlFileReal, resourceshomeDirReal)) { + if(currentWarnAboutGateHome()) { + if(!currentHaveWarnedAboutResourceshome().getValue()) { + logger.warn( + "\nYour application is using resources from your project "+ + "path at "+getResourceshomePath()+". Restoring the application "+ + "will only work if the same project path is set."); + currentHaveWarnedAboutResourceshome().setValue(true); + } + // the actual URL is shown every time + //logger.warn("Resource referenced: "+url); + } + if(currentUseGateHome()) { + pathMarker = resourceshomePathMarker; + } + + } + } + + String relPath = null; + + if(pathMarker.equals(relativePathMarker)) { + // In theory we should just relativize here using the original paths, without + // following any symbolic links. We do not want to follow symbolic links because + // somebody may want to use a symbolic link to a completely different location + // to include some resources into the project directory that contains the + // pipeline (and the link to the resource). + // However, if the project directory itself is within a linked location, then + // GATE will sometimes use the linked and sometimes the non-linked path + // (for some reason it uses the non-linked path in the plugin manager but it uses + // the linked path when the application file is choosen). This means that + // in those cases, there would be a large number of unwanted ../../../../some/dir/to/get/back + // If we solve this by using the canonical paths, it will do the wrong thing for + // links to resources. So we choose to make a compromise: if we can create a relative + // path that does not generate any ../ at the beginning of the relative part, then + // we use that, otherwise we use the real paths + + relPath = getRelativeFilePathString(outDir, urlFile); + logger.debug("First relative path string attempt got "+relPath); + if(relPath.startsWith("../")) { + // if we want to actually use the real path, we have to be careful which is the + // real parent of the out file: if outFile is a symbolic link then it is + // outDirOfReal otherwise it is outDirReal + logger.debug("upslength is "+upsLength(relPath)); + String tmpPath = relPath; + if(java.nio.file.Files.isSymbolicLink(outFile.toPath())) { + tmpPath = getRelativeFilePathString(outDirOfReal, urlFileReal); + logger.debug("trying outDirOfReal "+tmpPath); + logger.debug("upslength is "+upsLength(tmpPath)); + } else { + tmpPath = getRelativeFilePathString(outDirReal, urlFileReal); + logger.debug("trying outDirReal "+tmpPath); + logger.debug("upslength is "+upsLength(tmpPath)); + } + if(upsLength(tmpPath) < upsLength(relPath)) { + relPath = tmpPath; + } + logger.debug("Using tmpPath "+relPath); + } + // if we still get something that starts with ../ then our only remaining option is + // to find if a parent + } else if(pathMarker.equals(gatehomePathMarker)) { + relPath = getRelativeFilePathString(gateHomePathReal, urlFileReal); + } else if(pathMarker.equals(resourceshomePathMarker)) { + relPath = getRelativeFilePathString(resourceshomeDirReal, urlFileReal); + } else { + // this should really never happen! + throw new GateRuntimeException("Unexpected error when persisting URL "+urlFile); + } + + Path rel = Paths.get(relPath); + String uriPath = ""; + boolean first = true; + for(Path component : rel) { + if(!first) uriPath += "/"; + uriPath += component.toString(); + first = false; + } + if(urlFile.isDirectory()) { + // trailing slash + uriPath += "/"; + } + // construct the final properly encoded relative URI + URI finalRelUri = new URI(null, null, uriPath, null); + return pathMarker + finalRelUri.getRawPath(); + } + @Override public void extractDataFromSource(Object source) throws PersistenceException { @@ -221,149 +427,15 @@ // is the location to which we want to make the URL relative, unless we want to // use $gatehome$ or $resourceshome$ File outFile = currentPersistenceFile(); - File outFileReal = getCanonicalFileIfPossible(outFile); - // Note: the outDir will be correct if the application file itself is not a link - // If the application file is a link than its parent is the parent of the real - // path. - File outDir = outFile.getParentFile(); - File outDirReal = getCanonicalFileIfPossible(outDir); - File outDirOfReal = getCanonicalFileIfPossible(outFileReal.getParentFile()); + //File outFileReal = getCanonicalFileIfPossible(outFile); File urlFile = Files.fileFromURL(url); - File urlFileReal = getCanonicalFileIfPossible(urlFile); + //File urlFileReal = getCanonicalFileIfPossible(urlFile); logger.debug("Trying to persist "+url+" for "+outFile); - logger.debug("urlFile="+urlFile+", urlFileReal"+urlFileReal); - logger.debug("outDir="+outDir+", outDirReal"+outDirReal); - // by default, use just the relative path - String pathMarker = relativePathMarker; + urlString = relativize(outFile, urlFile); - // - this returns the canonical path to GATE_HOME - File gateHomePathReal = getGateHomePath(); - - // get the canonical path of the resources home directory, if set, otherwise null - File resourceshomeDirReal = getResourceshomePath(); - - // Only if we actually *want* to consider GATE_HOME and other special directories, - // do all of this ... - // Note: the semantics of this has slightly changed to what it was before: we only - // do this is the use gatehome flag is set, not if it is not set but the warn flag - // is set (previsouly, the warn flag alone was sufficient too). - if(currentUseGateHome()) { - // First of all, check if we want to use GATE_HOME instead: this happens - // if the real location of the url is inside the real location of GATE_HOME - // and the location of the outfile is outside of GATE_HOME - - if (!isContainedWithin(outFileReal, gateHomePathReal) && - isContainedWithin(urlFileReal, gateHomePathReal)) { - logger.debug("Setting path marker to "+gatehomePathMarker); - if(currentWarnAboutGateHome()) { - if(!currentHaveWarnedAboutGateHome().getValue()) { - logger.warn( - "\nYour application is using some of the resources/plugins "+ - "distributed with GATE, and may not work as expected "+ - "with different versions of GATE. You should consider "+ - "making private local copies of the plug-ins, and "+ - "distributing those with your application."); - currentHaveWarnedAboutGateHome().setValue(true); - } - // the actual URL is shown every time - logger.warn("GATE resource referenced: "+url); - } - if(currentUseGateHome()) { - pathMarker = gatehomePathMarker; - } - } else - // Otherwise, do the same check for the resources home path, but only if it - // is actuallys set - if(resourceshomeDirReal != null && - !isContainedWithin(outFileReal, resourceshomeDirReal) && - isContainedWithin(urlFileReal, resourceshomeDirReal)) { - if(currentWarnAboutGateHome()) { - if(!currentHaveWarnedAboutResourceshome().getValue()) { - logger.warn( - "\nYour application is using resources from your project "+ - "path at "+getResourceshomePath()+". Restoring the application "+ - "will only work if the same project path is set."); - currentHaveWarnedAboutResourceshome().setValue(true); - } - // the actual URL is shown every time - logger.warn("Resource referenced: "+url); - } - if(currentUseGateHome()) { - pathMarker = resourceshomePathMarker; - } - - } - } - - String relPath = null; - - if(pathMarker.equals(relativePathMarker)) { - // In theory we should just relativize here using the original paths, without - // following any symbolic links. We do not want to follow symbolic links because - // somebody may want to use a symbolic link to a completely different location - // to include some resources into the project directory that contains the - // pipeline (and the link to the resource). - // However, if the project directory itself is within a linked location, then - // GATE will sometimes use the linked and sometimes the non-linked path - // (for some reason it uses the non-linked path in the plugin manager but it uses - // the linked path when the application file is choosen). This means that - // in those cases, there would be a large number of unwanted ../../../../some/dir/to/get/back - // If we solve this by using the canonical paths, it will do the wrong thing for - // links to resources. So we choose to make a compromise: if we can create a relative - // path that does not generate any ../ at the beginning of the relative part, then - // we use that, otherwise we use the real paths - - relPath = getRelativeFilePathString(outDir, urlFile); - logger.debug("First relative path string attempt got "+relPath); - if(relPath.startsWith("../")) { - // if we want to actually use the real path, we have to be careful which is the - // real parent of the out file: if outFile is a symbolic link then it is - // outDirOfReal otherwise it is outDirReal - logger.debug("upslength is "+upsLength(relPath)); - String tmpPath = relPath; - if(java.nio.file.Files.isSymbolicLink(outFile.toPath())) { - tmpPath = getRelativeFilePathString(outDirOfReal, urlFileReal); - logger.debug("trying outDirOfReal "+tmpPath); - logger.debug("upslength is "+upsLength(tmpPath)); - } else { - tmpPath = getRelativeFilePathString(outDirReal, urlFileReal); - logger.debug("trying outDirReal "+tmpPath); - logger.debug("upslength is "+upsLength(tmpPath)); - } - if(upsLength(tmpPath) < upsLength(relPath)) { - relPath = tmpPath; - } - logger.debug("Using tmpPath "+relPath); - } - // if we still get something that starts with ../ then our only remaining option is - // to find if a parent - } else if(pathMarker.equals(gatehomePathMarker)) { - relPath = getRelativeFilePathString(gateHomePathReal, urlFileReal); - } else if(pathMarker.equals(resourceshomePathMarker)) { - relPath = getRelativeFilePathString(resourceshomeDirReal, urlFileReal); - } else { - // this should really never happen! - throw new GateRuntimeException("Unexpected error when persisting URL "+url); - } - - Path rel = Paths.get(relPath); - String uriPath = ""; - boolean first = true; - for(Path component : rel) { - if(!first) uriPath += "/"; - uriPath += component.toString(); - first = false; - } - if(urlFile.isDirectory()) { - // trailing slash - uriPath += "/"; - } - // construct the final properly encoded relative URI - URI finalRelUri = new URI(null, null, uriPath, null); - urlString = pathMarker + finalRelUri.getRawPath(); } // if protocol is file else { // protocol was not file: @@ -493,7 +565,7 @@ } - private File getGateHomePath() { + private static File getGateHomePath() { if(gatehomePath != null) { return gatehomePath; } else { @@ -502,7 +574,7 @@ } } - private File getResourceshomePath() { + private static File getResourceshomePath() { if(haveResourceshomePath == null) { String resourceshomeString = System.getProperty(resourceshomePropertyName); if(resourceshomeString == null) { @@ -521,7 +593,7 @@ } - private File getCanonicalFileIfPossible(File file) { + private static File getCanonicalFileIfPossible(File file) { if (file == null) return file; File tmp = file; try { @@ -544,7 +616,7 @@ * @param file the file we want to reference * @return the path appended to dir to get to file */ - private String getRelativeFilePathString(File dir, File file) { + private static String getRelativeFilePathString(File dir, File file) { Path dirPath = dir.toPath(); Path filePath = file.toPath(); try { @@ -561,7 +633,7 @@ return dirPath.relativize(filePath).toString(); } - private int upsLength(String path) { + private static int upsLength(String path) { Matcher m = goUpPattern.matcher(path); if(m.matches()) { return m.group(1).length(); @@ -1421,6 +1493,7 @@ registerPersistentEquivalent(VisualResource.class, SlashDevSlashNull.class); registerPersistentEquivalent(URL.class, URLHolder.class); + registerPersistentEquivalent(ResourceReference.class, RRPersistence.class); //for compatibility reasons we treat Plugins loaded from a directory URL as a URL registerPersistentEquivalent(Plugin.Directory.class, URLHolder.class); Modified: gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java =================================================================== --- gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-30 02:23:19 UTC (rev 20013) +++ gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-30 11:28:58 UTC (rev 20014) @@ -1,20 +1,25 @@ package gate.creole; +import java.io.File; import java.io.InputStream; import java.net.URI; import java.net.URL; import org.apache.commons.io.IOUtils; +import org.jdom.Content; import org.jdom.Document; import org.jdom.Element; import org.jdom.JDOMException; +import org.jdom.input.SAXBuilder; import gate.Factory; +import gate.FeatureMap; import gate.Gate; import gate.Resource; import gate.corpora.TestDocument; import gate.creole.metadata.CreoleParameter; import gate.creole.metadata.CreoleResource; +import gate.util.persistence.PersistenceManager; import junit.framework.TestCase; @SuppressWarnings("serial") @@ -23,7 +28,7 @@ private Plugin creolePlugin; @CreoleResource - public static class TestResource extends AbstractResource { + public static class TestResource extends AbstractProcessingResource { ResourceReference rr = null; @@ -189,7 +194,47 @@ } } - /*public void testPersistence() throws Exception { + public void testPersistence() throws Exception { - }*/ + Resource resource = null; + + File xgappFile = null; + File txtFile = null; + + try { + xgappFile = File.createTempFile("rr-test", ".xgapp"); + xgappFile.createNewFile(); + + txtFile = new File(xgappFile.getParentFile(),"test-file.txt"); + + FeatureMap params = Factory.newFeatureMap(); + params.put("param", new ResourceReference(txtFile.toURI())); + resource = Factory.createResource(TestResource.class.getName(),params); + + PersistenceManager.saveObjectToFile(resource, xgappFile); + + SAXBuilder builder = new SAXBuilder(); + Document doc = builder.build(xgappFile); + + Element entry = doc.getRootElement().getChild("application").getChild("initParams").getChild("localMap").getChild("entry"); + + assertEquals("couldn't find a param entry", "param",entry.getChildText("string")); + + Element value = entry.getChild("gate.util.persistence.PersistenceManager-RRPersistence"); + + assertNotNull("We couldn't find the RRPersistence wrapper",value); + + assertEquals("The URI was not as expected","$relpath$test-file.txt", value.getChildText("uriString")); + + } finally { + if (xgappFile != null) xgappFile.deleteOnExit(); + + if(resource != null) { + Factory.deleteResource(resource); + } + + + } + + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gat...@us...> - 2017-01-30 02:23:21
|
Revision: 20013 http://sourceforge.net/p/gate/code/20013 Author: gate-project Date: 2017-01-30 02:23:19 +0000 (Mon, 30 Jan 2017) Log Message: ----------- Build number update (build 5728) Modified Paths: -------------- gate/trunk/build/build.properties gate/trunk/build/build.txt Modified: gate/trunk/build/build.properties =================================================================== --- gate/trunk/build/build.properties 2017-01-29 15:56:26 UTC (rev 20012) +++ gate/trunk/build/build.properties 2017-01-30 02:23:19 UTC (rev 20013) @@ -1,4 +1,4 @@ #Build Number for ANT. Do not edit! -#Sun Jan 29 02:10:27 GMT 2017 +#Mon Jan 30 02:09:46 GMT 2017 cvs.version=$Id\: build.properties 7542 2006-07-17 14\:26\:51Z ian_roberts $ -build.number=5728 +build.number=5729 Modified: gate/trunk/build/build.txt =================================================================== --- gate/trunk/build/build.txt 2017-01-29 15:56:26 UTC (rev 20012) +++ gate/trunk/build/build.txt 2017-01-30 02:23:19 UTC (rev 20013) @@ -1 +1 @@ -5727 \ No newline at end of file +5728 \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2017-01-29 15:56:29
|
Revision: 20012 http://sourceforge.net/p/gate/code/20012 Author: johann_p Date: 2017-01-29 15:56:26 +0000 (Sun, 29 Jan 2017) Log Message: ----------- Change the current version of the LearningFramework to 3.5.4. This fixes a bug related to setting the pruning parameter for Mallet C45. Modified Paths: -------------- gate/trunk/build/deploy/plugins/gate-8.1.xml Modified: gate/trunk/build/deploy/plugins/gate-8.1.xml =================================================================== --- gate/trunk/build/deploy/plugins/gate-8.1.xml 2017-01-29 02:24:12 UTC (rev 20011) +++ gate/trunk/build/deploy/plugins/gate-8.1.xml 2017-01-29 15:56:26 UTC (rev 20012) @@ -20,8 +20,8 @@ downloadURL="https://github.com/johann-petrak/gateplugin-VirtualCorpus/releases/download/V0.16/VirtualCorpus-0.16.zip" /> <CreolePlugin - url="https://raw.githubusercontent.com/GateNLP/gateplugin-LearningFramework/V3_5_3/" - downloadURL="https://github.com/GateNLP/gateplugin-LearningFramework/releases/download/V3_5_3/gateplugin-LearningFramework-3.5.3.zip" + url="https://raw.githubusercontent.com/GateNLP/gateplugin-LearningFramework/V3_5_4/" + downloadURL="https://github.com/GateNLP/gateplugin-LearningFramework/releases/download/V3_5_4/gateplugin-LearningFramework-3.5.4.zip" /> <CreolePlugin url="https://raw.githubusercontent.com/GateNLP/cloud-client/1.0.1/gate-plugin/src/assembly/" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gat...@us...> - 2017-01-29 02:24:14
|
Revision: 20011 http://sourceforge.net/p/gate/code/20011 Author: gate-project Date: 2017-01-29 02:24:12 +0000 (Sun, 29 Jan 2017) Log Message: ----------- Build number update (build 5727) Modified Paths: -------------- gate/trunk/build/build.properties gate/trunk/build/build.txt Modified: gate/trunk/build/build.properties =================================================================== --- gate/trunk/build/build.properties 2017-01-28 02:24:47 UTC (rev 20010) +++ gate/trunk/build/build.properties 2017-01-29 02:24:12 UTC (rev 20011) @@ -1,4 +1,4 @@ #Build Number for ANT. Do not edit! -#Sat Jan 28 02:11:34 GMT 2017 +#Sun Jan 29 02:10:27 GMT 2017 cvs.version=$Id\: build.properties 7542 2006-07-17 14\:26\:51Z ian_roberts $ -build.number=5727 +build.number=5728 Modified: gate/trunk/build/build.txt =================================================================== --- gate/trunk/build/build.txt 2017-01-28 02:24:47 UTC (rev 20010) +++ gate/trunk/build/build.txt 2017-01-29 02:24:12 UTC (rev 20011) @@ -1 +1 @@ -5726 \ No newline at end of file +5727 \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gat...@us...> - 2017-01-28 02:24:49
|
Revision: 20010 http://sourceforge.net/p/gate/code/20010 Author: gate-project Date: 2017-01-28 02:24:47 +0000 (Sat, 28 Jan 2017) Log Message: ----------- Build number update (build 5726) Modified Paths: -------------- gate/trunk/build/build.properties gate/trunk/build/build.txt Modified: gate/trunk/build/build.properties =================================================================== --- gate/trunk/build/build.properties 2017-01-27 23:59:28 UTC (rev 20009) +++ gate/trunk/build/build.properties 2017-01-28 02:24:47 UTC (rev 20010) @@ -1,4 +1,4 @@ #Build Number for ANT. Do not edit! -#Fri Jan 27 02:10:16 GMT 2017 +#Sat Jan 28 02:11:34 GMT 2017 cvs.version=$Id\: build.properties 7542 2006-07-17 14\:26\:51Z ian_roberts $ -build.number=5726 +build.number=5727 Modified: gate/trunk/build/build.txt =================================================================== --- gate/trunk/build/build.txt 2017-01-27 23:59:28 UTC (rev 20009) +++ gate/trunk/build/build.txt 2017-01-28 02:24:47 UTC (rev 20010) @@ -1 +1 @@ -5725 \ No newline at end of file +5726 \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2017-01-27 23:59:30
|
Revision: 20009 http://sourceforge.net/p/gate/code/20009 Author: markagreenwood Date: 2017-01-27 23:59:28 +0000 (Fri, 27 Jan 2017) Log Message: ----------- delete resources after a test Modified Paths: -------------- gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java Modified: gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java =================================================================== --- gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-27 17:25:55 UTC (rev 20008) +++ gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-27 23:59:28 UTC (rev 20009) @@ -21,7 +21,7 @@ public class TestResourceReference extends TestCase { private Plugin creolePlugin; - + @CreoleResource public static class TestResource extends AbstractResource { @@ -58,10 +58,10 @@ Document doc = new Document(); Element element = null; doc.addContent(element = new Element("CREOLE-DIRECTORY")); - + element.addContent(element = new Element("CREOLE")); element.addContent(element = new Element("RESOURCE")); - Element classElement = new Element("CLASS"); + Element classElement = new Element("CLASS"); classElement.setText(TestResource.class.getName()); element.addContent(classElement); return doc; @@ -168,15 +168,28 @@ } public void testDefaultValue() throws Exception { - - Resource resource = Factory.createResource(TestResource.class.getName()); - - ResourceReference rr = (ResourceReference)resource.getParameterValue("param"); - - assertNotNull("ResourceReference param should not be null", rr); - - assertEquals("References do not match", new URI("creole://group;artifact;version/resources/file.txt"), - rr.toURI()); - + + Resource resource = null; + + try { + resource = Factory.createResource(TestResource.class.getName()); + + ResourceReference rr = + (ResourceReference)resource.getParameterValue("param"); + + assertNotNull("ResourceReference param should not be null", rr); + + assertEquals("References do not match", + new URI("creole://group;artifact;version/resources/file.txt"), + rr.toURI()); + } finally { + if(resource != null) { + Factory.deleteResource(resource); + } + } } + + /*public void testPersistence() throws Exception { + + }*/ } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2017-01-27 17:25:57
|
Revision: 20008 http://sourceforge.net/p/gate/code/20008 Author: markagreenwood Date: 2017-01-27 17:25:55 +0000 (Fri, 27 Jan 2017) Log Message: ----------- default param values now resolve correctly against the base URI of the plugin Modified Paths: -------------- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Parameter.java gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Parameter.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Parameter.java 2017-01-27 14:21:39 UTC (rev 20007) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Parameter.java 2017-01-27 17:25:55 UTC (rev 20008) @@ -26,6 +26,7 @@ import java.io.Serializable; import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; +import java.net.URISyntaxException; import java.net.URL; import java.util.ArrayList; import java.util.Collection; @@ -259,6 +260,13 @@ } } } + else if (typeName.equals("gate.creole.ResourceReference")) { + try { + value = new ResourceReference(plugin, stringValue); + } catch(URISyntaxException e) { + throw new ParameterException("Malformed ResourceReference parameter value: "+stringValue,e); + } + } // java builtin types - for numeric types, we don't attempt to parse an // empty string value, but just leave value as null else if(typeName.startsWith("java.")) { @@ -286,7 +294,7 @@ value = Float.valueOf(stringValue); } } - else if(typeName.equals("java.net.URL")) + else if(typeName.equals("java.net.URL")) { try{ if(stringValue != null && !stringValue.equals("")) { value = new URL(plugin.getBaseURL(), stringValue); @@ -295,6 +303,7 @@ //value = null; throw new ParameterException("Malformed URL parameter value: "+stringValue,mue); } + } else{ //try to construct a new value from the string using a constructor // e.g. for URLs Modified: gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java =================================================================== --- gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-27 14:21:39 UTC (rev 20007) +++ gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-27 17:25:55 UTC (rev 20008) @@ -9,17 +9,34 @@ import org.jdom.Element; import org.jdom.JDOMException; +import gate.Factory; import gate.Gate; import gate.Resource; import gate.corpora.TestDocument; import gate.creole.metadata.CreoleParameter; +import gate.creole.metadata.CreoleResource; import junit.framework.TestCase; -@SuppressWarnings({"serial","unused"}) +@SuppressWarnings("serial") public class TestResourceReference extends TestCase { private Plugin creolePlugin; + + @CreoleResource + public static class TestResource extends AbstractResource { + ResourceReference rr = null; + + public ResourceReference getParam() { + return rr; + } + + @CreoleParameter(defaultValue = "resources/file.txt") + public void setParam(ResourceReference rr) { + this.rr = rr; + } + } + @Override public void setUp() throws Exception { // Initialise the GATE library and creole register @@ -39,11 +56,18 @@ @Override public Document getCreoleXML() throws Exception, JDOMException { Document doc = new Document(); - doc.addContent(new Element("CREOLE-DIRECTORY")); + Element element = null; + doc.addContent(element = new Element("CREOLE-DIRECTORY")); + + element.addContent(element = new Element("CREOLE")); + element.addContent(element = new Element("RESOURCE")); + Element classElement = new Element("CLASS"); + classElement.setText(TestResource.class.getName()); + element.addContent(classElement); return doc; } }; - + Gate.getCreoleRegister().registerPlugin(creolePlugin); } @@ -76,19 +100,8 @@ } public void testCreateFromURL() throws Exception { - Resource resource = new AbstractResource() { - ResourceReference rr = null; + Resource resource = new TestResource(); - public ResourceReference getParam() { - return rr; - } - - @CreoleParameter - public void setParam(ResourceReference rr) { - this.rr = rr; - } - }; - URL url = new URL("http://gate.ac.uk"); resource.setParameterValue("param", url); @@ -149,8 +162,21 @@ rr = new ResourceReference(new URI("http://gate.ac.uk"), path); assertEquals("String representations don't match (7)", path, rr.toString()); - + rr = new ResourceReference(creolePlugin, path); assertEquals("String representations don't match (8)", path, rr.toString()); } -} + + public void testDefaultValue() throws Exception { + + Resource resource = Factory.createResource(TestResource.class.getName()); + + ResourceReference rr = (ResourceReference)resource.getParameterValue("param"); + + assertNotNull("ResourceReference param should not be null", rr); + + assertEquals("References do not match", new URI("creole://group;artifact;version/resources/file.txt"), + rr.toURI()); + + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2017-01-27 14:21:41
|
Revision: 20007 http://sourceforge.net/p/gate/code/20007 Author: markagreenwood Date: 2017-01-27 14:21:39 +0000 (Fri, 27 Jan 2017) Log Message: ----------- make sure the name field gets set even during reloading from a xgapp Modified Paths: -------------- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Plugin.java Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Plugin.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Plugin.java 2017-01-27 14:18:12 UTC (rev 20006) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Plugin.java 2017-01-27 14:21:39 UTC (rev 20007) @@ -606,7 +606,7 @@ ModelBuilder modelBuilder = new DefaultModelBuilderFactory().newInstance(); Model model = modelBuilder.build(req).getEffectiveModel(); - + name = group+":"+artifact+":"+version; if (model.getName() != null && !model.getName().trim().equals("")) name = model.getName(); /*System.out.println(model.getOrganization().getName()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2017-01-27 14:18:14
|
Revision: 20006 http://sourceforge.net/p/gate/code/20006 Author: markagreenwood Date: 2017-01-27 14:18:12 +0000 (Fri, 27 Jan 2017) Log Message: ----------- all the plugin loading now passes around a Plugin instance rather than two URLs so that we can access any of the plugin info at any point Modified Paths: -------------- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/CreoleRegisterImpl.java gate/branches/sawdust2/gate-core/src/main/java/gate/creole/CreoleXmlHandler.java gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Parameter.java gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/creole/CreoleRegisterImpl.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/CreoleRegisterImpl.java 2017-01-27 14:17:24 UTC (rev 20005) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/creole/CreoleRegisterImpl.java 2017-01-27 14:18:12 UTC (rev 20006) @@ -277,7 +277,7 @@ // directory defines annotationHandler.createResourceElementsForDirInfo(jdomDoc); - processFullCreoleXmlTree(directoryUrl, creoleFileUrl, jdomDoc, + processFullCreoleXmlTree(plugin, jdomDoc, annotationHandler); } catch(IOException e) { throw (new GateException(e)); @@ -288,7 +288,7 @@ } // parseDirectory - private void processFullCreoleXmlTree(URL directoryUrl, URL creoleFileUrl, + private void processFullCreoleXmlTree(Plugin plugin, Document jdomDoc, CreoleAnnotationHandler annotationHandler) throws GateException, IOException, JDOMException { // now we can process any annotations on the new classes @@ -303,13 +303,12 @@ // finally, parse the augmented definition with the normal parser DefaultHandler handler = - new CreoleXmlHandler(this, directoryUrl, creoleFileUrl); + new CreoleXmlHandler(this, plugin); SAXOutputter outputter = new SAXOutputter(handler, handler, handler, handler); outputter.output(jdomDoc); if(DEBUG) { - Out.prln("done parsing " - + ((directoryUrl == null) ? "null" : directoryUrl.toString())); + Out.prln("done parsing " + plugin); } } Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/creole/CreoleXmlHandler.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/CreoleXmlHandler.java 2017-01-27 14:17:24 UTC (rev 20005) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/creole/CreoleXmlHandler.java 2017-01-27 14:18:12 UTC (rev 20006) @@ -90,14 +90,11 @@ /** Debug flag */ private static final boolean DEBUG = false; - - /** The source URL of the directory file being parsed. */ - private URL sourceUrl; /** - * The URL to the creole.xml file being parsed. + * The plugin currently being loaded */ - private URL creoleFileUrl; + private Plugin plugin; /** This object indicates what to do when the parser encounts an error*/ private SimpleErrorHandler _seh = new SimpleErrorHandler(); @@ -120,12 +117,12 @@ private boolean readCharacterStatus = false; /** Construction */ - public CreoleXmlHandler(CreoleRegister register, URL directoryUrl, - URL creoleFileUrl) { + public CreoleXmlHandler(CreoleRegister register, Plugin plugin) { this.register = register; - this.sourceUrl = directoryUrl; - this.creoleFileUrl = creoleFileUrl; - currentParam = new Parameter(this.creoleFileUrl); + this.plugin = plugin; + //this.sourceUrl = directoryUrl; + //this.creoleFileUrl = creoleFileUrl; + currentParam = new Parameter(plugin); } // construction /** The register object that we add ResourceData objects to during parsing. @@ -315,7 +312,15 @@ ); //set the URL to the creole.xml file on the resource data object - resourceData.setXmlFileUrl(creoleFileUrl); + //TODO should this be a URI instead of the URL? + try { + resourceData.setXmlFileUrl(new URL(plugin.getBaseURL(), "creole.xml")); + } + catch (MalformedURLException e) { + throw new GateSaxException( + "Couldn't load autoloading resource: " + + resourceData.getName() + "; problem was: " + e,e); + } // add the new resource data object to the creole register register.put(resourceData.getClassName(), resourceData); // if the resource is auto-loading, try and load it @@ -441,8 +446,8 @@ } // add jar file URL if there is one - if(sourceUrl != null) { - String sourceUrlName = sourceUrl.toExternalForm(); + //if(sourceUrl != null) { + String sourceUrlName = plugin.getBaseURL().toExternalForm(); String separator = "/"; if(sourceUrlName.endsWith(separator)) @@ -460,7 +465,7 @@ } catch(MalformedURLException e) { throw new GateSaxException("bad URL " + jarFileUrl + e); }// End try - }// End if + //}// End if // End JAR processing ////////////////////////////////////////////////////////////////// } else if(elementName.toUpperCase().equals("CLASS")) { @@ -516,7 +521,7 @@ paramList.add(currentParam); if(DEBUG) Out.prln("added param: " + currentParam); - currentParam = new Parameter(creoleFileUrl); + currentParam = new Parameter(plugin); // End PARAMETER processing ////////////////////////////////////////////////////////////////// } else if(elementName.toUpperCase().equals("AUTOLOAD")) { Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Parameter.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Parameter.java 2017-01-27 14:17:24 UTC (rev 20005) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/creole/Parameter.java 2017-01-27 14:18:12 UTC (rev 20006) @@ -53,8 +53,12 @@ * this parameter belongs to. This will be used a context when deriving * default values for the parameters of type URL. */ - public Parameter(URL baseUrl){ + /*public Parameter(URL baseUrl){ this.baseURL = baseUrl; + }*/ + + public Parameter(Plugin plugin) { + this.plugin = plugin; } /** The type name of the parameter */ @@ -285,7 +289,7 @@ else if(typeName.equals("java.net.URL")) try{ if(stringValue != null && !stringValue.equals("")) { - value = new URL(baseURL, stringValue); + value = new URL(plugin.getBaseURL(), stringValue); } }catch(MalformedURLException mue){ //value = null; @@ -392,7 +396,10 @@ * belongs to. It is used for deriving default values for parameters of type * {@link URL}. */ - protected URL baseURL; + //protected URL baseURL; + + protected Plugin plugin; + /** Set runtime status of this parameter */ public void setRuntime(boolean runtime) { this.runtime = runtime; } Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java 2017-01-27 14:17:24 UTC (rev 20005) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java 2017-01-27 14:18:12 UTC (rev 20006) @@ -38,13 +38,12 @@ public ResourceReference(Plugin plugin, String path) throws URISyntaxException { - if (plugin != null) { + if(plugin != null) { uri = plugin.getBaseURI().resolve(path); - } - else { + } else { uri = new URI(path); } - + if(!uri.isAbsolute()) throw new URISyntaxException(path, "Context is null and path is not absolute"); @@ -52,26 +51,32 @@ public ResourceReference(URL context, String path) throws URISyntaxException, MalformedURLException { - + + // not sure if we need this constructor as we could just assume people can + // do the right thing before calling the constructor + uri = new URI(path); - + if(context != null && !uri.isAbsolute()) { uri = (new URL(context, path)).toURI(); } - + if(!uri.isAbsolute()) throw new URISyntaxException(path, "Context is null and path is not absolute"); } - public ResourceReference(URI context, String path) throws URISyntaxException { - if (context != null) { + public ResourceReference(URI context, String path) throws URISyntaxException { + + // not sure if we need this constructor as we could just assume people can + // do the right thing before calling the constructor + + if(context != null) { uri = context.resolve(path); - } - else { + } else { uri = new URI(path); } - + if(!uri.isAbsolute()) throw new URISyntaxException(path, "Context is null and path is not absolute"); @@ -79,13 +84,12 @@ public ResourceReference(ResourceReference context, String path) throws IOException, URISyntaxException { - if (context != null) { + if(context != null) { uri = context.uri.resolve(path); - } - else { + } else { uri = new URI(path); } - + if(!uri.isAbsolute()) throw new URISyntaxException(path, "Context is null and path is not absolute"); @@ -128,6 +132,7 @@ return uri; } + @Override public String toString() { return uri.toString(); } Modified: gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java =================================================================== --- gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-27 14:17:24 UTC (rev 20005) +++ gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-27 14:18:12 UTC (rev 20006) @@ -20,7 +20,6 @@ private Plugin creolePlugin; - @Override public void setUp() throws Exception { // Initialise the GATE library and creole register This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2017-01-27 14:17:27
|
Revision: 20005 http://sourceforge.net/p/gate/code/20005 Author: markagreenwood Date: 2017-01-27 14:17:24 +0000 (Fri, 27 Jan 2017) Log Message: ----------- not sure if this need rebuilding or not Modified Paths: -------------- gate/branches/sawdust2/gate-core/bin/gateLauncher.jar Modified: gate/branches/sawdust2/gate-core/bin/gateLauncher.jar =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2017-01-27 12:35:04
|
Revision: 20004 http://sourceforge.net/p/gate/code/20004 Author: markagreenwood Date: 2017-01-27 12:35:02 +0000 (Fri, 27 Jan 2017) Log Message: ----------- some cleanup Modified Paths: -------------- gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java Modified: gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java =================================================================== --- gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-27 12:33:01 UTC (rev 20003) +++ gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-27 12:35:02 UTC (rev 20004) @@ -15,10 +15,12 @@ import gate.creole.metadata.CreoleParameter; import junit.framework.TestCase; +@SuppressWarnings({"serial","unused"}) public class TestResourceReference extends TestCase { private Plugin creolePlugin; + @Override public void setUp() throws Exception { // Initialise the GATE library and creole register @@ -95,7 +97,6 @@ ((ResourceReference)resource.getParameterValue("param")).toURL()); } - @SuppressWarnings("serial") public void testRelativeReferences() throws Exception { URL testURL = new URL(TestDocument.getTestServerName() + "tests/"); URL creoleURL = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2017-01-27 12:33:04
|
Revision: 20003 http://sourceforge.net/p/gate/code/20003 Author: markagreenwood Date: 2017-01-27 12:33:01 +0000 (Fri, 27 Jan 2017) Log Message: ----------- changed the test name to make it more accurate Modified Paths: -------------- gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java Modified: gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java =================================================================== --- gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-27 12:30:10 UTC (rev 20002) +++ gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-27 12:33:01 UTC (rev 20003) @@ -125,7 +125,7 @@ assertEquals("URLs do not match (4)", creoleURL, rr.toURL()); } - public void testCreateFromString() throws Exception { + public void testCreateFromAbsolutePath() throws Exception { String path = "creole://group;artifact;version/test-file.xml"; ResourceReference rr = new ResourceReference((ResourceReference)null, path); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2017-01-27 12:30:12
|
Revision: 20002 http://sourceforge.net/p/gate/code/20002 Author: markagreenwood Date: 2017-01-27 12:30:10 +0000 (Fri, 27 Jan 2017) Log Message: ----------- you can now create an instance using an absolute path even if you supply a valid context Modified Paths: -------------- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java 2017-01-27 09:25:49 UTC (rev 20001) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java 2017-01-27 12:30:10 UTC (rev 20002) @@ -53,10 +53,10 @@ public ResourceReference(URL context, String path) throws URISyntaxException, MalformedURLException { - if(context != null) { + uri = new URI(path); + + if(context != null && !uri.isAbsolute()) { uri = (new URL(context, path)).toURI(); - } else { - uri = new URI(path); } if(!uri.isAbsolute()) Modified: gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java =================================================================== --- gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-27 09:25:49 UTC (rev 20001) +++ gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-27 12:30:10 UTC (rev 20002) @@ -17,116 +17,140 @@ public class TestResourceReference extends TestCase { - @Override - public void setUp() throws Exception { - // Initialise the GATE library and creole register - Gate.init(); - } + private Plugin creolePlugin; - public void testReadFromURL() throws Exception { + @Override + public void setUp() throws Exception { + // Initialise the GATE library and creole register + Gate.init(); - URL url = getClass().getClassLoader().getResource("gate/resources/gate.ac.uk/creole/creole.xml"); - ResourceReference rr = new ResourceReference(url); + creolePlugin = new Plugin.Maven("group", "artifact", "version") { - try (InputStream in = rr.openStream()) { - String contents = IOUtils.toString(in); + @Override + public URL getBaseURL() { + try { + return new URL(TestDocument.getTestServerName() + "tests/"); + } catch(Exception e) { + throw new RuntimeException(e); + } + } - assertEquals("Length of data read not as expected", 98, contents.length()); - } - } + @Override + public Document getCreoleXML() throws Exception, JDOMException { + Document doc = new Document(); + doc.addContent(new Element("CREOLE-DIRECTORY")); + return doc; + } + }; + + Gate.getCreoleRegister().registerPlugin(creolePlugin); + } - public void testReadFromURLPlugin() throws Exception { - // find a URL for finding test files and add to the directory set - URL testURL = new URL(TestDocument.getTestServerName() + "tests/"); - Plugin p = new Plugin.Directory(testURL); - ResourceReference rr = new ResourceReference(p, "gate.xml"); + public void testReadFromURL() throws Exception { - try (InputStream in = rr.openStream()) { - String contents = IOUtils.toString(in); + URL url = getClass().getClassLoader() + .getResource("gate/resources/gate.ac.uk/creole/creole.xml"); + ResourceReference rr = new ResourceReference(url); - assertEquals("Length of data read not as expected", 658, contents.length()); - } - } - - public void testCreateFromURL() throws Exception { - Resource resource = new AbstractResource() { - ResourceReference rr = null; - - public ResourceReference getParam() { - return rr; - } - - @CreoleParameter - public void setParam(ResourceReference rr) { - this.rr = rr; - } - }; - - URL url = new URL("http://gate.ac.uk"); - resource.setParameterValue("param", url); - - assertEquals("References do not match", url, ((ResourceReference)resource.getParameterValue("param")).toURL()); - } - - @SuppressWarnings("serial") + try (InputStream in = rr.openStream()) { + String contents = IOUtils.toString(in); + + assertEquals("Length of data read not as expected", 98, + contents.length()); + } + } + + public void testReadFromURLPlugin() throws Exception { + // find a URL for finding test files and add to the directory set + URL testURL = new URL(TestDocument.getTestServerName() + "tests/"); + Plugin p = new Plugin.Directory(testURL); + ResourceReference rr = new ResourceReference(p, "gate.xml"); + + try (InputStream in = rr.openStream()) { + String contents = IOUtils.toString(in); + + assertEquals("Length of data read not as expected", 658, + contents.length()); + } + } + + public void testCreateFromURL() throws Exception { + Resource resource = new AbstractResource() { + ResourceReference rr = null; + + public ResourceReference getParam() { + return rr; + } + + @CreoleParameter + public void setParam(ResourceReference rr) { + this.rr = rr; + } + }; + + URL url = new URL("http://gate.ac.uk"); + resource.setParameterValue("param", url); + + assertEquals("References do not match", url, + ((ResourceReference)resource.getParameterValue("param")).toURL()); + } + + @SuppressWarnings("serial") public void testRelativeReferences() throws Exception { - URL testURL = new URL(TestDocument.getTestServerName() + "tests/"); - URL creoleURL = new URL(TestDocument.getTestServerName() + "tests/creole.xml"); - - ResourceReference rr = new ResourceReference(testURL,"./creole.xml"); - assertEquals("References do not match (1)", creoleURL, rr.toURL()); - - ResourceReference context = new ResourceReference(testURL); - rr = new ResourceReference(context,"./creole.xml"); - assertEquals("References do not match (2)", creoleURL, rr.toURL()); - - Plugin plugin = new Plugin.Directory(testURL); - context = new ResourceReference(plugin,"abc"); - rr = new ResourceReference(context,"./creole.xml"); - assertEquals("References do not match (3)", creoleURL, rr.toURL()); - - context = new ResourceReference(plugin,"html/"); - rr = new ResourceReference(context,"../creole.xml"); - assertEquals("References do not match (3)", creoleURL, rr.toURL()); - - URI creoleURI = new URI("creole://group;artifact;version/creole.xml"); - plugin = new Plugin.Maven("group", "artifact", "version") { - - @Override - public URL getBaseURL() { - return testURL; - } - - @Override - public Document getCreoleXML() throws Exception, JDOMException { - Document doc = new Document(); - doc.addContent(new Element("CREOLE-DIRECTORY")); - return doc; - } - }; - - Gate.getCreoleRegister().registerPlugin(plugin); - context = new ResourceReference(plugin,"folder/"); - rr = new ResourceReference(context,"../creole.xml"); - assertEquals("References do not match (4)", creoleURI, rr.toURI()); - assertEquals("URLs do not match (4)", creoleURL, rr.toURL()); - } - - public void testCreateFromString() throws Exception { - String path = "creole://group;artifact;version/creole.xml"; - - ResourceReference rr = new ResourceReference((ResourceReference)null, path); - assertEquals("String representations don't match (1)",path, rr.toString()); - - rr = new ResourceReference((URL)null, path); - assertEquals("String representations don't match (2)",path, rr.toString()); - + URL testURL = new URL(TestDocument.getTestServerName() + "tests/"); + URL creoleURL = + new URL(TestDocument.getTestServerName() + "tests/creole.xml"); + + ResourceReference rr = new ResourceReference(testURL, "./creole.xml"); + assertEquals("References do not match (1)", creoleURL, rr.toURL()); + + ResourceReference context = new ResourceReference(testURL); + rr = new ResourceReference(context, "./creole.xml"); + assertEquals("References do not match (2)", creoleURL, rr.toURL()); + + Plugin plugin = new Plugin.Directory(testURL); + context = new ResourceReference(plugin, "abc"); + rr = new ResourceReference(context, "./creole.xml"); + assertEquals("References do not match (3)", creoleURL, rr.toURL()); + + context = new ResourceReference(plugin, "html/"); + rr = new ResourceReference(context, "../creole.xml"); + assertEquals("References do not match (3)", creoleURL, rr.toURL()); + + URI creoleURI = new URI("creole://group;artifact;version/creole.xml"); + + context = new ResourceReference(creolePlugin, "folder/"); + rr = new ResourceReference(context, "../creole.xml"); + assertEquals("References do not match (4)", creoleURI, rr.toURI()); + assertEquals("URLs do not match (4)", creoleURL, rr.toURL()); + } + + public void testCreateFromString() throws Exception { + String path = "creole://group;artifact;version/test-file.xml"; + + ResourceReference rr = new ResourceReference((ResourceReference)null, path); + assertEquals("String representations don't match (1)", path, rr.toString()); + + rr = new ResourceReference((URL)null, path); + assertEquals("String representations don't match (2)", path, rr.toString()); + rr = new ResourceReference((URI)null, path); - assertEquals("String representations don't match (3)",path, rr.toString()); - + assertEquals("String representations don't match (3)", path, rr.toString()); + rr = new ResourceReference((Plugin)null, path); - assertEquals("String representations don't match (4)",path, rr.toString()); + assertEquals("String representations don't match (4)", path, rr.toString()); + + rr = new ResourceReference( + new ResourceReference(new URL("http://gate.ac.uk")), path); + assertEquals("String representations don't match (5)", path, rr.toString()); + + rr = new ResourceReference(new URL("http://gate.ac.uk"), path); + assertEquals("String representations don't match (6)", path, rr.toString()); + + rr = new ResourceReference(new URI("http://gate.ac.uk"), path); + assertEquals("String representations don't match (7)", path, rr.toString()); - - } + rr = new ResourceReference(creolePlugin, path); + assertEquals("String representations don't match (8)", path, rr.toString()); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2017-01-27 09:25:51
|
Revision: 20001 http://sourceforge.net/p/gate/code/20001 Author: markagreenwood Date: 2017-01-27 09:25:49 +0000 (Fri, 27 Jan 2017) Log Message: ----------- test creation from absolute uri with null context Modified Paths: -------------- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java Modified: gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java =================================================================== --- gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java 2017-01-27 02:24:36 UTC (rev 20000) +++ gate/branches/sawdust2/gate-core/src/main/java/gate/creole/ResourceReference.java 2017-01-27 09:25:49 UTC (rev 20001) @@ -38,21 +38,57 @@ public ResourceReference(Plugin plugin, String path) throws URISyntaxException { - this(plugin.getBaseURI(), path); + if (plugin != null) { + uri = plugin.getBaseURI().resolve(path); + } + else { + uri = new URI(path); + } + + if(!uri.isAbsolute()) + throw new URISyntaxException(path, + "Context is null and path is not absolute"); } public ResourceReference(URL context, String path) throws URISyntaxException, MalformedURLException { - uri = (new URL(context, path)).toURI(); + + if(context != null) { + uri = (new URL(context, path)).toURI(); + } else { + uri = new URI(path); + } + + if(!uri.isAbsolute()) + throw new URISyntaxException(path, + "Context is null and path is not absolute"); } - public ResourceReference(URI context, String path) { - uri = context.resolve(path); + public ResourceReference(URI context, String path) throws URISyntaxException { + if (context != null) { + uri = context.resolve(path); + } + else { + uri = new URI(path); + } + + if(!uri.isAbsolute()) + throw new URISyntaxException(path, + "Context is null and path is not absolute"); } public ResourceReference(ResourceReference context, String path) throws IOException, URISyntaxException { - this(context.uri, path); + if (context != null) { + uri = context.uri.resolve(path); + } + else { + uri = new URI(path); + } + + if(!uri.isAbsolute()) + throw new URISyntaxException(path, + "Context is null and path is not absolute"); } public InputStream openStream() throws IOException { @@ -91,4 +127,12 @@ public URI toURI() throws URISyntaxException { return uri; } + + public String toString() { + return uri.toString(); + } + + public String toExternalForm() { + return toString(); + } } Modified: gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java =================================================================== --- gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-27 02:24:36 UTC (rev 20000) +++ gate/branches/sawdust2/gate-core/src/test/java/gate/creole/TestResourceReference.java 2017-01-27 09:25:49 UTC (rev 20001) @@ -111,4 +111,22 @@ assertEquals("References do not match (4)", creoleURI, rr.toURI()); assertEquals("URLs do not match (4)", creoleURL, rr.toURL()); } + + public void testCreateFromString() throws Exception { + String path = "creole://group;artifact;version/creole.xml"; + + ResourceReference rr = new ResourceReference((ResourceReference)null, path); + assertEquals("String representations don't match (1)",path, rr.toString()); + + rr = new ResourceReference((URL)null, path); + assertEquals("String representations don't match (2)",path, rr.toString()); + + rr = new ResourceReference((URI)null, path); + assertEquals("String representations don't match (3)",path, rr.toString()); + + rr = new ResourceReference((Plugin)null, path); + assertEquals("String representations don't match (4)",path, rr.toString()); + + + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |