PHOTARK-26 Applying patch from Suhothayan Sriskandarajah.Support for delete,edit and update albums and pictures
git-svn-id: https://svn.apache.org/repos/asf/incubator/photark/trunk@935448 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/photark-filesystem/src/main/java/org/apache/photark/filesystem/impl/AlbumImpl.java b/photark-filesystem/src/main/java/org/apache/photark/filesystem/impl/AlbumImpl.java
index a2ceb68..bc216e9 100644
--- a/photark-filesystem/src/main/java/org/apache/photark/filesystem/impl/AlbumImpl.java
+++ b/photark-filesystem/src/main/java/org/apache/photark/filesystem/impl/AlbumImpl.java
@@ -31,72 +31,76 @@
public class AlbumImpl implements Album {
- private String name;
- private String location;
- private String description;
- private boolean initialized;
- private List<String> pictures = new ArrayList<String>();
+ private String name;
+ private String location;
+ private String description;
+ private boolean initialized;
+ private List<String> pictures = new ArrayList<String>();
- @Init
- public void init() {
- try {
- /*
+ @Init
+ public void init() {
+ try {
+ /*
URL albumURL = this.getClass().getClassLoader().getResource(name);
if(albumURL == null) {
// Accomodate for J2EE classpath that starts in WEB-INF\classes
albumURL = this.getClass().getClassLoader().getResource("../../" + getLocation());
}*/
- if(location != null) {
- File album = new File(location);
- if (album.isDirectory() && album.exists()) {
- String[] listPictures = album.list(new ImageFilter(".jpg"));
- for(String image : listPictures) {
- pictures.add(image);
- }
- }
- }
- } catch (Exception e) {
- // FIXME: ignore for now
- e.printStackTrace();
- }
- }
-
- public String getName() {
- return name;
- }
-
- @Property
- public void setName(String name) {
- this.name = name;
- this.location = null;
- }
+ if(location != null) {
+ File album = new File(location);
+ if (album.isDirectory() && album.exists()) {
+ String[] listPictures = album.list(new ImageFilter(".jpg"));
+ for(String image : listPictures) {
+ pictures.add(image);
+ }
+ }
+ }
+ } catch (Exception e) {
+ // FIXME: ignore for now
+ e.printStackTrace();
+ }
+ }
- public String getLocation() {
- return location;
- }
-
- @Property
- public void setLocation(String location) {
- this.location = location;
- }
-
- public String[] getPictures() {
- if( ! initialized) {
- init();
- }
- String[] pictureArray = new String[pictures.size()];
- pictures.toArray(pictureArray);
- return pictureArray;
- }
-
- public void addPicture(Image picture){
- throw new UnsupportedOperationException("Not implemented");
- }
-
- public void deletePicture(Image picture){
- throw new UnsupportedOperationException("Not implemented");
- }
+ public String getName() {
+ return name;
+ }
+
+ @Property
+ public void setName(String name) {
+ this.name = name;
+ this.location = null;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ @Property
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public String[] getPictures() {
+ if( ! initialized) {
+ init();
+ }
+ String[] pictureArray = new String[pictures.size()];
+ pictures.toArray(pictureArray);
+ return pictureArray;
+ }
+
+ public void addPicture(Image picture){
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public void deletePicture(Image picture){
+ throw new UnsupportedOperationException("Not implemented");
+ }
+
+ public void deletePicture(String picture){
+ throw new UnsupportedOperationException("Not implemented");
+ }
public String getDescription() {
return description;
diff --git a/photark-filesystem/src/main/java/org/apache/photark/filesystem/impl/GalleryImpl.java b/photark-filesystem/src/main/java/org/apache/photark/filesystem/impl/GalleryImpl.java
index 65228e2..9a3bb54 100644
--- a/photark-filesystem/src/main/java/org/apache/photark/filesystem/impl/GalleryImpl.java
+++ b/photark-filesystem/src/main/java/org/apache/photark/filesystem/impl/GalleryImpl.java
@@ -81,4 +81,8 @@
public void addAlbum(String albumName){
}
+
+ public void deleteAlbum(String albumName) {
+
+ }
}
\ No newline at end of file
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 0d68e17..b6a743e 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,252 +43,276 @@
import org.oasisopen.sca.annotation.Property;
public class JCRAlbumImpl implements Album {
- private static final Logger logger = Logger.getLogger(JCRAlbumImpl.class.getName());
-
- 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 static final Logger logger = Logger.getLogger(JCRAlbumImpl.class.getName());
- public synchronized static Album createAlbum(JCRRepositoryManager repositoryManager, String name ) {
- if (!albums.containsKey(name)) {
- albums.put(name, new JCRAlbumImpl(repositoryManager,name ));
- }
- return albums.get(name);
- }
+ private JCRRepositoryManager repositoryManager;
- public JCRAlbumImpl(JCRRepositoryManager repositoryManager, String name) {
- this.repositoryManager = repositoryManager;
- this.name = 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);
- }
- }
- }
- }
+ * 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.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();
- }
+ 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);
+ }
+ }
+ }
+ }
- @Property
- public void setGallery(String gallery) {
- this.gallery = gallery;
- this.location = null;
- }
+ 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;
+ }
- public String getName() {
- return name;
- }
+ @Destroy
+ public void destroy() {
+ //repositoryManager.releaseSession();
+ }
- @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 setGallery(String gallery) {
+ this.gallery = gallery;
+ this.location = null;
+ }
- @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 getName() {
+ return name;
+ }
- public String getLocation() {
- if (location == null) {
- location = gallery + "/" + name + "/";
- }
- return location;
+ @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 void setLocation(String location) {
- logger.info("inside setLocation:location:" + location);
- this.location = location;
- }
+ } catch (Exception e) {
+ // FIXME: ignore for now
+ e.printStackTrace();
+ } finally {
+ //repositoryManager.releaseSession();
+ }
+ return description;
+ }
- 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();
+ @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();
+ }
- 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 String getLocation() {
+ if (location == null) {
+ location = gallery + "/" + name + "/";
+ }
+ return location;
- 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 setLocation(String location) {
+ logger.info("inside setLocation:location:" + location);
+ this.location = location;
+ }
- 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 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 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();
- }
- }
+ 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();
+ }
- /**
- * 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);
- }
- }
+ 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);
+ }
+ }
}
diff --git a/photark-jcr/src/main/java/org/apache/photark/jcr/services/JCRGalleryImpl.java b/photark-jcr/src/main/java/org/apache/photark/jcr/services/JCRGalleryImpl.java
index e597922..75ec9bb 100644
--- a/photark-jcr/src/main/java/org/apache/photark/jcr/services/JCRGalleryImpl.java
+++ b/photark-jcr/src/main/java/org/apache/photark/jcr/services/JCRGalleryImpl.java
@@ -135,4 +135,29 @@
//repositoryManager.releaseSession();
}
}
+
+ public void deleteAlbum(String albumName) {
+ try {
+ Session session = repositoryManager.getSession();
+ Node root = session.getRootNode();
+ if(root.hasNode(albumName)){
+ Node albumNode = root.getNode(albumName);
+ Album album = JCRAlbumImpl.createAlbum(repositoryManager, albumName);
+ if (albums.contains(album)) {
+ albums.remove(album);
+ }
+ albumNode.remove();
+ session.save();
+ //init();
+ logger.info("album " + albumName + " deleted");
+ }else{
+ logger.info("album " + albumName + " not found");
+ }
+ } catch (RepositoryException e) {
+ e.printStackTrace();
+ } finally {
+ //repositoryManager.releaseSession();
+ }
+
+ }
}
diff --git a/photark-jcr/src/main/java/org/apache/photark/jcr/services/JCRImageUploadServiceImpl.java b/photark-jcr/src/main/java/org/apache/photark/jcr/services/JCRImageUploadServiceImpl.java
index 5287300..1624e92 100644
--- a/photark-jcr/src/main/java/org/apache/photark/jcr/services/JCRImageUploadServiceImpl.java
+++ b/photark-jcr/src/main/java/org/apache/photark/jcr/services/JCRImageUploadServiceImpl.java
@@ -59,155 +59,227 @@
@Service(Servlet.class)
@Scope("COMPOSITE")
public class JCRImageUploadServiceImpl extends HttpServlet implements Servlet /*ImageUploadService*/ {
- private static final Logger logger = Logger.getLogger(JCRImageUploadServiceImpl.class.getName());
+ private static final Logger logger = Logger.getLogger(JCRImageUploadServiceImpl.class.getName());
- private static final long serialVersionUID = -7842318322982743234L;
- public static final long MAX_UPLOAD_ZIP_IN_MEGS = 30;
-
- private String supportedImageTypes[] = {".jpg", ".jpeg", ".png", ".gif"};
-
- private JCRRepositoryManager repositoryManager;
-
- private ServletFileUpload upload;
-
- private Gallery gallery;
-
- /**
- * Initialize the component.
- */
- @Init
- public void initialize() throws IOException {
- upload = new ServletFileUpload(new DiskFileItemFactory());
- upload.setSizeMax(MAX_UPLOAD_ZIP_IN_MEGS * 1024 * 1024);
- }
+ private static final long serialVersionUID = -7842318322982743234L;
+ public static final long MAX_UPLOAD_ZIP_IN_MEGS = 30;
- public JCRImageUploadServiceImpl() {
+ private String supportedImageTypes[] = {".jpg", ".jpeg", ".png", ".gif"};
- }
-
- @Reference(name="repositoryManager")
- protected void setRepositoryManager(JCRRepositoryManager repositoryManager) {
- this.repositoryManager = repositoryManager;
- }
+ private JCRRepositoryManager repositoryManager;
- @Reference(name="gallery")
- protected void setGallery(Gallery gallery) {
- this.gallery = gallery;
- }
-
- @Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- response.setContentType("text/html");
-
- PrintWriter out = response.getWriter();
- out.write("<html><body><h1>Photark Upload Service</h1></body></html>");
- }
+ private ServletFileUpload upload;
- @SuppressWarnings("unchecked")
- @Override
- public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
- response.setContentType("text/html");
+ private Gallery gallery;
- boolean isMultipartContent = ServletFileUpload.isMultipartContent(request);
- if (!isMultipartContent) {
- return;
- }
+ /**
+ * Initialize the component.
+ */
+ @Init
+ public void initialize() throws IOException {
+ upload = new ServletFileUpload(new DiskFileItemFactory());
+ upload.setSizeMax(MAX_UPLOAD_ZIP_IN_MEGS * 1024 * 1024);
+ }
- try {
- List<FileItem> fields = (List<FileItem>) upload.parseRequest(request);
- if(logger.isLoggable(Level.INFO)) {
- logger.log(Level.INFO, "Number of fields: " + fields.size());
- }
-
- Iterator<FileItem> fileItems = fields.iterator();
+ public JCRImageUploadServiceImpl() {
- if (!fileItems.hasNext()) {
- if(logger.isLoggable(Level.INFO)) {
- logger.log(Level.INFO, "No fields found");
- }
- return;
- }
+ }
- String albumName = "";
- String albumDescription= "";
- StringBuffer sb = new StringBuffer();
- while (fileItems.hasNext()) {
- FileItem fileItem = fileItems.next();
- if (fileItem.getFieldName().equalsIgnoreCase("albumName")) {
- albumName = fileItem.getString();
- }
-
- if (fileItem.getFieldName().equalsIgnoreCase("albumDescription")) {
- albumDescription = fileItem.getString();
- }
-
- boolean isFormField = fileItem.isFormField();
-
- if (!isFormField) {
- String fileName = fileItem.getName();
-
- if(logger.isLoggable(Level.INFO)) {
- logger.log(Level.INFO, "fileName:"+fileName);
- }
-
+ @Reference(name="repositoryManager")
+ protected void setRepositoryManager(JCRRepositoryManager repositoryManager) {
+ this.repositoryManager = repositoryManager;
+ }
- InputStream inStream = new BufferedInputStream(fileItem.getInputStream());
- List<Image> pictures = new ArrayList<Image>();
+ @Reference(name="gallery")
+ protected void setGallery(Gallery gallery) {
+ this.gallery = gallery;
+ }
- if (isArchive(inStream)) {
- ArchiveFileExtractor archiveFileExtractor = new ArchiveFileExtractor(supportedImageTypes);
- pictures = archiveFileExtractor.extractArchive(inStream);
- } else {
- // this is a picture file and not the archive file
- Image picture = new Image(fileName, new Date(), inStream);
- pictures.add(picture);
- }
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/html");
- for (Image picture : pictures) {
- addPictureToAlbum(albumName,albumDescription, picture);
- }
- sb.append("file=uploaded/" + fileName);
- sb.append(",name=" + fileName);
- //sb.append(",error=Not recognized file type");
- }
- }
- PrintWriter out = response.getWriter();
- out.write(sb.toString());
+ PrintWriter out = response.getWriter();
+ out.write("<html><body><h1>Photark Upload Service</h1></body></html>");
+ }
- } catch (FileUploadException e) {
- logger.info("Error uploading file : " + e.getMessage());
- response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Error uploading file : " + e.getMessage());
- } catch (Exception e) {
- logger.info("Error uploading file : " + e.getMessage());
- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error uploading file : " + e.getMessage());
- }
- }
+ @SuppressWarnings("unchecked")
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ response.setContentType("text/html");
- /**
- * @param albumName String
- * @param picture Picture
- */
- private void addPictureToAlbum(String albumName,String albumDescription, Image image) {
- gallery.addAlbum(albumName);
- Album album = new JCRAlbumImpl(repositoryManager, albumName);
- album.addPicture(image);
- album.setDescription(albumDescription);
- }
-
- /**
- * Test whether this stream is of archive or not
- *
- * @param inStream InputStream
- * @return boolean
- */
- private static boolean isArchive(InputStream inStream) {
- ArchiveStreamFactory streamFactory = new ArchiveStreamFactory();
- try {
- streamFactory.createArchiveInputStream(inStream);
- return true;
- } catch (ArchiveException e) {
- logger.info("File is not an archive");
- }
- return false;
- }
+ boolean isMultipartContent = ServletFileUpload.isMultipartContent(request);
+ if (!isMultipartContent) {
+ try {
+ String albumName ="";
+ String albumDescription ="";
+ //StringBuffer sb = new StringBuffer();
+ albumName= (String) request.getParameter("albumName");
+ albumDescription= (String) request.getParameter("addAlbumDesc");
+
+ if(albumDescription!=null){
+ addDescToAlbum(albumName,albumDescription);
+ if(logger.isLoggable(Level.INFO)) {
+ logger.log(Level.INFO, "album description updated in " + albumName+" with "+albumDescription);
+ }
+ PrintWriter out = response.getWriter();
+ out.write("albumDescription updated in " + albumName+" with "+albumDescription);
+ out.close();
+ return;
+ }else{
+ return;
+ }
+ } catch (Exception e) {
+ logger.info("Error adding albumDesc : " + e.getMessage());
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error adding albumDesc : " + e.getMessage());
+ }
+ }
+
+ try {
+ List<FileItem> fields = (List<FileItem>) upload.parseRequest(request);
+ if(logger.isLoggable(Level.INFO)) {
+ logger.log(Level.INFO, "Number of fields: " + fields.size());
+ }
+
+ Iterator<FileItem> fileItems = fields.iterator();
+
+ if (!fileItems.hasNext()) {
+ if(logger.isLoggable(Level.INFO)) {
+ logger.log(Level.INFO, "No fields found");
+ }
+ return;
+ }
+
+ String albumName = "";
+ String albumDescription= "";
+ StringBuffer sb = new StringBuffer();
+ while (fileItems.hasNext()) {
+ FileItem fileItem = fileItems.next();
+ if (fileItem.getFieldName().equalsIgnoreCase("albumName")) {
+ albumName = fileItem.getString();
+ }
+
+ if (fileItem.getFieldName().equalsIgnoreCase("albumDescription")) {
+ albumDescription = fileItem.getString();
+ }
+
+ boolean isFormField = fileItem.isFormField();
+
+ if (!isFormField) {
+ String fileName = fileItem.getName();
+
+ if(logger.isLoggable(Level.INFO)) {
+ logger.log(Level.INFO, "fileName:"+fileName);
+ }
+
+
+ InputStream inStream = new BufferedInputStream(fileItem.getInputStream());
+ List<Image> pictures = new ArrayList<Image>();
+
+ if (isArchive(inStream)) {
+ ArchiveFileExtractor archiveFileExtractor = new ArchiveFileExtractor(supportedImageTypes);
+ pictures = archiveFileExtractor.extractArchive(inStream);
+ } else {
+ // this is a picture file and not the archive file
+ Image picture = new Image(fileName, new Date(), inStream);
+ pictures.add(picture);
+ }
+
+ for (Image picture : pictures) {
+ addPictureToAlbum(albumName,albumDescription, picture);
+ }
+ sb.append("file=uploaded/" + fileName);
+ sb.append(",name=" + fileName);
+ //sb.append(",error=Not recognized file type");
+ }
+ }
+
+ PrintWriter out = response.getWriter();
+ out.write(sb.toString());
+
+ } catch (FileUploadException e) {
+ logger.info("Error uploading file : " + e.getMessage());
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Error uploading file : " + e.getMessage());
+ } catch (Exception e) {
+ logger.info("Error uploading file : " + e.getMessage());
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error uploading file : " + e.getMessage());
+ }
+ }
+
+ @Override
+ protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/html");
+
+ String albumName ="";
+ String imageName ="";
+ //StringBuffer sb = new StringBuffer();
+ albumName= (String) request.getParameter("albumName");
+ imageName= (String) request.getParameter("imageName");
+
+
+ deleteNode(albumName, imageName);
+ PrintWriter out = response.getWriter();
+
+ //sb.append("deleted " + albumName+"/"+imageName);
+ //out.write(sb.toString());
+ out.write("deleted " + albumName+"/"+imageName);
+ out.close();
+
+ }
+
+ /**
+ * @param albumName String
+ * @param picture Picture
+ * @param String albumDescription
+ */
+ private void addPictureToAlbum(String albumName,String albumDescription, Image image) {
+ gallery.addAlbum(albumName);
+ Album album = new JCRAlbumImpl(repositoryManager, albumName);
+ album.addPicture(image);
+ album.setDescription(albumDescription);
+ }
+
+ /**
+ * @param albumName String
+ * @param picture Picture
+ * @param String albumDescription
+ */
+ private void addDescToAlbum(String albumName,String albumDescription) {
+ gallery.addAlbum(albumName);
+ Album album = new JCRAlbumImpl(repositoryManager, albumName);
+ album.setDescription(albumDescription);
+ }
+
+
+ /**
+ *
+ * @param String albumName
+ * @param String imageName
+ */
+ private void deleteNode(String albumName, String imageName) {
+ if(imageName==null){
+ gallery.deleteAlbum(albumName);
+
+ }else{
+ Album album = new JCRAlbumImpl(repositoryManager, albumName);
+ album.deletePicture(imageName);
+ }
+ }
+
+ /**
+ * Test whether this stream is of archive or not
+ *
+ * @param inStream InputStream
+ * @return boolean
+ */
+ private static boolean isArchive(InputStream inStream) {
+ ArchiveStreamFactory streamFactory = new ArchiveStreamFactory();
+ try {
+ streamFactory.createArchiveInputStream(inStream);
+ return true;
+ } catch (ArchiveException e) {
+ logger.info("File is not an archive");
+ }
+ return false;
+ }
}
diff --git a/photark-ui-admin/src/main/webapp/admin/upload.css b/photark-ui-admin/src/main/webapp/admin/upload.css
index f98b889..c125d75 100644
--- a/photark-ui-admin/src/main/webapp/admin/upload.css
+++ b/photark-ui-admin/src/main/webapp/admin/upload.css
@@ -54,7 +54,7 @@
#newAlbum {
clear: both;
- width: 80%;
+ width: 905px;
background-color: #F2EFE9;
}
@@ -72,7 +72,7 @@
fieldset {
/*float: left;*/
clear: both;
- width: 80%;
+ /*width: 80%;*/
length:
/*margin: 0 0 -1em 0;*/
/*padding: 0 0 1em 0;*/
@@ -93,4 +93,11 @@
padding-bottom: 1em;
list-style:none;
}
+
+ #adminGallery{
+ width: 905px;
+ background-color:#F2EFE9;
+ border-bottom: 2px solid #BFBAB0;
+ padding-top: 40px;
+}
diff --git a/photark-ui-admin/src/main/webapp/admin/upload.html b/photark-ui-admin/src/main/webapp/admin/upload.html
index 5ff9b33..304fdcf 100644
--- a/photark-ui-admin/src/main/webapp/admin/upload.html
+++ b/photark-ui-admin/src/main/webapp/admin/upload.html
@@ -60,16 +60,25 @@
<script type="text/javascript">
//gallery json-rpc service
dojo.require("dojo.rpc.JsonService");
+ dojo.require("dojo._base.xhr");
+
+ var albumCover;
+ var albums;
+ var albumName="New Album";
+ var albumIndex;
+ var albumDescEditOn=false;
+ var albumDesc="";
var gallery = new dojo.rpc.JsonService( photark.constants.GalleryServiceEndpoint );
-
+
function populateSelect(){
+ gallery = new dojo.rpc.JsonService( photark.constants.GalleryServiceEndpoint );
gallery.getAlbums().addCallback( function(albums, exception) {
if(exception) {
alert(exception.msg);
return;
}
-
+ this.albums=albums;
var selectAlbum = dojo.byId("selectAlbum");
selectAlbum.options.length=0;
@@ -77,52 +86,201 @@
for(var pos = 0; pos<albums.length; pos++) {
selectAlbum.options[selectAlbum.options.length] = new Option(albums[pos].name, albums[pos].name, false, false);
}
+ dojo.byId("selectAlbum").value=albumName;
+ manageAlbumFields();
});
}
- // only shows the new album field when "new album" is selected from the dropdown
+ //to set the album cover
+ function setAlbumCoverResponse(cover, exception) {
+ if(exception){
+ alert(exception.msg);
+ return;
+ }
+ document.getElementById('albumCoverDiv').innerHTML = "<table id='albumCover' style='width:200px;' border='0' cellspacing='0' cellpadding='1'></table>";
+
+ var table=document.getElementById('albumCover');
+ var row = table.insertRow(0);
+ var column = row.insertCell(0);
+ if (cover != null) {
+ var img = document.createElement("img");
+ img.src = (window.location.href).replace("admin/upload.html","") + "gallery/"+ albumName +"/" + cover;
+ var img_html = "<img src=" + img.src + " class=\"slideImage\" width=200px ondragstart=\"return false\" onselectstart=\"return false\" oncontextmenu=\"return false\" galleryimg=\"no\" usemap=\"#imagemap\" alt=\"\"/>";
+ var html = "<table border=\"0\" style=\"width:180px; text-align: center;\"><tr style=\"cellpadding:10\"><td><a>" + img_html + "</a></td></tr><tr><td>"+albumName+"</td></tr></table>";
+ column.innerHTML = html;
+ }
+ }
+
+ function initializeAdminGallery() {
+ var table=document.getElementById('adminTableGallery');
+ var lastRow = table.rows.length;
+ for (var i = 0; i < albums[albumIndex].pictures.length;) {
+ var row = table.insertRow( Math.floor(i/4));
+ for (var j = 0; j < 4;j++) {
+ var column = row.insertCell(i%4);
+ if (albums[albumIndex].pictures[i] != null) {
+ var albumName = albums[albumIndex].name;
+ var img = document.createElement("img");
+ img.src = (window.location.href).replace("admin/upload.html","") + "gallery/"+ albumName +"/" + albums[albumIndex].pictures[i];
+ var img_html = "<img src=" + img.src + " class=\"slideImage\" width=200px ondragstart=\"return false\" onselectstart=\"return false\" oncontextmenu=\"return false\" galleryimg=\"no\" usemap=\"#imagemap\" alt=\"\"/>";
+ var html = "<table border=\"0\" style=\"width:180px; text-align: center;\"><tr style=\"cellpadding:10\"><td colspan=\"2\"><a>" + img_html + "</a></td></tr><tr><td>"+albums[albumIndex].pictures[i]+"</td><td><a href=\"javascript:confirmDelete('"+albums[albumIndex].pictures[i]+"');\">Remove</a></td></tr></table>";
+ column.innerHTML = html;
+ }
+ i++;
+ }
+
+ }
+ }
+
function manageAlbumFields(){
var selectAlbum = dojo.byId("selectAlbum");
- var selected = selectAlbum.value;
- if(selected == "New Album") {
- dojo.byId("newAlbumName").style.display = "";
- dojo.byId("albumDescription").value="";
+ albumName = selectAlbum.value;
+ document.getElementById('adminGallery').innerHTML = "<table id='adminTableGallery' style='width:720px;' border='0' cellspacing='0' cellpadding='1'></table>";
+ albumIndex=selectAlbum.selectedIndex-1;
+ cancelAlbumDesc();
+ dojo.byId("progressBar").style.display="none";
+
+ if(albumName == "New Album") {
+ document.getElementById('albumCoverDiv').innerHTML = "<table id='albumCover' style='width:200px;' border='0' cellspacing='0' cellpadding='1'></table>";
+ dojo.byId("newAlbumName").style.display = "";
+ dojo.byId("newAlbumLabel").style.display = "";
+ dojo.byId("btnAlbumDesc").style.display = "none";
+ dojo.byId("deleteAlbum").style.display = "none";
+ dojo.byId("albumDescriptionDiv").innerHTML="<textarea cols='20' rows='5' class='textarea' name='albumDescription' id='albumDescription'></textarea>";
}else{
- dojo.byId("newAlbumName").style.display = "none";
- gallery.getAlbums().addCallback( function(albums, exception) {
- if(exception) {
- alert(exception.msg);
- return;
- }
- dojo.byId("albumDescription").value=albums[selectAlbum.selectedIndex-1].description;
- });
+ dojo.byId("newAlbumName").style.display = "none";
+ dojo.byId("newAlbumLabel").style.display = "none";
+ dojo.byId("btnAlbumDesc").style.display = "";
+ dojo.byId("deleteAlbum").style.display = "";
+ gallery.getAlbums().addCallback( function(albums, exception) {
+ if(exception) {
+ alert(exception.msg);
+ return;
+ }
+ dojo.byId("albumDescription").value=albums[selectAlbum.selectedIndex-1].description;
+ gallery.getAlbumCover(albums[albumIndex].name).addCallback(setAlbumCoverResponse);
+ initializeAdminGallery();
+ });
+ dojo.byId("albumDescription").value="";
}
}
+ //this method will delete the selected image from the current album
+ function addAlbumDesc(){
+ if(albumDescEditOn==false){
+ albumDescEditOn=true;
+ albumDesc=dojo.byId("albumDescription").value;
+ dojo.byId("albumDescriptionDiv").innerHTML="<textarea cols='20' rows='5' class='textarea' name='albumDescription' id='albumDescription'></textarea>";
+ dojo.byId("albumDescription").value=albumDesc;
+ dojo.byId("albumDescription").focus();
+ dojo.byId("btnAlbumDesc").innerHTML="Save album Description";
+ dojo.byId("cancelBtnAlbumDesc").style.display="";
+ }else{
+ var desc=dojo.byId("albumDescription").value;
+ cancelAlbumDesc();
+
+ dojo.xhrPost({
+ url:"upload",
+ content:{albumName:albumName,addAlbumDesc:desc},
+ handleAs: "text",
+ load: function(response, ioArgs){
+ reloadAdminGallery();
+ },
+ error: function(response, ioArgs){
+ console.error("Error in editing album description");
+ }
+ });
+ }
+ }
+
+ //to cancel the editing of the albumDescription
+ function cancelAlbumDesc(){
+ dojo.byId("albumDescriptionDiv").innerHTML="<textarea cols='20' rows='5' class='textarea' name='albumDescription' id='albumDescription' readonly='readonly' style='background-color:#F4F2F2;'></textarea>";
+ dojo.byId("albumDescription").value=albumDesc;
+ dojo.byId("btnAlbumDesc").innerHTML="Edit album Description";
+ dojo.byId("cancelBtnAlbumDesc").style.display="none";
+ albumDescEditOn=false;
+ }
+
+ //this method will delete the selected image from the current album
+ function removeImage(imageName){
+ dojo.xhrDelete({
+ url:"upload",
+ content:{imageName:imageName,albumName:albumName},
+ handleAs: "text",
+ load: function(response, ioArgs){
+ reloadAdminGallery();
+ },
+ error: function(response, ioArgs){
+ console.error("Error in deleting file");
+ }
+ });
+ }
+
+ function reloadAdminGallery(){
+ gallery = new dojo.rpc.JsonService( photark.constants.GalleryServiceEndpoint );
+ populateSelect();
+ }
+
+ //confirm before deletion
+ function confirmDelete(item ){
+ var r;
+ if(item==undefined){
+ r=confirm("Are you sure to delete the album "+albumName+"?");
+ }else{
+ r=confirm("Are you sure to delete the image "+item+"?");
+ }
+ if (r==true){
+ removeImage(item);
+ }
+ }
+
dojo.addOnLoad( function() {
populateSelect();
- dojo.byId("albumDescription").value="";
+
});
+
</script>
</head>
<body>
+ <center>
<div id="newAlbum">
- <fieldset id="newAlbumDetails">
+ <fieldset id="newAlbumDetails" style="text-align: left;">
<legend>Album Details</legend>
<ol>
<li>
<label for="selectAlbum">Select Album:</label>
- <select id="selectAlbum" name="selectAlbum" autoComplete="true" onChange="manageAlbumFields();"/>
- <label>New Album:</label>
+ <select id="selectAlbum" name="selectAlbum" autoComplete="true" onChange="manageAlbumFields();"></select>
+ <label id="newAlbumLabel">New Album:</label>
<input type="text" class="text" name="newAlbumName" id="newAlbumName">
+ <button type="button" name="deleteAlbum" id="deleteAlbum" onClick="confirmDelete(null);" >Delete Album</button>
</li>
<li>
- <label for="albumDescription">Album Description</label>
- <textarea cols="25" rows="5" class="textarea" name="albumDescription" id="albumDescription" />
- </textarea>
+ <table border="0">
+ <tr>
+ <td>
+ <div id="albumCoverDiv">
+
+ </div>
+ </td>
+ <td>
+ <label for="albumDescriptionDiv">Album Description</label>
+ <div id="albumDescriptionDiv" >
+
+ </div>
+ </td>
+ </tr>
+ <tr>
+ <td></td>
+ <td>
+ <div id="btnAlbumDesc" class="uploadBtn btn" onClick="addAlbumDesc();" style="float: right;" >Edit album Description</div>
+ <div id="cancelBtnAlbumDesc" class="uploadBtn btn" onClick="cancelAlbumDesc();" style="float: right;" >Cancel</div>
+ </td>
+ </tr>
+ </table>
</li>
<li>
<label>Files:</label>
@@ -134,12 +292,16 @@
<div id="progressBar" dojoType="dijit.ProgressBar" style="width:300px;display:none;" jsId="jsProgress"></div>
</div>
</li>
- <li>
- <div id="btnUploader" class="uploadBtn btn" >Select Files</div>
- <div id="btnUpload" class="uploadBtn btn" onClick="doUpload();">Upload</div>
+ <li >
+ <div id="btnUploader" class="uploadBtn btn" >Select Files</div>
+ <div id="btnUpload" class="uploadBtn btn" onClick="doUpload();">Upload</div>
</li>
</ol>
</fieldset>
</div>
+ <div id='adminGallery'>
+
+ </div>
+ </center>
</body>
</html>
\ No newline at end of file
diff --git a/photark-ui-admin/src/main/webapp/admin/upload.js b/photark-ui-admin/src/main/webapp/admin/upload.js
index 645b6a1..c12b3a6 100644
--- a/photark-ui-admin/src/main/webapp/admin/upload.js
+++ b/photark-ui-admin/src/main/webapp/admin/upload.js
@@ -78,16 +78,23 @@
doUpload = function(){
console.log("doUpload");
displayProgress();
+ var files= dojo.byId("files").childElementCount;
var selectAlbum = dojo.byId("selectAlbum");
var selected = selectAlbum.value;
+ albumName=selected;
var albumDescription= dojo.byId("albumDescription").value;
console.log("selected:"+selected);
- if(selected == null || (selected != null && selected == "" && selected.length == 0)) {
+ if(files == 0) {//to stop upload when on files are selected
+ alert("Photo Upload can not be started. Select picture(s) before upload");
+ dojo.byId("progressBar").style.display="none";
+ } else if(selected == null || (selected != null && selected == "" && selected.length == 0)) {
alert("Photo Upload can not be started.Select Album before upload");
+ dojo.byId("progressBar").style.display="none";
} else if(selected == "New Album") {
- var albumName = dojo.byId("newAlbumName").value;
+ albumName = dojo.byId("newAlbumName").value;
if( albumName == null || (albumName != null && albumName == "" && albumName.length == 0)) {
alert("Photo Upload can not be started.Enter the new album name");
+ dojo.byId("progressBar").style.display="none";
} else {
//add new album to list of albums
selectAlbum.options[selectAlbum.options.length] = new Option(albumName, albumName, false, false);
@@ -107,6 +114,7 @@
console.log("onComplete");
setProgressbar(1,1);
dojo.byId("newAlbumName").value ="";
+ reloadAdminGallery();
});
dojo.connect(uploader, "onProgress", function(dataArray){
diff --git a/photark-ui/src/main/webapp/gallery.html b/photark-ui/src/main/webapp/gallery.html
index 050ccd8..9e8fe6a 100644
--- a/photark-ui/src/main/webapp/gallery.html
+++ b/photark-ui/src/main/webapp/gallery.html
@@ -68,7 +68,7 @@
}
gallery.getAlbums().addCallback(gallery_getAlbumsResponse);
} catch(exception) {
- alert(e);
+ alert(exception);
}
}
@@ -112,7 +112,7 @@
var albumName = galleryAlbums[i].name;
var img = document.createElement("img");
img.src = window.location.href + "gallery/"+ albumName +"/" + albumCovers[i];
- var img_html = "<img src=" + img.src + " class=\"slideImage\" height=85% width=85% ondragstart=\"return false\" onselectstart=\"return false\" oncontextmenu=\"return false\" galleryimg=\"no\" usemap=\"#imagemap\" alt=\"\"/>";
+ var img_html = "<img src=" + img.src + " class=\"slideImage\" width=180px ondragstart=\"return false\" onselectstart=\"return false\" oncontextmenu=\"return false\" galleryimg=\"no\" usemap=\"#imagemap\" alt=\"\"/>";
var html = "<a href=\"javascript:initializeAlbum('" + albumName + "')\">" + img_html + "</a>";
column.innerHTML = html;
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 44d5671..7e5ac38 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
@@ -24,22 +24,24 @@
@Remotable
public interface Album {
-
- String getName();
-
- void setName(String name);
-
- String getDescription();
-
- void setDescription(String description);
-
- String getLocation();
-
- void setLocation(String location);
-
- String[] getPictures();
-
- void addPicture(Image picture);
-
- void deletePicture(Image picture);
+
+ String getName();
+
+ void setName(String name);
+
+ String getDescription();
+
+ void setDescription(String description);
+
+ String getLocation();
+
+ void setLocation(String location);
+
+ String[] getPictures();
+
+ void addPicture(Image picture);
+
+ void deletePicture(String 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 06a8ff2..f73b806 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,40 +27,40 @@
import org.oasisopen.sca.annotation.Reference;
public class AlbumAgregator implements Album {
- private static String NAME = "Aggregated Album";
-
- private List<String> pictures = new ArrayList<String>();
-
- @Reference(required=false)
- protected Album album;
-
- @Reference(required=false)
- protected org.apache.tuscany.sca.binding.atom.collection.Collection albumFeed;
-
- /* FIXME: GData support not available in Tuscany 2.x
+ private static String NAME = "Aggregated Album";
+
+ private List<String> pictures = new ArrayList<String>();
+
+ @Reference(required=false)
+ protected Album album;
+
+ @Reference(required=false)
+ protected org.apache.tuscany.sca.binding.atom.collection.Collection albumFeed;
+
+ /* 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);
- }
- }
-
- if (albumFeed != null) {
- try {
- for(org.apache.abdera.model.Entry feedPicture : albumFeed.getFeed().getEntries()) {
- String feedImageLink = feedPicture.getEnclosureLinkResolvedHref().toString();
- pictures.add(feedImageLink);
- }
- }catch (Exception e) {
- //log exception, warn user that album xxx was not processed (not found)
- }
- }
- /* FIXME: GData support not available in Tuscany 2.x
+ */
+
+ @Init
+ public void init() {
+ if(album != null) {
+ for(String picture : album.getPictures()) {
+ pictures.add(picture);
+ }
+ }
+
+ if (albumFeed != null) {
+ try {
+ for(org.apache.abdera.model.Entry feedPicture : albumFeed.getFeed().getEntries()) {
+ String feedImageLink = feedPicture.getEnclosureLinkResolvedHref().toString();
+ pictures.add(feedImageLink);
+ }
+ }catch (Exception e) {
+ //log exception, warn user that album xxx was not processed (not found)
+ }
+ }
+ /* FIXME: GData support not available in Tuscany 2.x
if( albumPicassa != null) {
try {
for(com.google.gdata.data.Entry picassaPicture : albumPicassa.getFeed().getEntries()) {
@@ -71,46 +71,50 @@
//log exception, warn user that album xxx was not processed (not found)
}
}
- */
-
- }
-
- public String getName() {
- return NAME;
- }
-
- public void setName(String name) {
- throw new UnsupportedOperationException();
- }
-
- public String getDescription(){
- throw new UnsupportedOperationException();
- }
-
- public void setDescription(String description){
- throw new UnsupportedOperationException();
- }
-
- public String getLocation() {
- 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 void addPicture(Image picture){
-
- }
-
- public void deletePicture(Image picture){
-
- }
+ }
+
+ public String getName() {
+ return NAME;
+ }
+
+ public void setName(String name) {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getDescription(){
+ throw new UnsupportedOperationException();
+ }
+
+ public void setDescription(String description){
+ throw new UnsupportedOperationException();
+ }
+
+ public String getLocation() {
+ 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 void addPicture(Image picture){
+
+ }
+
+ public void deletePicture(Image picture){
+
+ }
+
+ public void deletePicture(String picture){
+
+ }
}
diff --git a/photark/src/main/java/org/apache/photark/services/gallery/Gallery.java b/photark/src/main/java/org/apache/photark/services/gallery/Gallery.java
index 026387f..02176ce 100644
--- a/photark/src/main/java/org/apache/photark/services/gallery/Gallery.java
+++ b/photark/src/main/java/org/apache/photark/services/gallery/Gallery.java
@@ -30,6 +30,8 @@
void addAlbum(String albumName);
+ void deleteAlbum(String albumName);
+
Album[] getAlbums();
String getAlbumCover(String albumName);