Revision: 2000
Author: [email protected]
Date: Fri Aug 13 01:32:28 2010
Log: Added property for location on disk to store project files that have been submitted to Simal. Also some minor exception flow improvements. (Issue 337)
http://code.google.com/p/simal/source/detail?r=2000

Modified:
/trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/SimalProperties.java /trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/rdf/io/RDFXMLUtils.java /trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/service/jena/JenaProjectService.java /trunk/uk.ac.osswatch.simal.core/src/main/resources/default.simal.properties

=======================================
--- /trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/SimalProperties.java Thu Jun 10 05:57:08 2010 +++ /trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/SimalProperties.java Fri Aug 13 01:32:28 2010
@@ -40,6 +40,7 @@
private static final String DEFAULT_PROPERTIES_FILE = "default.simal.properties";

public static final String PROPERTY_RDF_DATA_DIR = "simal.repository.dir"; + public static final String PROPERTY_RDF_BACKUP_DIR = "simal.repository.backup.dir"; public static final String PROPERTY_RDF_DATA_FILENAME = "simal.repository.filename";
   public static final String PROPERTY_TEST = "simal.test";
public static final String PROPERTY_SIMAL_INSTANCE_ID = "simal.instance.id";
@@ -179,23 +180,13 @@
    * @param key
    * @param default
    * @return
-   * @throws SimalRepositoryException
-   *           if the properties cannot be initialised
    */
-  public static String getProperty(String key, String defaultValue)
-      throws SimalRepositoryException {
-    // FIXME We shouldn't be throwing Exceptions when the caller can supply
-    // a sensible default value.
+  public static String getProperty(String key, String defaultValue) {
     if (defaultProps == null) {
       try {
         initProperties();
       } catch (SimalRepositoryException e) {
-        if (defaultValue != null) {
-          return defaultValue;
-        } else {
-          throw new SimalRepositoryException(
-              "Unable to load configuration file", e);
-        }
+        return defaultValue;
       }
     }

@@ -210,14 +201,24 @@

     if (value == null) {
       if (key.equals(PROPERTY_SIMAL_INSTANCE_ID)) {
-        if (SimalRepositoryFactory.getInstance().isTest()) {
-          value = "simal:test";
-        } else {
+        try {
+          if (SimalRepositoryFactory.getInstance().isTest()) {
+            value = "simal:test";
+          } else {
+            value = UUID.randomUUID().toString();
+          }
+        } catch (SimalRepositoryException e) {
           value = UUID.randomUUID().toString();
         }
         setProperty(PROPERTY_SIMAL_INSTANCE_ID, value);
       } else if (key.equals(PROPERTY_RDF_DATA_DIR)) {
         value = System.getProperty("user.dir");
+      } else if (key.equals(PROPERTY_RDF_BACKUP_DIR)) {
+        value = System.getProperty("user.dir");
+        if(!value.endsWith(File.separator)) {
+          value += File.separator;
+        }
+        value += "backup";
       } else {
         StringBuilder sb = new StringBuilder("The property '");
         sb.append(key);
=======================================
--- /trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/rdf/io/RDFXMLUtils.java Mon Jun 7 06:47:17 2010 +++ /trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/rdf/io/RDFXMLUtils.java Fri Aug 13 01:32:28 2010
@@ -79,11 +79,13 @@
domResult = builder.parse(new InputSource(new StringReader(xmlSource)));
       } catch (ParserConfigurationException e) {
LOGGER.warn("Unexpected ParserConfigurationException: " + e.getMessage(),e);
+        throw new SimalException("Invalid configuration", e);
       } catch (SAXException e) {
         LOGGER.warn("Unexpected SAXException: " + e.getMessage(),e);
throw new SimalException("Tried to create DOM Document from invalid XML", e);
       } catch (IOException e) {
         LOGGER.warn("Unexpected IOException: " + e.getMessage(),e);
+ throw new SimalException("IOException when trying to parse xml source.", e);
       }
     }
     return domResult;
=======================================
--- /trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/service/jena/JenaProjectService.java Fri Jun 4 04:48:47 2010 +++ /trunk/uk.ac.osswatch.simal.core/src/main/java/uk/ac/osswatch/simal/service/jena/JenaProjectService.java Fri Aug 13 01:32:28 2010
@@ -436,6 +436,10 @@
         throws SimalRepositoryException {
// Strip any extra XML, such as Atom feed data or web services response
       // data
+      if (sourceXml == null) {
+ throw new SimalRepositoryException("Supplied RDF/XML document is null.");
+      }
+
       IProject newProject = null;
NodeList projects = sourceXml.getElementsByTagNameNS(RDFUtils.DOAP_NS,
           "Project");
=======================================
--- /trunk/uk.ac.osswatch.simal.core/src/main/resources/default.simal.properties Fri Jun 11 11:08:11 2010 +++ /trunk/uk.ac.osswatch.simal.core/src/main/resources/default.simal.properties Fri Aug 13 01:32:28 2010
@@ -15,6 +15,9 @@
 simal.version=0.2.5-SNAPSHOT
 simal.test=false
#simal.repository.dir=[the directory in which to store the simal repository, defaults to user.dir]
+
+#simal.repository.backup.dir=[the directory to backup the repository, defaults to user.dir/backup]
+simal.repository.backup.dir=backup
 simal.repository.filename=simal
 simal.doap.filestore=simalDOAPFilestore
 # Database type; one of RDB, SDB, TDB

--
You received this message because you are subscribed to the Google Groups "Simal 
Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/simal-commits?hl=en.

Reply via email to