You are viewing a plain text version of this content. The canonical link for it is here.
Posted to photark-commits@incubator.apache.org by lr...@apache.org on 2010/11/01 21:17:46 UTC

svn commit: r1029843 - in /incubator/photark/branches/photark-rest/photark-filesystem: pom.xml src/main/java/org/apache/photark/services/filesystem/FileSystemGallery.java src/test/java/org/apache/photark/services/filesystem/FileSystemGalleryTestCase.java

Author: lresende
Date: Mon Nov  1 21:17:46 2010
New Revision: 1029843

URL: http://svn.apache.org/viewvc?rev=1029843&view=rev
Log:
Tyding up filesystem support

Modified:
    incubator/photark/branches/photark-rest/photark-filesystem/pom.xml
    incubator/photark/branches/photark-rest/photark-filesystem/src/main/java/org/apache/photark/services/filesystem/FileSystemGallery.java
    incubator/photark/branches/photark-rest/photark-filesystem/src/test/java/org/apache/photark/services/filesystem/FileSystemGalleryTestCase.java

Modified: incubator/photark/branches/photark-rest/photark-filesystem/pom.xml
URL: http://svn.apache.org/viewvc/incubator/photark/branches/photark-rest/photark-filesystem/pom.xml?rev=1029843&r1=1029842&r2=1029843&view=diff
==============================================================================
--- incubator/photark/branches/photark-rest/photark-filesystem/pom.xml (original)
+++ incubator/photark/branches/photark-rest/photark-filesystem/pom.xml Mon Nov  1 21:17:46 2010
@@ -7,15 +7,15 @@
     * to you under the Apache License, Version 2.0 (the
     * "License"); you may not use this file except in compliance
     * with the License.  You may obtain a copy of the License at
-    * 
+    *
     *   http://www.apache.org/licenses/LICENSE-2.0
-    * 
+    *
     * Unless required by applicable law or agreed to in writing,
     * software distributed under the License is distributed on an
     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     * KIND, either express or implied.  See the License for the
     * specific language governing permissions and limitations
-    * under the License.    
+    * under the License.
 -->
 <project>
 	<modelVersion>4.0.0</modelVersion>
@@ -30,15 +30,9 @@
 
 	<dependencies>
 		<dependency>
-			<groupId>org.apache.tuscany.sca</groupId>
-			<artifactId>tuscany-sca-api</artifactId>
-			<version>${tuscany.version}</version>
-		</dependency>
-
-		<dependency>
 			<groupId>org.apache.photark</groupId>
 			<artifactId>photark</artifactId>
-			<version>1.0-incubating-SNAPSHOT</version>
+			<version>${project.version}</version>
 		</dependency>
 
 		<dependency>
@@ -46,7 +40,14 @@
 			<artifactId>jsr311-api</artifactId>
 			<version>1.1</version>
 		</dependency>
-		
+
+        <!-- Tuscany Dependencies -->
+		<dependency>
+			<groupId>org.apache.tuscany.sca</groupId>
+			<artifactId>tuscany-sca-api</artifactId>
+			<version>${tuscany.version}</version>
+		</dependency>
+
 		<!-- marking dependency as provided to exclude from war file -->
 		<dependency>
 			<groupId>javax.servlet</groupId>
@@ -54,7 +55,6 @@
 			<version>2.5</version>
 			<scope>provided</scope>
 		</dependency>
-		
 
 		<dependency>
 			<groupId>org.apache.tuscany.sca</groupId>

Modified: incubator/photark/branches/photark-rest/photark-filesystem/src/main/java/org/apache/photark/services/filesystem/FileSystemGallery.java
URL: http://svn.apache.org/viewvc/incubator/photark/branches/photark-rest/photark-filesystem/src/main/java/org/apache/photark/services/filesystem/FileSystemGallery.java?rev=1029843&r1=1029842&r2=1029843&view=diff
==============================================================================
--- incubator/photark/branches/photark-rest/photark-filesystem/src/main/java/org/apache/photark/services/filesystem/FileSystemGallery.java (original)
+++ incubator/photark/branches/photark-rest/photark-filesystem/src/main/java/org/apache/photark/services/filesystem/FileSystemGallery.java Mon Nov  1 21:17:46 2010
@@ -59,15 +59,6 @@ public class FileSystemGallery implement
         this.galleryRoot = galleryRoot;
     }
 
-    public String getLocation() {
-        return this.galleryLocation;
-    }
-
-    @Property(name="galleryURL", required=false)
-    public void setLocation(String location) {
-        this.galleryLocation = location;
-    }
-
     @Init
     public void init() {
         try {
@@ -105,11 +96,25 @@ public class FileSystemGallery implement
                     }
                 }
             }
+
+            if(logger.isLoggable(Level.FINE)) {
+                logger.fine("Found '" + albums.size() + "' albums in the repository");
+            }
+
         } catch (Exception e) {
             logger.log(Level.SEVERE, "Error initializing FileSystem gallery: " + e.getMessage(), e);
         }
     }
 
+    public String getLocation() {
+        return this.galleryLocation;
+    }
+
+    @Property(name="galleryURL", required=false)
+    public void setLocation(String location) {
+        this.galleryLocation = location;
+    }
+
     public AlbumList getAlbums() {
         AlbumList albumList = new AlbumList();
 
@@ -142,6 +147,9 @@ public class FileSystemGallery implement
         if (galleryRootDirectory != null) {
            File newAlbumDirectory = new File(galleryRootDirectory.getPath() + File.separator + newAlbum.getName());
            if ( ! newAlbumDirectory.mkdir()) {
+               if(logger.isLoggable(Level.SEVERE)) {
+                   logger.log(Level.SEVERE, "Error creating new album directory '" + newAlbumDirectory.getPath() + "'" );
+               }
                throw new PhotarkRuntimeException("Error creating new album directory '" + newAlbumDirectory.getPath() + "'" );
            }
         }
@@ -154,6 +162,10 @@ public class FileSystemGallery implement
         }
 
         if(! albums.containsKey(album.getName())) {
+            if(logger.isLoggable(Level.SEVERE)) {
+                logger.log(Level.SEVERE, "Album '" + album.getName() + "' not found");
+            }
+
             throw new InvalidParameterException("Album '" + album.getName() + "' not found");
         }
 

Modified: incubator/photark/branches/photark-rest/photark-filesystem/src/test/java/org/apache/photark/services/filesystem/FileSystemGalleryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/photark/branches/photark-rest/photark-filesystem/src/test/java/org/apache/photark/services/filesystem/FileSystemGalleryTestCase.java?rev=1029843&r1=1029842&r2=1029843&view=diff
==============================================================================
--- incubator/photark/branches/photark-rest/photark-filesystem/src/test/java/org/apache/photark/services/filesystem/FileSystemGalleryTestCase.java (original)
+++ incubator/photark/branches/photark-rest/photark-filesystem/src/test/java/org/apache/photark/services/filesystem/FileSystemGalleryTestCase.java Mon Nov  1 21:17:46 2010
@@ -114,22 +114,6 @@ public class FileSystemGalleryTestCase {
         Assert.assertEquals(204, response.getResponseCode());
     }
 
-    private String getNewAlbumName() throws IOException, JSONException {
-        String[] albums = readAlbums();
-        String album = albums[albums.length -1 ];
-        String[] tokens = album.split("-");
-        album = tokens[0] + "-" + (Integer.parseInt(tokens[1]) + 1);
-
-        return album;
-    }
-
-    private String getLastAlbumName() throws IOException, JSONException {
-        String[] albums = readAlbums();
-        String album = albums[albums.length -1];
-
-        return album;
-    }
-
     private String[] readAlbums()  throws IOException, JSONException {
         WebConversation wc = new WebConversation();
         WebRequest request = new GetMethodWebRequest(GALLERY_SERVICE_URL);
@@ -154,4 +138,25 @@ public class FileSystemGalleryTestCase {
         return albumNameArray;
     }
 
+    private String getNewAlbumName() throws IOException, JSONException {
+        String[] albums = readAlbums();
+        String album = null;
+        if (albums.length == 0) {
+            album = "album-0";
+        } else {
+            album = albums[albums.length -1 ];
+            String[] tokens = album.split("-");
+            album = tokens[0] + "-" + (Integer.parseInt(tokens[1]) + 1);
+        }
+        return album;
+    }
+
+    private String getLastAlbumName() throws IOException, JSONException {
+        String[] albums = readAlbums();
+        String album = albums[albums.length -1];
+
+        return album;
+    }
+
+
 }