Author: ross.gardler
Date: Fri Sep 12 16:59:40 2008
New Revision: 1307

Modified:
     
trunk/uk.ac.osswatch.simal.rest/src/documentation/content/xdocs/developer/implementNewCommand.xml
     
trunk/uk.ac.osswatch.simal.rest/src/main/java/uk/ac/osswatch/simal/rest/PersonAPI.java

Log:
USe repository method for generating JSON

Modified:  
trunk/uk.ac.osswatch.simal.rest/src/documentation/content/xdocs/developer/implementNewCommand.xml
==============================================================================
---  
trunk/uk.ac.osswatch.simal.rest/src/documentation/content/xdocs/developer/implementNewCommand.xml
        
(original)
+++  
trunk/uk.ac.osswatch.simal.rest/src/documentation/content/xdocs/developer/implementNewCommand.xml
        
Fri Sep 12 16:59:40 2008
@@ -180,33 +180,29 @@

        <source>
  <![CDATA[
-  /**
-   * Get all the people in the repository.
-   * @param cmd
-   * @return
-   * @throws SimalAPIException
-   */
-  public String getAllPeople(final RESTCommand cmd)
-    throws SimalAPIException {
-    final String id = cmd.getPersonID();
-
-    StringBuffer response = new StringBuffer();
-    try {
-      Iterator<IPerson> itr = getRepository().getAllPeople().iterator();
-      if (cmd.isJSON()) {
-        while(itr.hasNext()) {
-          response.append("{ \"items\": [");
-          response.append(itr.next().toJSON(true));
-          response.append("]}");
-        }
-      } else {
-        throw new SimalAPIException("Unknown data format: " +  
cmd.getFormat());
-      }
-    } catch (SimalRepositoryException e) {
-      throw new SimalAPIException("Unable to get a person with id " + id,  
e);
+/**
+ * Get all the people in the repository.
+ * @param cmd
+ * @return
+ * @throws SimalAPIException
+ */
+public String getAllPeople(final RESTCommand cmd)
+  throws SimalAPIException {
+  final String id = cmd.getPersonID();
+
+  String response;
+  try {
+    Iterator<IPerson> itr = getRepository().getAllPeople().iterator();
+    if (cmd.isJSON()) {
+      response = getRepository().getAllPeopleAsJSON();
+    } else {
+      throw new SimalAPIException("Unknown data format: " +  
cmd.getFormat());
      }
-    return response.toString();
+  } catch (SimalRepositoryException e) {
+    throw new SimalAPIException("Unable to get a person with id " + id, e);
    }
+  return response;
+}
  ]]>
        </source>


Modified:  
trunk/uk.ac.osswatch.simal.rest/src/main/java/uk/ac/osswatch/simal/rest/PersonAPI.java
==============================================================================
---  
trunk/uk.ac.osswatch.simal.rest/src/main/java/uk/ac/osswatch/simal/rest/PersonAPI.java
   
(original)
+++  
trunk/uk.ac.osswatch.simal.rest/src/main/java/uk/ac/osswatch/simal/rest/PersonAPI.java
   
Fri Sep 12 16:59:40 2008
@@ -171,21 +171,17 @@
      throws SimalAPIException {
      final String id = cmd.getPersonID();

-    StringBuffer response = new StringBuffer();
+    String response;
      try {
        Iterator<IPerson> itr = getRepository().getAllPeople().iterator();
        if (cmd.isJSON()) {
-        while(itr.hasNext()) {
-          response.append("{ \"items\": [");
-          response.append(itr.next().toJSON(true));
-          response.append("]}");
-        }
+        response = getRepository().getAllPeopleAsJSON();
        } else {
          throw new SimalAPIException("Unknown data format: " +  
cmd.getFormat());
        }
      } catch (SimalRepositoryException e) {
        throw new SimalAPIException("Unable to get a person with id " + id,  
e);
      }
-    return response.toString();
+    return response;
    }
  }

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