|
From: <pe...@us...> - 2003-12-19 18:03:38
|
Update of /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/source
In directory sc8-pr-cvs1:/tmp/cvs-serv5310/src/java/org/neuclear/source
Modified Files:
CachedSource.java HttpSource.java Source.java
Added Files:
SourceException.java
Log Message:
Revamped a lot of exception handling throughout the framework, it has been simplified in most places:
- For most cases the main exception to worry about now is InvalidNamedObjectException.
- Most lowerlevel exception that cant be handled meaningful are now wrapped in the LowLevelException, a
runtime exception.
- Source and Store patterns each now have their own exceptions that generalizes the various physical
exceptions that can happen in that area.
--- NEW FILE: SourceException.java ---
package org.neuclear.source;
import org.neuclear.commons.NeuClearException;
/**
* Created by IntelliJ IDEA.
* User: pelleb
* Date: Dec 19, 2003
* Time: 9:59:44 AM
* To change this template use Options | File Templates.
*/
public class SourceException extends NeuClearException{
public SourceException(final Source source,final Throwable cause) {
super(cause);
this.source=source;
}
public SourceException(final Source source,final String message) {
super(message);
this.source=source;
}
public SourceException(final Source source,final String message, final Throwable cause) {
super(message, cause);
this.source=source;
}
private final Source source;
}
Index: CachedSource.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/source/CachedSource.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** CachedSource.java 9 Dec 2003 23:41:44 -0000 1.16
--- CachedSource.java 19 Dec 2003 18:03:35 -0000 1.17
***************
*** 3,6 ****
--- 3,14 ----
* $Id$
* $Log$
+ * Revision 1.17 2003/12/19 18:03:35 pelle
+ * Revamped a lot of exception handling throughout the framework, it has been simplified in most places:
+ * - For most cases the main exception to worry about now is InvalidNamedObjectException.
+ * - Most lowerlevel exception that cant be handled meaningful are now wrapped in the LowLevelException, a
+ * runtime exception.
+ * - Source and Store patterns each now have their own exceptions that generalizes the various physical
+ * exceptions that can happen in that area.
+ *
* Revision 1.16 2003/12/09 23:41:44 pelle
* IdentityCreator is now the default class of the uber jar.
***************
*** 124,127 ****
--- 132,136 ----
import org.neuclear.commons.NeuClearException;
import org.neuclear.id.NSTools;
+ import org.neuclear.id.InvalidNamedObjectException;
import java.io.*;
***************
*** 146,150 ****
! protected InputStream getStream(final String endpoint, final String name) throws NeuClearException {
final File object = new File(cachedirpath + NSTools.name2path(name) + "/root.id");
try {
--- 155,159 ----
! protected InputStream getStream(final String endpoint, final String name) throws SourceException, InvalidNamedObjectException {
final File object = new File(cachedirpath + NSTools.name2path(name) + "/root.id");
try {
***************
*** 165,169 ****
} catch (IOException e) {
// I have already checked for this but will wrap it anyhow.
! throw new NeuClearException(e);
}
--- 174,178 ----
} catch (IOException e) {
// I have already checked for this but will wrap it anyhow.
! throw new SourceException(this,e);
}
Index: HttpSource.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/source/HttpSource.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** HttpSource.java 8 Dec 2003 19:32:32 -0000 1.12
--- HttpSource.java 19 Dec 2003 18:03:35 -0000 1.13
***************
*** 8,11 ****
--- 8,19 ----
* $Id$
* $Log$
+ * Revision 1.13 2003/12/19 18:03:35 pelle
+ * Revamped a lot of exception handling throughout the framework, it has been simplified in most places:
+ * - For most cases the main exception to worry about now is InvalidNamedObjectException.
+ * - Most lowerlevel exception that cant be handled meaningful are now wrapped in the LowLevelException, a
+ * runtime exception.
+ * - Source and Store patterns each now have their own exceptions that generalizes the various physical
+ * exceptions that can happen in that area.
+ *
* Revision 1.12 2003/12/08 19:32:32 pelle
* Added support for the http scheme into ID. See http://neuclear.org/archives/000195.html
***************
*** 85,88 ****
--- 93,97 ----
import org.neuclear.id.NSTools;
import org.neuclear.id.SignedNamedObject;
+ import org.neuclear.id.InvalidNamedObjectException;
import java.io.InputStream;
***************
*** 110,114 ****
public final class HttpSource extends Source {
! protected final InputStream getStream(final String endpoint, final String name) throws NeuClearException {
try {
final String urlstring = endpoint + NSTools.name2path(name)+"/root.id";
--- 119,123 ----
public final class HttpSource extends Source {
! protected final InputStream getStream(final String endpoint, final String name) throws SourceException, InvalidNamedObjectException {
try {
final String urlstring = endpoint + NSTools.name2path(name)+"/root.id";
***************
*** 117,121 ****
return url.openStream();
} catch (java.io.IOException e) {
! throw new NeuClearException(e);
}
}
--- 126,130 ----
return url.openStream();
} catch (java.io.IOException e) {
! throw new SourceException(this,e);
}
}
Index: Source.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-id/src/java/org/neuclear/source/Source.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Source.java 4 Dec 2003 21:50:36 -0000 1.8
--- Source.java 19 Dec 2003 18:03:35 -0000 1.9
***************
*** 8,11 ****
--- 8,19 ----
* $Id$
* $Log$
+ * Revision 1.9 2003/12/19 18:03:35 pelle
+ * Revamped a lot of exception handling throughout the framework, it has been simplified in most places:
+ * - For most cases the main exception to worry about now is InvalidNamedObjectException.
+ * - Most lowerlevel exception that cant be handled meaningful are now wrapped in the LowLevelException, a
+ * runtime exception.
+ * - Source and Store patterns each now have their own exceptions that generalizes the various physical
+ * exceptions that can happen in that area.
+ *
* Revision 1.8 2003/12/04 21:50:36 pelle
* Mainly documentation changes.
***************
*** 74,77 ****
--- 82,87 ----
import org.neuclear.id.NSTools;
import org.neuclear.id.SignedNamedObject;
+ import org.neuclear.id.InvalidNamedObjectException;
+ import org.neuclear.id.NameResolutionException;
import org.neuclear.id.verifier.VerifyingReader;
import org.neuclear.xml.XMLException;
***************
*** 103,122 ****
* @param name
* @return
- * @throws NeuClearException
*/
! public final SignedNamedObject fetch(final String endpoint, String name) throws NeuClearException {
! try {
! name = NSTools.normalizeNameURI(name);
! SignedNamedObject candidate = (SignedNamedObject) cache.get(name);
! if (candidate != null)
! return candidate;
!
! candidate = VerifyingReader.getInstance().read(getStream(endpoint, name));
! if (candidate != null)
! storeInCache(candidate);
return candidate;
! } catch (XMLException e) {
! throw new NeuClearException(e);
! }
}
--- 113,127 ----
* @param name
* @return
*/
! public final SignedNamedObject fetch(final String endpoint, String name) throws SourceException, InvalidNamedObjectException, NameResolutionException {
! name = NSTools.normalizeNameURI(name);
! SignedNamedObject candidate = (SignedNamedObject) cache.get(name);
! if (candidate != null)
return candidate;
!
! candidate = VerifyingReader.getInstance().read(getStream(endpoint, name));
! if (candidate != null)
! storeInCache(candidate);
! return candidate;
}
***************
*** 128,136 ****
* @return
*/
! protected InputStream getStream(final String endpoint, final String name) throws NeuClearException {
return null;
}
! private void storeInCache(final SignedNamedObject obj) throws NeuClearException {
cache.put(obj.getName(), obj);
}
--- 133,141 ----
* @return
*/
! protected InputStream getStream(final String endpoint, final String name) throws SourceException, InvalidNamedObjectException {
return null;
}
! private void storeInCache(final SignedNamedObject obj) {
cache.put(obj.getName(), obj);
}
|