Author: ross.gardler
Date: Fri Sep 12 17:01:11 2008
New Revision: 1308

Modified:
     
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/ToolsPage.java
     
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/data/DetachableCategoryModel.java
     
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/data/DetachablePersonModel.java
     
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/data/DetachableProjectModel.java
     
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/doap/CategoryDetailPage.java
     
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/doap/ExhibitProjectBrowserPage.java
     
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/foaf/PersonBrowserPage.java
     
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/markup/html/repeater/data/table/LinkPropertyColumn.java

Log:
@refactor use REST API for all people as JSON
@refactor remove some findbugs and pmd warnings

Modified:  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/ToolsPage.java
==============================================================================
---  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/ToolsPage.java
  
(original)
+++  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/ToolsPage.java
  
Fri Sep 12 17:01:11 2008
@@ -1,4 +1,5 @@
  package uk.ac.osswatch.simal.wicket;
+
  /*
   * Copyright 2008 University of Oxford
   *
@@ -16,7 +17,6 @@
   * under the License.                                                *
   */

-
  import java.io.File;
  import java.io.FileWriter;
  import java.io.IOException;
@@ -45,26 +45,33 @@
    private static final Logger logger =  
LoggerFactory.getLogger(ToolsPage.class);

    public ToolsPage() {
-
+
      // Repository Stats
      try {
-      add(new Label("numOfProjects",  
Integer.toString(UserApplication.getRepository().getAllProjects().size())));
-      add(new Label("numOfPeople",  
Integer.toString(UserApplication.getRepository().getAllPeople().size())));
-      add(new Label("numOfCategories",  
Integer.toString(UserApplication.getRepository().getAllCategories().size())));
+      add(new Label("numOfProjects", Integer.toString(UserApplication
+          .getRepository().getAllProjects().size())));
+      add(new Label("numOfPeople", Integer.toString(UserApplication
+          .getRepository().getAllPeople().size())));
+      add(new Label("numOfCategories", Integer.toString(UserApplication
+          .getRepository().getAllCategories().size())));
      } catch (SimalRepositoryException e) {
-      UserReportableException error = new UserReportableException("Unable  
to get repository statistics", ToolsPage.class, e);
+      UserReportableException error = new UserReportableException(
+          "Unable to get repository statistics", ToolsPage.class, e);
        setResponsePage(new ErrorReportPage(error));
      }
-
-    //Repository Config
+
+    // Repository Config
      try {
-      add(new Label("instanceID",  
SimalProperties.getProperty(SimalProperties.PROPERTY_SIMAL_INSTANCE_ID)));
-      add(new Label("propertiesFile",  
SimalProperties.getLocalPropertiesFile().toString()));
+      add(new Label("instanceID", SimalProperties
+          .getProperty(SimalProperties.PROPERTY_SIMAL_INSTANCE_ID)));
+      add(new Label("propertiesFile",  
SimalProperties.getLocalPropertiesFile()
+          .toString()));
      } catch (SimalRepositoryException e) {
-      UserReportableException error = new UserReportableException("Unable  
to get repository configuration data", ToolsPage.class, e);
+      UserReportableException error = new UserReportableException(
+          "Unable to get repository configuration data", ToolsPage.class,  
e);
        setResponsePage(new ErrorReportPage(error));
      }
-
+
      add(new Link("removeAllData") {

        public void onClick() {
@@ -88,7 +95,7 @@
          }
        }
      });
-
+
      add(new Link("importPTSWLink") {
        private static final long serialVersionUID = -6938957715376331902L;

@@ -102,20 +109,19 @@
        }
      });
    }
-
-

    /**
-   * Remove all data from the repository.
-   * @throws UserReportableException
+   * Remove all data from the repository.
+   *
+   * @throws UserReportableException
     */
    private void removeAllData() throws UserReportableException {
      ISimalRepository repo;
      try {
        repo = UserApplication.getRepository();
      } catch (SimalRepositoryException e) {
-      throw new UserReportableException(
-          "Unable to get the count of projects", ToolsPage.class, e);
+      throw new UserReportableException("Unable to get the count of  
projects",
+          ToolsPage.class, e);
      }
      repo.removeAllData();
    }
@@ -125,8 +131,8 @@
      try {
        repo = UserApplication.getRepository();
      } catch (SimalRepositoryException e) {
-      throw new UserReportableException(
-          "Unable to import test data", ToolsPage.class, e);
+      throw new UserReportableException("Unable to import test data",
+          ToolsPage.class, e);
      }
      ModelSupport.addTestData(repo);
    }
@@ -138,15 +144,16 @@
        repo = UserApplication.getRepository();
        preProjectCount = repo.getAllProjects().size();
      } catch (SimalRepositoryException e) {
-      throw new UserReportableException(
-          "Unable to get the count of projects", ToolsPage.class, e);
+      throw new UserReportableException("Unable to get the count of  
projects",
+          ToolsPage.class, e);
      }
      PTSWImport importer = new PTSWImport();
      Document pings;
      try {
        pings = importer.getLatestPingsAsRDF();
      } catch (SimalException e) {
-      throw new UserReportableException("Unable to retrieve the latest  
pings from PTSW", ToolsPage.class, e);
+      throw new UserReportableException(
+          "Unable to retrieve the latest pings from PTSW",  
ToolsPage.class, e);
      }
      OutputFormat format = new OutputFormat(pings);
      StringWriter writer = new StringWriter();
@@ -154,28 +161,38 @@
      try {
        serial.serialize(pings);
      } catch (IOException e) {
-      throw new UserReportableException("Unable to serialize PTSW  
response", ToolsPage.class);
+      throw new UserReportableException("Unable to serialize PTSW  
response",
+          ToolsPage.class);
      }
      logger.info("Updated DOAP documents:\n");
      logger.info(writer.toString());

      File tmpFile = new File(System.getProperty("java.io.tmpdir")
          + File.separator + "PTSWExport.xml");
-    FileWriter fw;
+    FileWriter fw = null;
      try {
        fw = new FileWriter(tmpFile);
        fw.write(writer.toString());
-      fw.close();
      } catch (IOException e) {
        throw new UserReportableException(
-          "Unable to write PTSW export file to temporary space",  
ToolsPage.class);
+          "Unable to write PTSW export file to temporary space",
+          ToolsPage.class);
+    } finally {
+      if (fw != null) {
+        try {
+          fw.close();
+        } catch (IOException e) {
+          logger.warn("Unable to close file", e);
+        }
+      }
      }

      try {
-      repo.addProject(tmpFile.toURI().toURL(),
-          tmpFile.toURI().toURL().toExternalForm());
+      repo.addProject(tmpFile.toURI().toURL(), tmpFile.toURI().toURL()
+          .toExternalForm());
        int postProjectCount = repo.getAllProjects().size();
-      logger.info("Imported " + (postProjectCount - preProjectCount) + "  
project records from PTSW");
+      logger.info("Imported " + (postProjectCount - preProjectCount)
+          + " project records from PTSW");
      } catch (Exception e) {
        throw new UserReportableException(
            "Unable to add projects from PTSW Export", ToolsPage.class, e);

Modified:  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/data/DetachableCategoryModel.java
==============================================================================
---  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/data/DetachableCategoryModel.java
       
(original)
+++  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/data/DetachableCategoryModel.java
       
Fri Sep 12 17:01:11 2008
@@ -16,15 +16,13 @@
   * under the License.                                                *
   */

-import org.apache.wicket.model.IModel;
  import org.apache.wicket.model.LoadableDetachableModel;

  import uk.ac.osswatch.simal.model.IDoapCategory;
  import uk.ac.osswatch.simal.rdf.SimalRepositoryException;
  import uk.ac.osswatch.simal.wicket.UserApplication;

-public class DetachableCategoryModel extends LoadableDetachableModel  
implements
-               IModel {
+public class DetachableCategoryModel extends LoadableDetachableModel {
        private static final long serialVersionUID = -9017519516676203598L;
        String uri;


Modified:  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/data/DetachablePersonModel.java
==============================================================================
---  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/data/DetachablePersonModel.java
         
(original)
+++  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/data/DetachablePersonModel.java
         
Fri Sep 12 17:01:11 2008
@@ -16,15 +16,13 @@
   * under the License.                                                *
   */

-import org.apache.wicket.model.IModel;
  import org.apache.wicket.model.LoadableDetachableModel;

  import uk.ac.osswatch.simal.model.IPerson;
  import uk.ac.osswatch.simal.rdf.SimalRepositoryException;
  import uk.ac.osswatch.simal.wicket.UserApplication;

-public class DetachablePersonModel extends LoadableDetachableModel  
implements
-               IModel {
+public class DetachablePersonModel extends LoadableDetachableModel {
        private static final long serialVersionUID = -9017519516676203598L;
        String uri;


Modified:  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/data/DetachableProjectModel.java
==============================================================================
---  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/data/DetachableProjectModel.java
        
(original)
+++  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/data/DetachableProjectModel.java
        
Fri Sep 12 17:01:11 2008
@@ -16,15 +16,13 @@
   * under the License.                                                *
   */

-import org.apache.wicket.model.IModel;
  import org.apache.wicket.model.LoadableDetachableModel;

  import uk.ac.osswatch.simal.model.IProject;
  import uk.ac.osswatch.simal.rdf.SimalRepositoryException;
  import uk.ac.osswatch.simal.wicket.UserApplication;

-public class DetachableProjectModel extends LoadableDetachableModel  
implements
-               IModel {
+public class DetachableProjectModel extends LoadableDetachableModel {
        private static final long serialVersionUID = -9017519516676203598L;
        String uri;


Modified:  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/doap/CategoryDetailPage.java
==============================================================================
---  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/doap/CategoryDetailPage.java
    
(original)
+++  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/doap/CategoryDetailPage.java
    
Fri Sep 12 17:01:11 2008
@@ -31,6 +31,7 @@
   * Displays a single category in detail.
   */
  public class CategoryDetailPage extends BasePage {
+  private static final long serialVersionUID = 1L;
    IDoapCategory category;

    public CategoryDetailPage(IDoapCategory category) {

Modified:  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/doap/ExhibitProjectBrowserPage.java
==============================================================================
---  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/doap/ExhibitProjectBrowserPage.java
     
(original)
+++  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/doap/ExhibitProjectBrowserPage.java
     
Fri Sep 12 17:01:11 2008
@@ -19,8 +19,6 @@
  import org.apache.wicket.behavior.HeaderContributor;
  import org.apache.wicket.behavior.StringHeaderContributor;
  import org.apache.wicket.markup.html.resources.CompressedResourceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;

  import uk.ac.osswatch.simal.wicket.BasePage;

@@ -31,7 +29,6 @@
   */
  public class ExhibitProjectBrowserPage extends BasePage {
        private static final long serialVersionUID = 2675836864409849552L;
-       private static final Logger logger =  
LoggerFactory.getLogger(ExhibitProjectBrowserPage.class);
        private static final CompressedResourceReference EXHIBIT_CSS = new  
CompressedResourceReference(
            BasePage.class, "style/exhibit.css");


Modified:  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/foaf/PersonBrowserPage.java
==============================================================================
---  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/foaf/PersonBrowserPage.java
     
(original)
+++  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/foaf/PersonBrowserPage.java
     
Fri Sep 12 17:01:11 2008
@@ -16,18 +16,11 @@
   * under the License.                                                *
   */

-import java.io.File;
-import java.io.FileWriter;
-import java.net.URL;
-
  import org.apache.wicket.behavior.HeaderContributor;
  import org.apache.wicket.behavior.StringHeaderContributor;
  import org.apache.wicket.markup.html.resources.CompressedResourceReference;

  import uk.ac.osswatch.simal.wicket.BasePage;
-import uk.ac.osswatch.simal.wicket.ErrorReportPage;
-import uk.ac.osswatch.simal.wicket.UserApplication;
-import uk.ac.osswatch.simal.wicket.UserReportableException;

  /**
   * Creates a page which contains an <a
@@ -35,26 +28,17 @@
   * faceted browser for People.
   */
  public class PersonBrowserPage extends BasePage {
+  private static final long serialVersionUID = 1L;

    private static final CompressedResourceReference EXHIBIT_CSS = new  
CompressedResourceReference(
        BasePage.class, "style/exhibit.css");

    public PersonBrowserPage() {
-    URL dir = UserApplication.class.getResource(DEFAULT_CSS_LOC);
-    try {
-      File outFile = new File(new File(dir.toURI()).getParent() +  
File.separator + "people.js");
-      FileWriter out = new FileWriter(outFile);
-      out.write(UserApplication.getRepository().getAllPeopleAsJSON());
-      out.close();
-    } catch (Exception e) {
-      UserReportableException error = new UserReportableException("Unable  
to write JSON file", PersonBrowserPage.class, e);
-      setResponsePage(new ErrorReportPage(error));
-    }
      add(HeaderContributor.forCss(EXHIBIT_CSS));
      add(HeaderContributor
          
.forJavaScript("http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js";));
      add(new StringHeaderContributor(
-        "<link  
href=\"/resources/uk.ac.osswatch.simal.wicket.UserApplication/style/people.js\" 
 
type=\"application/json\" rel=\"exhibit/data\" />"));
+        "<link href=\"/simal-rest/allPeople/json\" rel=\"exhibit/data\"  
/>"));
    }
  }


Modified:  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/markup/html/repeater/data/table/LinkPropertyColumn.java
==============================================================================
---  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/markup/html/repeater/data/table/LinkPropertyColumn.java
         
(original)
+++  
trunk/uk.ac.osswatch.simal.web/src/main/java/uk/ac/osswatch/simal/wicket/markup/html/repeater/data/table/LinkPropertyColumn.java
         
Fri Sep 12 17:01:11 2008
@@ -36,6 +36,7 @@
   * ]]>
   */
  public abstract class LinkPropertyColumn extends PropertyColumn {
+  private static final long serialVersionUID = 1L;
        PopupSettings popupSettings;
        IModel labelModel;


--~--~---------~--~----~------------~-------~--~----~
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