incubator-photark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lrese...@apache.org
Subject svn commit: r942772 - in /incubator/photark/trunk: photark-jcr/src/main/java/org/apache/photark/jcr/services/ photark/src/main/java/org/apache/photark/services/album/
Date Mon, 10 May 2010 15:01:08 GMT
Author: lresende
Date: Mon May 10 15:01:08 2010
New Revision: 942772

URL: http://svn.apache.org/viewvc?rev=942772&view=rev
Log:
Formatting...

Modified:
    incubator/photark/trunk/photark-jcr/src/main/java/org/apache/photark/jcr/services/JCRAlbumImpl.java
    incubator/photark/trunk/photark/src/main/java/org/apache/photark/services/album/Album.java
    incubator/photark/trunk/photark/src/main/java/org/apache/photark/services/album/AlbumAgregator.java
    incubator/photark/trunk/photark/src/main/java/org/apache/photark/services/album/ImageFilter.java

Modified: incubator/photark/trunk/photark-jcr/src/main/java/org/apache/photark/jcr/services/JCRAlbumImpl.java
URL: http://svn.apache.org/viewvc/incubator/photark/trunk/photark-jcr/src/main/java/org/apache/photark/jcr/services/JCRAlbumImpl.java?rev=942772&r1=942771&r2=942772&view=diff
==============================================================================
--- incubator/photark/trunk/photark-jcr/src/main/java/org/apache/photark/jcr/services/JCRAlbumImpl.java
(original)
+++ incubator/photark/trunk/photark-jcr/src/main/java/org/apache/photark/jcr/services/JCRAlbumImpl.java
Mon May 10 15:01:08 2010
@@ -43,276 +43,276 @@ import org.oasisopen.sca.annotation.Init
 import org.oasisopen.sca.annotation.Property;
 
 public class JCRAlbumImpl implements Album {
-	private static final Logger logger = Logger.getLogger(JCRAlbumImpl.class.getName());
+    private static final Logger logger = Logger.getLogger(JCRAlbumImpl.class.getName());
 
-	private JCRRepositoryManager repositoryManager;
+    private JCRRepositoryManager repositoryManager;
 
-	private String gallery;
-	private String name;
-	private String location;
-	private boolean initialized;
-	private static Map<String, Album> albums = new HashMap<String, Album>();
-
-	public synchronized static Album createAlbum(JCRRepositoryManager repositoryManager, String
name ) {
-		if (!albums.containsKey(name)) {
-			albums.put(name, new JCRAlbumImpl(repositoryManager,name ));
-		}
-		return albums.get(name);
-	}
-
-	public JCRAlbumImpl(JCRRepositoryManager repositoryManager, String name) {
-		this.repositoryManager = repositoryManager;
-		this.name = name;
-	}
-
-	/**
-	 * Initialize the gallery service
-	 *   - During initialization, check for local images and create a JCR album 
-	 *     which is usefull for sample gallery shiped in the sample application.
-	 */
-	@Init
-	public synchronized void init() {
-		logger.info("Initializing JCR Album");
-		try {
-			URL albumURL = this.getClass().getClassLoader().getResource(getLocation());
-			if (albumURL == null) {
-				String loc = "../../" + getLocation();
-				albumURL = this.getClass().getClassLoader().getResource(loc);
-			}
-
-			Session session = repositoryManager.getSession();
-			if (albumURL != null) {
-				try {
-					File album = new File(albumURL.toURI());
-					if (album.isDirectory() && album.exists()) {
-						String[] listPictures = album.list(new ImageFilter(".jpg"));
-						if (listPictures != null && listPictures.length > 0) {
-							Node albumNode = getAlbumNode(name);
-							for (String image : listPictures) {
-								if (!albumNode.hasNode(image)) {
-									Node picNode = albumNode.addNode(image);
-									String imagePath = albumURL.getPath() + image;
-									InputStream imageContent = new FileInputStream(new File(imagePath));
-									picNode.setProperty("imageContent", imageContent);
-									picNode.setProperty("name", image);
-									picNode.setProperty("location", image);
-								}
-							}
-						}
-					}
-
-					session.save();
-				} catch (Exception e) {
-					// FIXME: ignore for now
-					e.printStackTrace();
-				}
-			}
-		} catch (Exception e) {
-			// FIXME: ignore for now
-			e.printStackTrace();
-		} finally {
-			//repositoryManager.releaseSession();
-		}
-		initialized = true;
-	}
-
-	@Destroy
-	public void destroy() {
-		//repositoryManager.releaseSession();
-	}
-
-	@Property
-	public void setGallery(String gallery) {
-		this.gallery = gallery;
-		this.location = null;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	@Property
-	public void setName(String name) {
-		this.name = name;
-		this.location = null;
-	}
-
-	public String getDescription() {
-		String description="";
-		if (!initialized) {
-			init();
-		}
-		try {
-			Session session = repositoryManager.getSession();
-			Node root = session.getRootNode();
-			Node albumNode = root.getNode(name);
-			if(albumNode.hasProperty("description")){
-				description = albumNode.getProperty("description").getString();
-			}else{
-				logger.info("description of album " + name + " not found");
-			}
-
-		} catch (Exception e) {
-			// FIXME: ignore for now
-			e.printStackTrace();
-		} finally {
-			//repositoryManager.releaseSession();
-		}
-		return description;
-	}
-
-	@Property
-	public void setDescription(String description) {
-		try {
-			Session session = repositoryManager.getSession();
-			Node root = session.getRootNode();
-			Node albumNode = root.getNode(name);
-			albumNode.setProperty("description", description);
-			session.save();
-		} catch (RepositoryException e) {
-			e.printStackTrace();
-		}  finally {
-			//repositoryManager.releaseSession();
-		}
-
-	}
-
-	public String getLocation() {
-		if (location == null) {
-			location = gallery + "/" + name + "/";
-		}
-		return location;
-
-	}
-
-	public void setLocation(String location) {
-		logger.info("inside setLocation:location:" + location);
-		this.location = location;
-	}
-
-	public String[] getPictures() {
-		if (!initialized) {
-			init();
-		}
-		List<String> pictures = new ArrayList<String>();
-		try {
-			Session session = repositoryManager.getSession();
-			Node root = session.getRootNode();
-			Node albumNode = root.getNode(name);
-			NodeIterator nodes = albumNode.getNodes();
-
-			while (nodes.hasNext()) {
-				Node node = nodes.nextNode();
-				if (node.getPath().equals("/jcr:system"))
-					continue;
-				pictures.add(node.getProperty("location").getString());
-			}
-		} catch (Exception e) {
-			// FIXME: ignore for now
-			e.printStackTrace();
-		} finally {
-			//repositoryManager.releaseSession();
-		}
-
-		String[] pictureArray = new String[pictures.size()];
-		pictures.toArray(pictureArray);
-		return pictureArray;
-	}
-
-	public void removeNodes() {
-		try {
-			Session session = repositoryManager.getSession();
-			Node root = session.getRootNode();
-			NodeIterator nodes = root.getNodes();
-			while (nodes.hasNext()) {
-				Node node = nodes.nextNode();
-				if (node.getPath().equals("/jcr:system"))
-					continue;
-				else
-					node.remove();
-			}
-			session.save();
-		} catch (Exception e) {
-			// FIXME: ignore for now
-			e.printStackTrace();
-		} finally {
-			//repositoryManager.releaseSession();
-		}
-
-	}
-
-	public void addPicture(Image picture) {
-		try {
-			Session session = repositoryManager.getSession();
-			Node root = session.getRootNode();
-			Node albumNode = root.getNode(name);
-			Node picNode = albumNode.addNode(picture.getName());
-			picture.getImageAsStream();
-			picNode.setProperty("imageContent", picture.getImageAsStream());
-			picNode.setProperty("name", picture.getName());
-			picNode.setProperty("location", picture.getName());
-			session.save();
-		} catch (RepositoryException e) {
-			e.printStackTrace();
-		}  finally {
-			//repositoryManager.releaseSession();
-		}
-	}
-
-	public void deletePicture(Image picture) {
-		try {
-			Session session = repositoryManager.getSession();
-			Node root = session.getRootNode();
-			Node albumNode = root.getNode(name);
-			Node picNode = albumNode.addNode(picture.getName());
-			picNode.remove();
-			session.save();
-		} catch (RepositoryException e) {
-			e.printStackTrace();
-		}  finally {
-			//repositoryManager.releaseSession();
-		}
-	}
-
-	/**
-	 * This method deletes the picture node.
-	 * @param String pictureName
-	 * 
-	 */
-	public void deletePicture(String pictureName) {
-		try {
-			Session session = repositoryManager.getSession();
-			Node root = session.getRootNode();
-			Node albumNode = root.getNode(name);
-			if(albumNode.hasNode(pictureName)){
-				Node picNode = albumNode.getNode(pictureName);
-				picNode.remove();
-				session.save();
-			}else{
-				logger.info("image " + pictureName + " not found");
-			}    	            
-		} catch (RepositoryException e) {
-			e.printStackTrace();
-		}  finally {
-			//repositoryManager.releaseSession();
-		}
-	}
-
-	/**
-	 * This method create new album node in case it does not exists in
-	 * repository or return older album node otherwise.
-	 * 
-	 * @param albumName
-	 * @return
-	 * @throws RepositoryException
-	 */
-	private Node getAlbumNode(String name) throws RepositoryException {
-		Session session = repositoryManager.getSession();
-		Node root = session.getRootNode();
-		if (root.hasNode(name)) {
-			return root.getNode(name);
-		} else {
-			return root.addNode(name);
-		}
-	}
+    private String gallery;
+    private String name;
+    private String location;
+    private boolean initialized;
+    private static Map<String, Album> albums = new HashMap<String, Album>();
+
+    public synchronized static Album createAlbum(JCRRepositoryManager repositoryManager,
String name ) {
+        if (!albums.containsKey(name)) {
+            albums.put(name, new JCRAlbumImpl(repositoryManager,name ));
+        }
+        return albums.get(name);
+    }
+
+    public JCRAlbumImpl(JCRRepositoryManager repositoryManager, String name) {
+        this.repositoryManager = repositoryManager;
+        this.name = name;
+    }
+
+    /**
+     * Initialize the gallery service
+     *   - During initialization, check for local images and create a JCR album 
+     *     which is usefull for sample gallery shiped in the sample application.
+     */
+    @Init
+    public synchronized void init() {
+        logger.info("Initializing JCR Album");
+        try {
+            URL albumURL = this.getClass().getClassLoader().getResource(getLocation());
+            if (albumURL == null) {
+                String loc = "../../" + getLocation();
+                albumURL = this.getClass().getClassLoader().getResource(loc);
+            }
+
+            Session session = repositoryManager.getSession();
+            if (albumURL != null) {
+                try {
+                    File album = new File(albumURL.toURI());
+                    if (album.isDirectory() && album.exists()) {
+                        String[] listPictures = album.list(new ImageFilter(".jpg"));
+                        if (listPictures != null && listPictures.length > 0) {
+                            Node albumNode = getAlbumNode(name);
+                            for (String image : listPictures) {
+                                if (!albumNode.hasNode(image)) {
+                                    Node picNode = albumNode.addNode(image);
+                                    String imagePath = albumURL.getPath() + image;
+                                    InputStream imageContent = new FileInputStream(new File(imagePath));
+                                    picNode.setProperty("imageContent", imageContent);
+                                    picNode.setProperty("name", image);
+                                    picNode.setProperty("location", image);
+                                }
+                            }
+                        }
+                    }
+
+                    session.save();
+                } catch (Exception e) {
+                    // FIXME: ignore for now
+                    e.printStackTrace();
+                }
+            }
+        } catch (Exception e) {
+            // FIXME: ignore for now
+            e.printStackTrace();
+        } finally {
+            //repositoryManager.releaseSession();
+        }
+        initialized = true;
+    }
+
+    @Destroy
+    public void destroy() {
+        //repositoryManager.releaseSession();
+    }
+
+    @Property
+    public void setGallery(String gallery) {
+        this.gallery = gallery;
+        this.location = null;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    @Property
+    public void setName(String name) {
+        this.name = name;
+        this.location = null;
+    }
+
+    public String getDescription() {
+        String description="";
+        if (!initialized) {
+            init();
+        }
+        try {
+            Session session = repositoryManager.getSession();
+            Node root = session.getRootNode();
+            Node albumNode = root.getNode(name);
+            if(albumNode.hasProperty("description")){
+                description = albumNode.getProperty("description").getString();
+            }else{
+                logger.info("description of album " + name + " not found");
+            }
+
+        } catch (Exception e) {
+            // FIXME: ignore for now
+            e.printStackTrace();
+        } finally {
+            //repositoryManager.releaseSession();
+        }
+        return description;
+    }
+
+    @Property
+    public void setDescription(String description) {
+        try {
+            Session session = repositoryManager.getSession();
+            Node root = session.getRootNode();
+            Node albumNode = root.getNode(name);
+            albumNode.setProperty("description", description);
+            session.save();
+        } catch (RepositoryException e) {
+            e.printStackTrace();
+        }  finally {
+            //repositoryManager.releaseSession();
+        }
+
+    }
+
+    public String getLocation() {
+        if (location == null) {
+            location = gallery + "/" + name + "/";
+        }
+        return location;
+
+    }
+
+    public void setLocation(String location) {
+        logger.info("inside setLocation:location:" + location);
+        this.location = location;
+    }
+
+    public String[] getPictures() {
+        if (!initialized) {
+            init();
+        }
+        List<String> pictures = new ArrayList<String>();
+        try {
+            Session session = repositoryManager.getSession();
+            Node root = session.getRootNode();
+            Node albumNode = root.getNode(name);
+            NodeIterator nodes = albumNode.getNodes();
+
+            while (nodes.hasNext()) {
+                Node node = nodes.nextNode();
+                if (node.getPath().equals("/jcr:system"))
+                    continue;
+                pictures.add(node.getProperty("location").getString());
+            }
+        } catch (Exception e) {
+            // FIXME: ignore for now
+            e.printStackTrace();
+        } finally {
+            //repositoryManager.releaseSession();
+        }
+
+        String[] pictureArray = new String[pictures.size()];
+        pictures.toArray(pictureArray);
+        return pictureArray;
+    }
+
+    public void removeNodes() {
+        try {
+            Session session = repositoryManager.getSession();
+            Node root = session.getRootNode();
+            NodeIterator nodes = root.getNodes();
+            while (nodes.hasNext()) {
+                Node node = nodes.nextNode();
+                if (node.getPath().equals("/jcr:system"))
+                    continue;
+                else
+                    node.remove();
+            }
+            session.save();
+        } catch (Exception e) {
+            // FIXME: ignore for now
+            e.printStackTrace();
+        } finally {
+            //repositoryManager.releaseSession();
+        }
+
+    }
+
+    public void addPicture(Image picture) {
+        try {
+            Session session = repositoryManager.getSession();
+            Node root = session.getRootNode();
+            Node albumNode = root.getNode(name);
+            Node picNode = albumNode.addNode(picture.getName());
+            picture.getImageAsStream();
+            picNode.setProperty("imageContent", picture.getImageAsStream());
+            picNode.setProperty("name", picture.getName());
+            picNode.setProperty("location", picture.getName());
+            session.save();
+        } catch (RepositoryException e) {
+            e.printStackTrace();
+        }  finally {
+            //repositoryManager.releaseSession();
+        }
+    }
+
+    public void deletePicture(Image picture) {
+        try {
+            Session session = repositoryManager.getSession();
+            Node root = session.getRootNode();
+            Node albumNode = root.getNode(name);
+            Node picNode = albumNode.addNode(picture.getName());
+            picNode.remove();
+            session.save();
+        } catch (RepositoryException e) {
+            e.printStackTrace();
+        }  finally {
+            //repositoryManager.releaseSession();
+        }
+    }
+
+    /**
+     * This method deletes the picture node.
+     * @param String pictureName
+     * 
+     */
+    public void deletePicture(String pictureName) {
+        try {
+            Session session = repositoryManager.getSession();
+            Node root = session.getRootNode();
+            Node albumNode = root.getNode(name);
+            if(albumNode.hasNode(pictureName)){
+                Node picNode = albumNode.getNode(pictureName);
+                picNode.remove();
+                session.save();
+            }else{
+                logger.info("image " + pictureName + " not found");
+            }    	            
+        } catch (RepositoryException e) {
+            e.printStackTrace();
+        }  finally {
+            //repositoryManager.releaseSession();
+        }
+    }
+
+    /**
+     * This method create new album node in case it does not exists in
+     * repository or return older album node otherwise.
+     * 
+     * @param albumName
+     * @return
+     * @throws RepositoryException
+     */
+    private Node getAlbumNode(String name) throws RepositoryException {
+        Session session = repositoryManager.getSession();
+        Node root = session.getRootNode();
+        if (root.hasNode(name)) {
+            return root.getNode(name);
+        } else {
+            return root.addNode(name);
+        }
+    }
 }

Modified: incubator/photark/trunk/photark/src/main/java/org/apache/photark/services/album/Album.java
URL: http://svn.apache.org/viewvc/incubator/photark/trunk/photark/src/main/java/org/apache/photark/services/album/Album.java?rev=942772&r1=942771&r2=942772&view=diff
==============================================================================
--- incubator/photark/trunk/photark/src/main/java/org/apache/photark/services/album/Album.java
(original)
+++ incubator/photark/trunk/photark/src/main/java/org/apache/photark/services/album/Album.java
Mon May 10 15:01:08 2010
@@ -25,23 +25,23 @@ import org.oasisopen.sca.annotation.Remo
 @Remotable
 public interface Album {
 
-	String getName();
+    String getName();
 
-	void setName(String name);
+    void setName(String name);
 
-	String getDescription();
+    String getDescription();
 
-	void setDescription(String description);
+    void setDescription(String description);
 
-	String getLocation();
+    String getLocation();
 
-	void setLocation(String location);
+    void setLocation(String location);
 
-	String[] getPictures();
+    String[] getPictures();
 
-	void addPicture(Image picture);
+    void addPicture(Image picture);
 
-	void deletePicture(String picture);
+    void deletePicture(String picture);
 
-	void deletePicture(Image picture);
+    void deletePicture(Image picture);
 }
\ No newline at end of file

Modified: incubator/photark/trunk/photark/src/main/java/org/apache/photark/services/album/AlbumAgregator.java
URL: http://svn.apache.org/viewvc/incubator/photark/trunk/photark/src/main/java/org/apache/photark/services/album/AlbumAgregator.java?rev=942772&r1=942771&r2=942772&view=diff
==============================================================================
--- incubator/photark/trunk/photark/src/main/java/org/apache/photark/services/album/AlbumAgregator.java
(original)
+++ incubator/photark/trunk/photark/src/main/java/org/apache/photark/services/album/AlbumAgregator.java
Mon May 10 15:01:08 2010
@@ -27,35 +27,35 @@ import org.oasisopen.sca.annotation.Init
 import org.oasisopen.sca.annotation.Reference;
 
 public class AlbumAgregator implements Album {
-	private static String NAME = "Aggregated Album";
+    private static String NAME = "Aggregated Album";
 
-	private List<String> pictures = new ArrayList<String>();
+    private List<String> pictures = new ArrayList<String>();
 
-	@Reference(required=false)
-	protected Album album;
+    @Reference(required=false)
+    protected Album album;
 
-	/* FIXME: Not currently in use... */
-	/*
+    /* FIXME: Not currently in use... */
+    /*
 	@Reference(required=false)
 	protected org.apache.tuscany.sca.binding.atom.collection.Collection albumFeed;
-	*/
+     */
 
-	/* FIXME: GData support not available in Tuscany 2.x */
-	/*
+    /* FIXME: GData support not available in Tuscany 2.x */
+    /*
         @Reference(required=false)
         protected org.apache.tuscany.sca.binding.gdata.collection.Collection albumPicassa;
-	 */
+     */
 
-	@Init
-	public void init() {
-	    if(album != null) {
-	        for(String picture : album.getPictures()) {
-	            pictures.add(picture);
-	        }            
-	    }
+    @Init
+    public void init() {
+        if(album != null) {
+            for(String picture : album.getPictures()) {
+                pictures.add(picture);
+            }            
+        }
 
-	    /* FIXME: Not currently in use... */
-	    /*
+        /* FIXME: Not currently in use... */
+        /*
 	    if (albumFeed != null) {
 	        try {
 	            for(org.apache.abdera.model.Entry feedPicture : albumFeed.getFeed().getEntries())
{
@@ -66,10 +66,10 @@ public class AlbumAgregator implements A
 	            //log exception, warn user that album xxx was not processed (not found)
 	        }
 	    }
-	    */
+         */
 
-	    /* FIXME: GData support not available in Tuscany 2.x*/ 
-	    /*
+        /* FIXME: GData support not available in Tuscany 2.x*/ 
+        /*
 	    if( albumPicassa != null) {
 	        try {
 	            for(com.google.gdata.data.Entry picassaPicture : albumPicassa.getFeed().getEntries())
{
@@ -80,51 +80,51 @@ public class AlbumAgregator implements A
 	            //log exception, warn user that album xxx was not processed (not found)
 	        }
 	    }
-	    */
+         */
 
 
-	}
+    }
 
-	public String getName() {
-		return NAME;
-	}
+    public String getName() {
+        return NAME;
+    }
 
-	public void setName(String name) {
-		throw new UnsupportedOperationException();
-	}
+    public void setName(String name) {
+        throw new UnsupportedOperationException();
+    }
 
-	public String getDescription(){
-		throw new UnsupportedOperationException();
-	}
+    public String getDescription(){
+        throw new UnsupportedOperationException();
+    }
 
-	public void setDescription(String description){
-		throw new UnsupportedOperationException();
-	}
+    public void setDescription(String description){
+        throw new UnsupportedOperationException();
+    }
 
-	public String getLocation() {
-		throw new UnsupportedOperationException();
-	}
+    public String getLocation() {
+        throw new UnsupportedOperationException();
+    }
 
-	public void setLocation(String location) {
-		throw new UnsupportedOperationException();
-	}
+    public void setLocation(String location) {
+        throw new UnsupportedOperationException();
+    }
 
-	public String[] getPictures() {
-		String[] pictureArray = new String[pictures.size()];
-		pictures.toArray(pictureArray);
-		return pictureArray;
-	}
+    public String[] getPictures() {
+        String[] pictureArray = new String[pictures.size()];
+        pictures.toArray(pictureArray);
+        return pictureArray;
+    }
 
 
-	public void addPicture(Image picture){
+    public void addPicture(Image picture){
 
-	}
+    }
 
-	public void deletePicture(Image picture){
+    public void deletePicture(Image picture){
 
-	}
+    }
 
-	public void deletePicture(String picture){
+    public void deletePicture(String picture){
 
-	}
+    }
 }

Modified: incubator/photark/trunk/photark/src/main/java/org/apache/photark/services/album/ImageFilter.java
URL: http://svn.apache.org/viewvc/incubator/photark/trunk/photark/src/main/java/org/apache/photark/services/album/ImageFilter.java?rev=942772&r1=942771&r2=942772&view=diff
==============================================================================
--- incubator/photark/trunk/photark/src/main/java/org/apache/photark/services/album/ImageFilter.java
(original)
+++ incubator/photark/trunk/photark/src/main/java/org/apache/photark/services/album/ImageFilter.java
Mon May 10 15:01:08 2010
@@ -29,8 +29,8 @@ public class ImageFilter implements File
     String afn;
     public ImageFilter(String afn) { this.afn = afn; }
     public boolean accept(File dir, String name) {
-      // Strip path information:
-      String f = new File(name).getName();
-      return f.indexOf(afn) != -1;
+        // Strip path information:
+        String f = new File(name).getName();
+        return f.indexOf(afn) != -1;
     }
-  }
\ No newline at end of file
+}
\ No newline at end of file



Mime
View raw message