You are viewing a plain text version of this content. The canonical link for it is here.
Posted to photark-commits@incubator.apache.org by lr...@apache.org on 2011/06/04 06:58:26 UTC
svn commit: r1131336 - in /incubator/photark/branches/photark-rest:
photark-jcr/src/main/java/org/apache/photark/services/jcr/
photark-jcr/src/test/java/org/apache/photark/services/jcr/
photark-jcr/src/test/resources/gallery-home/ photark-jcr/src/test/...
Author: lresende
Date: Sat Jun 4 06:58:25 2011
New Revision: 1131336
URL: http://svn.apache.org/viewvc?rev=1131336&view=rev
Log:
Starting to support photo upload in the rest branch
Added:
incubator/photark/branches/photark-rest/photark-jcr/src/main/java/org/apache/photark/services/jcr/JCRImageService.java (with props)
incubator/photark/branches/photark-rest/photark-jcr/src/test/resources/gallery-home/
incubator/photark/branches/photark-rest/photark-jcr/src/test/resources/gallery-home/album-1/
incubator/photark/branches/photark-rest/photark-jcr/src/test/resources/gallery-home/album-1/IMG_0735.jpg (with props)
incubator/photark/branches/photark-rest/photark-jcr/src/test/resources/gallery-home/album-2/
incubator/photark/branches/photark-rest/photark-jcr/src/test/resources/gallery-home/album-2/IMG_0735.jpg (with props)
incubator/photark/branches/photark-rest/photark/src/main/java/org/apache/photark/services/ImageService.java (contents, props changed)
- copied, changed from r1131335, incubator/photark/branches/photark-rest/photark/src/main/java/org/apache/photark/services/ImageUploadService.java
Removed:
incubator/photark/branches/photark-rest/photark/src/main/java/org/apache/photark/services/ImageUploadService.java
Modified:
incubator/photark/branches/photark-rest/photark-jcr/src/test/java/org/apache/photark/services/jcr/JCRGalleryTestCase.java
Added: incubator/photark/branches/photark-rest/photark-jcr/src/main/java/org/apache/photark/services/jcr/JCRImageService.java
URL: http://svn.apache.org/viewvc/incubator/photark/branches/photark-rest/photark-jcr/src/main/java/org/apache/photark/services/jcr/JCRImageService.java?rev=1131336&view=auto
==============================================================================
--- incubator/photark/branches/photark-rest/photark-jcr/src/main/java/org/apache/photark/services/jcr/JCRImageService.java (added)
+++ incubator/photark/branches/photark-rest/photark-jcr/src/main/java/org/apache/photark/services/jcr/JCRImageService.java Sat Jun 4 06:58:25 2011
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.photark.services.jcr;
+
+import java.io.InputStream;
+import java.util.logging.Logger;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.photark.services.ImageService;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+@Scope("COMPOSITE")
+public class JCRImageService implements ImageService {
+ private static final Logger logger = Logger.getLogger(JCRImageService.class.getName());
+
+ private static String supportedImageTypes[] = {".jpg", ".jpeg", ".png", ".gif"};
+
+ @Reference(name="repositoryManager")
+ private JCRRepositoryManager repositoryManager;
+
+ public void uploadImage(InputStream imageStream) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Response getImage(String imageKey) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+}
Propchange: incubator/photark/branches/photark-rest/photark-jcr/src/main/java/org/apache/photark/services/jcr/JCRImageService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/photark/branches/photark-rest/photark-jcr/src/main/java/org/apache/photark/services/jcr/JCRImageService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/photark/branches/photark-rest/photark-jcr/src/test/java/org/apache/photark/services/jcr/JCRGalleryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/photark/branches/photark-rest/photark-jcr/src/test/java/org/apache/photark/services/jcr/JCRGalleryTestCase.java?rev=1131336&r1=1131335&r2=1131336&view=diff
==============================================================================
--- incubator/photark/branches/photark-rest/photark-jcr/src/test/java/org/apache/photark/services/jcr/JCRGalleryTestCase.java (original)
+++ incubator/photark/branches/photark-rest/photark-jcr/src/test/java/org/apache/photark/services/jcr/JCRGalleryTestCase.java Sat Jun 4 06:58:25 2011
@@ -1,6 +1,7 @@
package org.apache.photark.services.jcr;
import java.io.ByteArrayInputStream;
+import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -17,13 +18,16 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
+import org.xml.sax.SAXException;
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.PostMethodWebRequest;
import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebRequest;
import com.meterware.httpunit.WebResponse;
+import com.meterware.httpunit.protocol.UploadFileSpec;
public class JCRGalleryTestCase {
private static final String GALLERY_SERVICE_URL = "http://localhost:8085/gallery";
@@ -76,6 +80,19 @@ public class JCRGalleryTestCase {
}
@Test
+ @Ignore
+ public void testUploadImage() throws IOException, JSONException, SAXException {
+ WebConversation wc = new WebConversation();
+ WebRequest request = new PostMethodWebRequest(ALBUM_SERVICE_URL + "/" + getLastAlbumName() + "/images");
+
+ File image = new File("gallery-root/IMG_0735.jpg");
+ final UploadFileSpec ufs = new UploadFileSpec(image,"image/jpeg");
+ request.setParameter("document", new UploadFileSpec[]{ufs});
+
+ WebResponse response = wc.getResponse(request);
+ }
+
+ @Test
public void testRemoveAlbums() throws IOException, JSONException {
WebConversation wc = new WebConversation();
WebRequest request = new GetMethodWebRequest(ALBUM_SERVICE_URL + "/" + getLastAlbumName());
Added: incubator/photark/branches/photark-rest/photark-jcr/src/test/resources/gallery-home/album-1/IMG_0735.jpg
URL: http://svn.apache.org/viewvc/incubator/photark/branches/photark-rest/photark-jcr/src/test/resources/gallery-home/album-1/IMG_0735.jpg?rev=1131336&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/photark/branches/photark-rest/photark-jcr/src/test/resources/gallery-home/album-1/IMG_0735.jpg
------------------------------------------------------------------------------
svn:mime-type = image/jpeg
Added: incubator/photark/branches/photark-rest/photark-jcr/src/test/resources/gallery-home/album-2/IMG_0735.jpg
URL: http://svn.apache.org/viewvc/incubator/photark/branches/photark-rest/photark-jcr/src/test/resources/gallery-home/album-2/IMG_0735.jpg?rev=1131336&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/photark/branches/photark-rest/photark-jcr/src/test/resources/gallery-home/album-2/IMG_0735.jpg
------------------------------------------------------------------------------
svn:mime-type = image/jpeg
Copied: incubator/photark/branches/photark-rest/photark/src/main/java/org/apache/photark/services/ImageService.java (from r1131335, incubator/photark/branches/photark-rest/photark/src/main/java/org/apache/photark/services/ImageUploadService.java)
URL: http://svn.apache.org/viewvc/incubator/photark/branches/photark-rest/photark/src/main/java/org/apache/photark/services/ImageService.java?p2=incubator/photark/branches/photark-rest/photark/src/main/java/org/apache/photark/services/ImageService.java&p1=incubator/photark/branches/photark-rest/photark/src/main/java/org/apache/photark/services/ImageUploadService.java&r1=1131335&r2=1131336&rev=1131336&view=diff
==============================================================================
--- incubator/photark/branches/photark-rest/photark/src/main/java/org/apache/photark/services/ImageUploadService.java (original)
+++ incubator/photark/branches/photark-rest/photark/src/main/java/org/apache/photark/services/ImageService.java Sat Jun 4 06:58:25 2011
@@ -6,20 +6,24 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
- * under the License.
+ * under the License.
*/
package org.apache.photark.services;
-import javax.servlet.Servlet;
+import java.io.InputStream;
+
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
import org.oasisopen.sca.annotation.Remotable;
@@ -27,6 +31,13 @@ import org.oasisopen.sca.annotation.Remo
* @version $Rev$ $Date$
*/
@Remotable
-public interface ImageUploadService extends Servlet {
+public interface ImageService {
+
+ @POST
+ @Path("/images")
+ void uploadImage(InputStream imageStream);
+
+
+ Response getImage(String imageKey);
}
Propchange: incubator/photark/branches/photark-rest/photark/src/main/java/org/apache/photark/services/ImageService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/photark/branches/photark-rest/photark/src/main/java/org/apache/photark/services/ImageService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date