Formatting...
git-svn-id: https://svn.apache.org/repos/asf/incubator/photark/trunk@942772 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/photark-jcr/src/main/java/org/apache/photark/jcr/services/JCRAlbumImpl.java b/photark-jcr/src/main/java/org/apache/photark/jcr/services/JCRAlbumImpl.java
index b6a743e..542c246 100644
--- a/photark-jcr/src/main/java/org/apache/photark/jcr/services/JCRAlbumImpl.java
+++ b/photark-jcr/src/main/java/org/apache/photark/jcr/services/JCRAlbumImpl.java
@@ -43,276 +43,276 @@
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>();
+ 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 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;
- }
+ 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);
- }
+ /**
+ * 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 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;
- }
+ 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();
- }
+ @Destroy
+ public void destroy() {
+ //repositoryManager.releaseSession();
+ }
- @Property
- public void setGallery(String gallery) {
- this.gallery = gallery;
- this.location = null;
- }
+ @Property
+ public void setGallery(String gallery) {
+ this.gallery = gallery;
+ this.location = null;
+ }
- public String getName() {
- return name;
- }
+ public String getName() {
+ return name;
+ }
- @Property
- public void setName(String name) {
- this.name = name;
- this.location = null;
- }
+ @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");
- }
+ 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;
- }
+ } 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();
- }
+ @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 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 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();
+ 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();
- }
+ 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;
- }
+ 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 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 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();
- }
- }
+ 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 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);
- }
- }
+ /**
+ * 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);
+ }
+ }
}
diff --git a/photark/src/main/java/org/apache/photark/services/album/Album.java b/photark/src/main/java/org/apache/photark/services/album/Album.java
index 7e5ac38..8a5ca05 100644
--- a/photark/src/main/java/org/apache/photark/services/album/Album.java
+++ b/photark/src/main/java/org/apache/photark/services/album/Album.java
@@ -25,23 +25,23 @@
@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
diff --git a/photark/src/main/java/org/apache/photark/services/album/AlbumAgregator.java b/photark/src/main/java/org/apache/photark/services/album/AlbumAgregator.java
index 9980fab..01d0dc3 100644
--- a/photark/src/main/java/org/apache/photark/services/album/AlbumAgregator.java
+++ b/photark/src/main/java/org/apache/photark/services/album/AlbumAgregator.java
@@ -27,35 +27,35 @@
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 @@
//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 @@
//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){
- }
+ }
}
diff --git a/photark/src/main/java/org/apache/photark/services/album/ImageFilter.java b/photark/src/main/java/org/apache/photark/services/album/ImageFilter.java
index 1740046..fe77b5b 100644
--- a/photark/src/main/java/org/apache/photark/services/album/ImageFilter.java
+++ b/photark/src/main/java/org/apache/photark/services/album/ImageFilter.java
@@ -29,8 +29,8 @@
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