Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated the application to support uploads.

  • Loading branch information...
commit bd8c0e0631089847faea791e5a2e6ed515a8809e 1 parent a8a7986
Josh Long joshlong authored
Showing with 697 additions and 564 deletions.
  1. +30 −0 batch-importer/README.txt
  2. +148 −142 core/src/main/java/org/springframework/social/flickr/api/PhotoOperations.java
  3. +255 −204 core/src/main/java/org/springframework/social/flickr/api/impl/PhotoTemplate.java
  4. +9 −0 core/src/test/resources/log4j.properties
  5. +13 −3 web/pom.xml
  6. +114 −110 web/src/main/java/org/springframework/social/flickr/HomeController.java
  7. +47 −21 web/src/main/java/org/springframework/social/flickr/config/MainConfig.java
  8. +23 −24 web/src/main/java/org/springframework/social/flickr/config/SocialConfig.java
  9. +1 −0  web/src/main/java/org/springframework/social/flickr/config/WebMvcConfig.java
  10. +0 −2  web/src/main/java/org/springframework/social/flickr/config/flickr.properties
  11. +0 −5 web/src/main/java/org/springframework/social/flickr/user/User.java
  12. +1 −2  web/src/main/java/org/springframework/social/flickr/user/UserInterceptor.java
  13. +17 −2 web/src/main/resources/org/springframework/social/flickr/config/flickr.properties
  14. 0  web/src/main/webapp/{ → WEB-INF/jsp}/signin.jsp
  15. +39 −0 web/src/main/webapp/WEB-INF/jsp/welcome.jsp
  16. +0 −35 web/src/main/webapp/WEB-INF/jsp/welcomePage.jsp
  17. +0 −12 web/src/main/webapp/hello.jsp
  18. +0 −2  web/src/main/webapp/redirect.jsp
30 batch-importer/README.txt
View
@@ -0,0 +1,30 @@
+This tool lets you download all your photos from Flickr and supports restarts and auditability.
+It's very rough and not nearly ready for someone to use if they're not a software programmer:
+you need to first run the 'web' module in this same project (/web). When you run it, go to http://localhost:8080/ and then follow the signin flow.
+
+Once you've done that, check your database (configured in MainConfig)'s userconnection table. In particular, you'll see the accessToken and secret values. Add those to a properties along with the configuration needed to connect to you rbatch database, like this:
+
+#----------------------------------
+
+clientId=Your client ID
+clientSecret=your client Secret
+
+accessToken=access Token
+accessTokenSecret=access token secret
+
+
+dataSource.user=photos
+dataSource.db=photos
+dataSource.password=photos
+dataSource.host=127.0.0.1
+dataSource.driverClassName=org.postgresql.Driver
+dataSource.port=5432
+
+dataSource.createTables = false
+#----------------------------------
+
+Once you have all that, you can run the batch job. The batch job will need the tables contained
+in src/main/resources/batch_pg.sql and src/main/resources/photos_pg.sql to work. Once you're done,
+simply specify where Spring can find this configuration file in the code for the Main class. By default, the code
+looks for <code>~/Desktop/flickr.properties</code>.
+
290 core/src/main/java/org/springframework/social/flickr/api/PhotoOperations.java
View
@@ -7,150 +7,156 @@
* @author HemantS
*
*/
+
/**
* The Interface PhotoOperations.
*/
public interface PhotoOperations {
-
- /**
- * Adds the tags.
- *
- * @param photoId the photo id
- * @param tagList the tag list
- * @return true, if successful
- */
- boolean addTags(String photoId,String[] tagList);
-
- /**
- * Adds the tags.
- *
- * @param photoId the photo id
- * @param tags comma separated tags
- * @return true, if successful
- */
- boolean addTags(String photoId,String tags);
-
-
- /**Remove a tag from a photo.
- *
- * This method requires authentication with 'write' permission.
- *
- * @param tagId
- * @return
- */
- boolean removeTag(String tagId);
-
- /**
- * Delete the photoT
- * This method require 'delete' permission
- * @param photoId the photo id
- * @return true, if successful
- */
- boolean delete(String photoId);
-
- /**
- * Gets the recent.
- *
- * @param perPage the per page
- * @param page the page
- * @param List of extras
- * @return the recent
- */
- Photos getRecent(String perPage, String page , String[] extras);
-
- /**
- * Returns the list of people who have favorited a given photo.
- *
- * @param perPage the per page
- * @param page the page
- * @param photoId the photo id
- * @return the favorites
- */
- Photo getFavorites(String perPage, String page,String photoId);
-
- /**
- * Get information about a photo. The calling user must have permission to view the photo.
- *
- * @param photoId the photo id
- * @return the info
- */
- PhotoDetail getInfo(String photoId);
-
- /**
- * Returns the available sizes for a photo. The calling user must have permission to view the photo.
- *
- * @param photoId the photo id
- * @return the sizes
- */
- Sizes getSizes(String photoId);
-
- /**Get permissions for a photo.
- *
- * This method requires authentication with 'read' permission.
- *
- * @param photoId
- * @return
- */
- Perms getPerms(String photoId);
-
- /**
- * Set permissions for a photo.
- *
- * This method requires authentication with 'write' permission.
- *
- * @param perms
- * @return
- */
- PhotoId setPerms(Perms perms);
- /**
- * Set the content type of a photo.
- *
- * This method requires authentication with 'write' permission.
- *
- * @param photoId
- * @param contentType
- * @return
- */
- boolean setContentType(String photoId, ContentTypeEnum contentTypeEnum);
-
- /**
- * Set the safety level of a photo.
- *
- * This method requires authentication with 'write' permission.
- *
- * @param photoId
- * @param safetyLevel
- * @param hidden
- * @return
- */
- boolean setSafetyLevel(String photoId, SafetyLevelEnum safetyLevel, Boolean hidden);
- boolean setSafetyLevel(String photoId, SafetyLevelEnum safetyLevel);
-
- /**
- * Set the meta information for a photo.
- *
- * This method requires authentication with 'write' permission.
- *
- * @param photoId
- * @param title
- * @param description
- * @return
- */
- boolean setMeta(String photoId , String title , String description);
-
- /**
- * Rotate a photo.
- *
- * This method requires authentication with 'write' permission.
- *
- * @param photoId
- * @param rotation The amount of degrees by which to rotate the photo (clockwise) from it's current orientation. Valid values are 90, 180 and 270.
- * @return
- */
- PhotoId rotate(String photoId,RotateEnum rotation);
-
- /*peding */
- Object upload(File photo,String title , String description , String[] tags,Perms perms, ContentTypeEnum contentType , HiddenEnum hiddenType);
-
-
+
+ /**
+ * Adds the tags.
+ *
+ * @param photoId the photo id
+ * @param tagList the tag list
+ * @return true, if successful
+ */
+ boolean addTags(String photoId, String[] tagList);
+
+ /**
+ * Adds the tags.
+ *
+ * @param photoId the photo id
+ * @param tags comma separated tags
+ * @return true, if successful
+ */
+ boolean addTags(String photoId, String tags);
+
+
+ /**
+ * Remove a tag from a photo.
+ * <p/>
+ * This method requires authentication with 'write' permission.
+ *
+ * @param tagId
+ * @return
+ */
+ boolean removeTag(String tagId);
+
+ /**
+ * Delete the photoT
+ * This method require 'delete' permission
+ *
+ * @param photoId the photo id
+ * @return true, if successful
+ */
+ boolean delete(String photoId);
+
+ /**
+ * Gets the recent.
+ *
+ * @param perPage the per page
+ * @param page the page
+ * @param List of extras
+ * @return the recent
+ */
+ Photos getRecent(String perPage, String page, String[] extras);
+
+ /**
+ * Returns the list of people who have favorited a given photo.
+ *
+ * @param perPage the per page
+ * @param page the page
+ * @param photoId the photo id
+ * @return the favorites
+ */
+ Photo getFavorites(String perPage, String page, String photoId);
+
+ /**
+ * Get information about a photo. The calling user must have permission to view the photo.
+ *
+ * @param photoId the photo id
+ * @return the info
+ */
+ PhotoDetail getInfo(String photoId);
+
+ /**
+ * Returns the available sizes for a photo. The calling user must have permission to view the photo.
+ *
+ * @param photoId the photo id
+ * @return the sizes
+ */
+ Sizes getSizes(String photoId);
+
+ /**
+ * Get permissions for a photo.
+ * <p/>
+ * This method requires authentication with 'read' permission.
+ *
+ * @param photoId
+ * @return
+ */
+ Perms getPerms(String photoId);
+
+ /**
+ * Set permissions for a photo.
+ * <p/>
+ * This method requires authentication with 'write' permission.
+ *
+ * @param perms
+ * @return
+ */
+ PhotoId setPerms(Perms perms);
+
+ /**
+ * Set the content type of a photo.
+ * <p/>
+ * This method requires authentication with 'write' permission.
+ *
+ * @param photoId
+ * @param contentType
+ * @return
+ */
+ boolean setContentType(String photoId, ContentTypeEnum contentTypeEnum);
+
+ /**
+ * Set the safety level of a photo.
+ * <p/>
+ * This method requires authentication with 'write' permission.
+ *
+ * @param photoId
+ * @param safetyLevel
+ * @param hidden
+ * @return
+ */
+ boolean setSafetyLevel(String photoId, SafetyLevelEnum safetyLevel, Boolean hidden);
+
+ boolean setSafetyLevel(String photoId, SafetyLevelEnum safetyLevel);
+
+ /**
+ * Set the meta information for a photo.
+ * <p/>
+ * This method requires authentication with 'write' permission.
+ *
+ * @param photoId
+ * @param title
+ * @param description
+ * @return
+ */
+ boolean setMeta(String photoId, String title, String description);
+
+ /**
+ * Rotate a photo.
+ * <p/>
+ * This method requires authentication with 'write' permission.
+ *
+ * @param photoId
+ * @param rotation The amount of degrees by which to rotate the photo (clockwise) from it's current orientation. Valid values are 90, 180 and 270.
+ * @return
+ */
+ PhotoId rotate(String photoId, RotateEnum rotation);
+
+ /*peding */
+ String upload(File photo, String title, String description, String[] tags, Perms perms, ContentTypeEnum contentType, HiddenEnum hiddenType);
+
+
}
459 core/src/main/java/org/springframework/social/flickr/api/impl/PhotoTemplate.java
View
@@ -1,226 +1,277 @@
package org.springframework.social.flickr.api.impl;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-
-import org.springframework.social.flickr.api.ContentTypeEnum;
-import org.springframework.social.flickr.api.HiddenEnum;
-import org.springframework.social.flickr.api.Perms;
-import org.springframework.social.flickr.api.Photo;
-import org.springframework.social.flickr.api.PhotoDetail;
-import org.springframework.social.flickr.api.PhotoId;
-import org.springframework.social.flickr.api.PhotoOperations;
-import org.springframework.social.flickr.api.Photos;
-import org.springframework.social.flickr.api.RotateEnum;
-import org.springframework.social.flickr.api.SafetyLevelEnum;
-import org.springframework.social.flickr.api.Sizes;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.core.io.Resource;
+import org.springframework.http.converter.FormHttpMessageConverter;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.social.flickr.api.*;
import org.springframework.social.support.URIBuilder;
+import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
+import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;
+import org.w3c.dom.Element;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.net.URI;
/**
* @author HemantS
- *
+ * @author Josh Long (josh.long@springsource.com)
*/
public class PhotoTemplate extends AbstractFlickrOperations implements PhotoOperations {
- private final RestTemplate restTemplate;
-
- public PhotoTemplate(RestTemplate restTemplate,boolean isAuthorizedForUser) {
- super(isAuthorizedForUser);
- this.restTemplate = restTemplate;
- }
-
- @Override
- public boolean addTags(String photoId, String[] tagList) {
- requireAuthorization();
- MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
- parameters.set("photo_id", photoId);
- parameters.set("tags", toCommaList(tagList));
- restTemplate.postForObject(buildUri("flickr.photos.addTags"), parameters, Object.class);
- return true;
- }
-
- @Override
- public boolean addTags(String photoId, String tags) {
- requireAuthorization();
- MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
- parameters.set("photo_id", photoId);
- parameters.set("tags", tags);
- restTemplate.postForObject(buildUri("flickr.photos.addTags"), parameters, Object.class);
- return true;
- }
-
-
- @Override
- public boolean removeTag(String tagId) {
- requireAuthorization();
- MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
- parameters.set("tag_id", tagId);
- restTemplate.postForObject(buildUri("flickr.photos.removeTag"), parameters, Object.class);
- return true;
- }
-
- @Override
- public boolean delete(String photoId) {
- requireAuthorization();
- MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
- parameters.set("photo_id", photoId);
- restTemplate.postForObject(buildUri("flickr.photos.delete"), parameters, Object.class);
- return true;
- }
-
- @Override
- public Photos getRecent(String perPage, String page, String[] extras) {
- MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
- parameters.set("per_page", perPage);
- parameters.set("page", page);
- parameters.set("extras", toCommaList(extras));
- return restTemplate.getForObject(buildUri("flickr.photos.getRecent",parameters), Photos.class);
- }
-
- @Override
- public Photo getFavorites(String perPage, String page, String photoId) {
- MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
- parameters.set("per_page", perPage);
- parameters.set("page", page);
- parameters.set("photo_id", photoId);
- return restTemplate.getForObject(buildUri("flickr.photos.getFavorites",parameters), Photo.class);
- }
-
- @Override
- public PhotoDetail getInfo(String photoId) {
- return restTemplate.getForObject(buildUri("flickr.photos.getInfo","photo_id",photoId), PhotoDetail.class);
- }
-
-
- @Override
- public Sizes getSizes(String photoId) {
- return restTemplate.getForObject(buildUri("flickr.photos.getSizes","photo_id",photoId), Sizes.class);
- }
-
- @Override
- public Perms getPerms(String photoId) {
- requireAuthorization();
- return restTemplate.getForObject(buildUri("flickr.photos.getPerms","photo_id",photoId), Perms.class);
- }
-
- @Override
- public PhotoId setPerms(Perms perms) {
- requireAuthorization();
- MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
- parameters.set("photo_id", perms.getId());
- if(perms.isIspublic()){
- parameters.set("is_public", "1");
- }else{
- parameters.set("is_public", "0");
- }
- if(perms.isIsfamily()){
- parameters.set("is_family", "1");
- }else{
- parameters.set("is_family", "0");
- }
- if(perms.isIsfriend()){
- parameters.set("is_friend", "1");
- }else{
- parameters.set("is_friend", "0");
- }
- parameters.set("perm_comment",perms.getPermcomment().getPermision());
- parameters.set("perm_addmeta",perms.getPermcomment().getPermision());
- return restTemplate.postForObject(buildUri("flickr.photos.setPerms"), parameters, PhotoId.class);
- }
-
- @Override
- public boolean setContentType(String photoId, ContentTypeEnum contentTypeEnum) {
- requireAuthorization();
- MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
- parameters.set("photo_id", photoId);
- parameters.set("content_type", contentTypeEnum.getType());
- restTemplate.postForObject(buildUri("flickr.photos.setContentType"), parameters, Object.class);
- return true;
- }
-
- @Override
- public boolean setSafetyLevel(String photoId, SafetyLevelEnum safetyLevel,Boolean hidden) {
- requireAuthorization();
- MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
- parameters.set("photo_id", photoId);
- parameters.set("safety_level", safetyLevel.getSafetyLevel());
- if(hidden!=null){
- if(hidden == true){
- parameters.set("hidden", "1");
- }else{
- parameters.set("hidden", "0");
- }
- }
- restTemplate.postForObject(buildUri("flickr.photos.setSafetyLevel"), parameters, Object.class);
- return true;
- }
-
- @Override
- public boolean setSafetyLevel(String photoId, SafetyLevelEnum safetyLevel) {
- return setSafetyLevel(photoId,safetyLevel,null );
- }
-
- @Override
- public boolean setMeta(String photoId, String title, String description) {
- requireAuthorization();
- MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
- parameters.set("photo_id", photoId);
- parameters.set("title", title);
- parameters.set("description", description);
- restTemplate.postForObject(buildUri("flickr.photos.setMeta"), parameters, Object.class);
- return true;
- }
-
- @Override
- public PhotoId rotate(String photoId, RotateEnum rotation) {
- requireAuthorization();
- MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
- parameters.set("photo_id", photoId);
- parameters.set("degrees",rotation.getRotation());
- return restTemplate.postForObject(buildUri("flickr.photos.transform.rotate"), parameters, PhotoId.class);
- }
-
-
- private String toCommaList(String[] a){
- if (a == null)
+ private final RestTemplate restTemplate;
+
+ public PhotoTemplate(RestTemplate restTemplate, boolean isAuthorizedForUser) {
+ super(isAuthorizedForUser);
+ this.restTemplate = restTemplate;
+ }
+
+ @Override
+ public boolean addTags(String photoId, String[] tagList) {
+ requireAuthorization();
+ MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
+ parameters.set("photo_id", photoId);
+ parameters.set("tags", toCommaList(tagList));
+ restTemplate.postForObject(buildUri("flickr.photos.addTags"), parameters, Object.class);
+ return true;
+ }
+
+ @Override
+ public boolean addTags(String photoId, String tags) {
+ requireAuthorization();
+ MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
+ parameters.set("photo_id", photoId);
+ parameters.set("tags", tags);
+ restTemplate.postForObject(buildUri("flickr.photos.addTags"), parameters, Object.class);
+ return true;
+ }
+
+
+ @Override
+ public boolean removeTag(String tagId) {
+ requireAuthorization();
+ MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
+ parameters.set("tag_id", tagId);
+ restTemplate.postForObject(buildUri("flickr.photos.removeTag"), parameters, Object.class);
+ return true;
+ }
+
+ @Override
+ public boolean delete(String photoId) {
+ requireAuthorization();
+ MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
+ parameters.set("photo_id", photoId);
+ restTemplate.postForObject(buildUri("flickr.photos.delete"), parameters, Object.class);
+ return true;
+ }
+
+ @Override
+ public Photos getRecent(String perPage, String page, String[] extras) {
+ MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
+ parameters.set("per_page", perPage);
+ parameters.set("page", page);
+ parameters.set("extras", toCommaList(extras));
+ return restTemplate.getForObject(buildUri("flickr.photos.getRecent", parameters), Photos.class);
+ }
+
+ @Override
+ public Photo getFavorites(String perPage, String page, String photoId) {
+ MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
+ parameters.set("per_page", perPage);
+ parameters.set("page", page);
+ parameters.set("photo_id", photoId);
+ return restTemplate.getForObject(buildUri("flickr.photos.getFavorites", parameters), Photo.class);
+ }
+
+ @Override
+ public PhotoDetail getInfo(String photoId) {
+ return restTemplate.getForObject(buildUri("flickr.photos.getInfo", "photo_id", photoId), PhotoDetail.class);
+ }
+
+
+ @Override
+ public Sizes getSizes(String photoId) {
+ return restTemplate.getForObject(buildUri("flickr.photos.getSizes", "photo_id", photoId), Sizes.class);
+ }
+
+ @Override
+ public Perms getPerms(String photoId) {
+ requireAuthorization();
+ return restTemplate.getForObject(buildUri("flickr.photos.getPerms", "photo_id", photoId), Perms.class);
+ }
+
+ @Override
+ public PhotoId setPerms(Perms perms) {
+ requireAuthorization();
+ MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
+ parameters.set("photo_id", perms.getId());
+ if (perms.isIspublic()) {
+ parameters.set("is_public", "1");
+ } else {
+ parameters.set("is_public", "0");
+ }
+ if (perms.isIsfamily()) {
+ parameters.set("is_family", "1");
+ } else {
+ parameters.set("is_family", "0");
+ }
+ if (perms.isIsfriend()) {
+ parameters.set("is_friend", "1");
+ } else {
+ parameters.set("is_friend", "0");
+ }
+ parameters.set("perm_comment", perms.getPermcomment().getPermision());
+ parameters.set("perm_addmeta", perms.getPermcomment().getPermision());
+ return restTemplate.postForObject(buildUri("flickr.photos.setPerms"), parameters, PhotoId.class);
+ }
+
+ @Override
+ public boolean setContentType(String photoId, ContentTypeEnum contentTypeEnum) {
+ requireAuthorization();
+ MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
+ parameters.set("photo_id", photoId);
+ parameters.set("content_type", contentTypeEnum.getType());
+ restTemplate.postForObject(buildUri("flickr.photos.setContentType"), parameters, Object.class);
+ return true;
+ }
+
+ @Override
+ public boolean setSafetyLevel(String photoId, SafetyLevelEnum safetyLevel, Boolean hidden) {
+ requireAuthorization();
+ MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
+ parameters.set("photo_id", photoId);
+ parameters.set("safety_level", safetyLevel.getSafetyLevel());
+ if (hidden != null) {
+ if (hidden) {
+ parameters.set("hidden", "1");
+ } else {
+ parameters.set("hidden", "0");
+ }
+ }
+ restTemplate.postForObject(buildUri("flickr.photos.setSafetyLevel"), parameters, Object.class);
+ return true;
+ }
+
+ @Override
+ public boolean setSafetyLevel(String photoId, SafetyLevelEnum safetyLevel) {
+ return setSafetyLevel(photoId, safetyLevel, null);
+ }
+
+ @Override
+ public boolean setMeta(String photoId, String title, String description) {
+ requireAuthorization();
+ MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
+ parameters.set("photo_id", photoId);
+ if (StringUtils.hasText(title))
+ parameters.set("title", title);
+ if (StringUtils.hasText(description))
+ parameters.set("description", description);
+ restTemplate.postForObject(buildUri("flickr.photos.setMeta"), parameters, Object.class);
+ return true;
+ }
+
+ @Override
+ public PhotoId rotate(String photoId, RotateEnum rotation) {
+ requireAuthorization();
+ MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
+ parameters.set("photo_id", photoId);
+ parameters.set("degrees", rotation.getRotation());
+ return restTemplate.postForObject(buildUri("flickr.photos.transform.rotate"), parameters, PhotoId.class);
+ }
+
+
+ private String toCommaList(String[] a) {
+ if (a == null)
return "null";
- int iMax = a.length - 1;
- if (iMax == -1)
+ int iMax = a.length - 1;
+ if (iMax == -1)
return "";
StringBuilder b = new StringBuilder();
-
+
for (int i = 0; ; i++) {
b.append(a[i]);
- if (i == iMax)
- return b.toString();
+ if (i == iMax)
+ return b.toString();
b.append(",");
}
- }
-
- @Override
- public Object upload(File photo, String title, String description,
- String[] tags, Perms perms, ContentTypeEnum contentType,
- HiddenEnum hiddenType) {
- requireAuthorization();
- MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
- try {
- InputStream inputStream = new FileInputStream(photo);
- System.out.println(inputStream);
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- parameters.set("photo", photo.toString());
- parameters.set("title",title);
- return restTemplate.postForObject( URIBuilder.fromUri("http://api.flickr.com/services/upload/").build(), parameters, Object.class);
- }
+ }
+
+
+ protected void ensureSupportsFormHttpUploads() {
+
+ boolean hasFormHttpMessageConverter = false;
+ for (HttpMessageConverter mc : restTemplate.getMessageConverters()) {
+ if (mc instanceof FormHttpMessageConverter) {
+ hasFormHttpMessageConverter = true;
+ break;
+ }
+ }
+ if (!hasFormHttpMessageConverter) {
+ this.restTemplate.getMessageConverters().add(new FormHttpMessageConverter()); // just in case
+ }
+ }
+
+ /**
+ * handles setting other properties on the photo after the post, since, atm,
+ * i can't figure out how to POST the data correctly.
+ */
+ protected void setPropertiesOnPhoto(String photoId, String title, String description, String[] tags, Perms perms, ContentTypeEnum contentType, HiddenEnum hiddenType) {
+
+
+ if (hiddenType != null) {
+ System.out.println("NB: this API does not yet support setting the HiddenEnum on a Photo");
+ }
+
+ setMeta(photoId, title, description);
+
+ if (null != tags) {
+ addTags(photoId, tags);
+ }
+ if (null != perms) {
+ setPerms(perms);
+ }
+
+ if (null != contentType) {
+ setContentType(photoId, contentType);
+ }
+
+ }
+
+ @Override
+ public String upload(File photo, String title, String description, String[] tags, Perms perms, ContentTypeEnum contentType, HiddenEnum hiddenType) {
+ Resource res = new FileSystemResource(photo);
+ requireAuthorization();
+ ensureSupportsFormHttpUploads();
+
+ try {
+ Assert.notNull(res);
+ Assert.isTrue(res.exists());
+
+ MultiValueMap<String, Object> parms = new LinkedMultiValueMap<String, Object>();
+ parms.set("photo", res);
+
+ URI uri = URIBuilder.fromUri("http://api.flickr.com/services/upload/").build();
+ String response = restTemplate.postForObject(uri, parms, String.class);
+
+ Element node = DocumentBuilderFactory
+ .newInstance()
+ .newDocumentBuilder()
+ .parse(new ByteArrayInputStream(response.getBytes()))
+ .getDocumentElement();
+
+ String id = (node.getElementsByTagName("photoid").item(0).getTextContent());
+ setPropertiesOnPhoto(id, title, description, tags, perms, contentType, hiddenType);
+ return id;
+
+ } catch (Throwable thr) {
+ throw new RuntimeException(thr);
+ }
+ }
}
9 core/src/test/resources/log4j.properties
View
@@ -0,0 +1,9 @@
+# Direct log messages to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+
+# Root logger option
+log4j.rootLogger=INFO,stdout
+
16 web/pom.xml
View
@@ -15,6 +15,16 @@
<url>https://github.com/ranjan-rk/spring-social-flickr</url>
<dependencies>
<dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>9.1-901-1.jdbc4</version>
+ </dependency>
+ <dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-flickr-core</artifactId>
<version>${project.version}</version>
@@ -48,7 +58,7 @@
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
</dependency>
- <dependency>
+ <dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
</dependency>
@@ -60,11 +70,11 @@
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
- <dependency>
+ <dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
</dependency>
- <dependency>
+ <dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
224 web/src/main/java/org/springframework/social/flickr/HomeController.java
View
@@ -15,129 +15,133 @@
*/
package org.springframework.social.flickr;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import javax.inject.Inject;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-
import org.springframework.social.flickr.api.Flickr;
import org.springframework.social.flickr.api.impl.FlickrException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.InputStream;
+import java.util.concurrent.Callable;
+
@Controller
public class HomeController {
- private final Flickr flickr;
-
-
- @Inject
- private CommonsMultipartResolver multipartResolver ;
-
- @Inject
- public HomeController(Flickr flickr) {
- this.flickr = flickr;
- }
- @RequestMapping(value = "/", method = RequestMethod.GET)
- public String home(Model model) {
- System.out.println(multipartResolver);
- model.addAttribute("welcomeMessage","Welcome to spring social flickr, "+ flickr.peopleOperations().getPersonProfile().getUserName());
- return "welcomePage";
- }
-
- @RequestMapping(value = "/addtags", method = RequestMethod.POST)
- public String addtags(@RequestParam("photoid") String photoId,@RequestParam("tags") String tags,Model model) {
- flickr.photoOperations().addTags(photoId, tags);
- model.addAttribute("messages","tags : "+tags+" Added successfully..");
- return "welcomePage";
- }
-
- @RequestMapping(value = "/deletephoto", method = RequestMethod.POST)
- public String addtags(@RequestParam("photoid") String photoId , Model model) {
- try{
- flickr.photoOperations().delete(photoId);
- }catch(FlickrException e){
- model.addAttribute("messages",e.getMessage());
- return "welcomePage";
- }
- model.addAttribute("messages","Photo Id : "+photoId+" delete successfully..");
- return "welcomePage";
- }
-
- @RequestMapping(value = "/uploadphoto",method = RequestMethod.POST)
- public String create(UploadItem uploadItem, BindingResult result,
- HttpServletRequest request, HttpServletResponse response,
- HttpSession session) {
- if (result.hasErrors()) {
- for (ObjectError error : result.getAllErrors()) {
- System.err.println("Error: " + error.getCode() + " - "
- + error.getDefaultMessage());
- }
- return "/uploadfile";
- }
-
- // Some type of file processing...
- System.err.println("-------------------------------------------");
- try {
- MultipartFile file = uploadItem.getFileData();
- String fileName = null;
- InputStream inputStream = null;
-
- if (file.getSize() > 0) {
- inputStream = file.getInputStream();
- if (file.getSize() > 100000) {
- System.out.println("File Size:::" + file.getSize());
- return "/uploadfile";
- }
- System.out.println("size::" + file.getSize());
-
-
- System.out.println("fileName:" + file.getOriginalFilename());
-
- int readBytes = 0;
- byte[] buffer = new byte[10000];
- while ((readBytes = inputStream.read(buffer, 0, 10000)) != -1) {
- System.out.println(readBytes);
- }
- //Object obj = flickr.photoOperations().upload(photo , title, null , null , null , null , null )
- inputStream.close();
- }
-
- // ..........................................
- session.setAttribute("uploadFile", file.getOriginalFilename());
- } catch (Exception e) {
- e.printStackTrace();
- }
+ private Flickr flickr;
+ private CommonsMultipartResolver multipartResolver;
+
+ @Inject
+ public HomeController(CommonsMultipartResolver multipartResolver, Flickr flickr) {
+ this.flickr = flickr;
+ this.multipartResolver = multipartResolver;
+ }
+ @RequestMapping(value = "/welcome", method = RequestMethod.GET)
+ public String welcome (Model m) {
+ m.addAttribute("flickrUser", flickr.peopleOperations().getPersonProfile().getUserName()) ;
+ return "welcome" ;
+ }
+
+ @RequestMapping(value = "/addtags", method = RequestMethod.POST)
+ public String addTagsToPhotos(@RequestParam("photoid") String photoId, @RequestParam("tags") String tags, Model model) {
+ flickr.photoOperations().addTags(photoId, tags);
+ model.addAttribute("messages", "tags : " + tags + " Added successfully..");
+ return "welcomePage";
+ }
+
+ @RequestMapping(value = "/deletephoto", method = RequestMethod.POST)
+ public String deletePhoto(@RequestParam("photoid") String photoId, Model model) {
+ try {
+ flickr.photoOperations().delete(photoId);
+ } catch (FlickrException e) {
+ model.addAttribute("messages", e.getMessage());
+ return "welcomePage";
+ }
+ model.addAttribute("messages", "Photo Id : " + photoId + " delete successfully..");
+ return "welcomePage";
+ }
+
+
+ /* // more correct
+ @RequestMapping(value = "/uploadphoto", method = RequestMethod.POST)
+ @ResponseBody
+ public String uploadPhoto ( @RequestParam("file") MultipartFile file) {
+
+// flickr.photoOperations().upload()
+
+ return "welcome" ;
+ }*/
+
+ @RequestMapping(value = "/uploadphoto", method = RequestMethod.POST)
+ public String create(UploadItem uploadItem, BindingResult result,
+ HttpServletRequest request, HttpServletResponse response,
+ HttpSession session) {
+ if (result.hasErrors()) {
+ for (ObjectError error : result.getAllErrors()) {
+ System.err.println("Error: " + error.getCode() + " - "
+ + error.getDefaultMessage());
+ }
+ return "/uploadfile";
+ }
+
+ // Some type of file processing...
+ System.err.println("-------------------------------------------");
+ try {
+ MultipartFile file = uploadItem.getFileData();
+ String fileName = null;
+ InputStream inputStream = null;
+
+ if (file.getSize() > 0) {
+ inputStream = file.getInputStream();
+ if (file.getSize() > 100000) {
+ System.out.println("File Size:::" + file.getSize());
+ return "/uploadfile";
+ }
+ System.out.println("size::" + file.getSize());
+
+
+ System.out.println("fileName:" + file.getOriginalFilename());
+
+ int readBytes = 0;
+ byte[] buffer = new byte[10000];
+ while ((readBytes = inputStream.read(buffer, 0, 10000)) != -1) {
+ System.out.println(readBytes);
+ }
+ //Object obj = flickr.photoOperations().upload(photo , title, null , null , null , null , null )
+ inputStream.close();
+ }
+
+ // ..........................................
+ session.setAttribute("uploadFile", file.getOriginalFilename());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return "welcomePage";
+ }
+
+ /*Pending
+ @RequestMapping(value = "/uploadphoto", method = RequestMethod.POST, headers={"content-type=multipart/form-data"})
+ public String deletePhoto(@RequestParam("photo") byte[] photo ,@RequestParam("title") String title, Model model ) {
+ Object obj =null;
+ try{
+ //System.out.println(c);
+ System.out.println(photo);
+ //obj = flickr.photoOperations().upload(photo , title, null , null , null , null , null );
+ }catch(FlickrException e){
+ model.addAttribute("messages",e.getMessage());
return "welcomePage";
+ }
+ if(obj!=null)
+ model.addAttribute("messages","Photo Id : "+obj.toString()+" added successfully..");
+ return "welcomePage";
}
+ */
- /*Pending
- @RequestMapping(value = "/uploadphoto", method = RequestMethod.POST, headers={"content-type=multipart/form-data"})
- public String addtags(@RequestParam("photo") byte[] photo ,@RequestParam("title") String title, Model model ) {
- Object obj =null;
- try{
- //System.out.println(c);
- System.out.println(photo);
- //obj = flickr.photoOperations().upload(photo , title, null , null , null , null , null );
- }catch(FlickrException e){
- model.addAttribute("messages",e.getMessage());
- return "welcomePage";
- }
- if(obj!=null)
- model.addAttribute("messages","Photo Id : "+obj.toString()+" added successfully..");
- return "welcomePage";
- }
- */
-
}
68 web/src/main/java/org/springframework/social/flickr/config/MainConfig.java
View
@@ -1,38 +1,64 @@
package org.springframework.social.flickr.config;
-import javax.sql.DataSource;
-
+import org.apache.commons.dbcp.BasicDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
+import org.springframework.core.env.Environment;
import org.springframework.core.io.ClassPathResource;
-import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactory;
-import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import org.springframework.jdbc.datasource.init.DatabasePopulator;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.social.connect.jdbc.JdbcUsersConnectionRepository;
+import org.springframework.social.flickr.UploadItem;
+
+import javax.inject.Inject;
+import javax.sql.DataSource;
+import java.sql.Driver;
@Configuration
-@ComponentScan(basePackages = "org.springframework.social.flickr", excludeFilters = { @Filter(Configuration.class) })
+@ComponentScan(basePackageClasses = {UploadItem.class}, excludeFilters = {@Filter(Configuration.class)})
@PropertySource("classpath:/org/springframework/social/flickr/config/flickr.properties")
public class MainConfig {
+/*
+
+ @Bean(destroyMethod = "shutdown")
+ public DataSource dataSource() {
+ EmbeddedDatabaseFactory factory = new EmbeddedDatabaseFactory();
+ factory.setDatabaseName("spring-social-flickr");
+ factory.setDatabaseType(EmbeddedDatabaseType.H2);
+ factory.setDatabasePopulator(databasePopulator());
+ return factory.getDatabase();
+ }
+*/
+
+
+ @Bean(destroyMethod = "close")
+ @Inject
+ public DataSource dataSource(Environment environment) throws Exception {
+ String user = environment.getProperty("dataSource.user"),
+ pw = environment.getProperty("dataSource.password"),
+ host = environment.getProperty("dataSource.host");
+ int port = Integer.parseInt(environment.getProperty("dataSource.port"));
+ String db = environment.getProperty("dataSource.db");
+ Class<Driver> driverClass = environment.getPropertyAsClass("dataSource.driverClassName", Driver.class);
+ BasicDataSource basicDataSource = new BasicDataSource();
+ basicDataSource.setDriverClassName(driverClass.getName());
+ basicDataSource.setPassword(pw);
+ String url = String.format("jdbc:postgresql://%s:%s/%s", host, port, db);
+ basicDataSource.setUrl(url);
+ basicDataSource.setUsername(user);
+ basicDataSource.setInitialSize(5);
+ basicDataSource.setMaxActive(10);
+
+ return basicDataSource;
+ }
- @Bean(destroyMethod = "shutdown")
- public DataSource dataSource() {
- EmbeddedDatabaseFactory factory = new EmbeddedDatabaseFactory();
- factory.setDatabaseName("spring-social-flickr");
- factory.setDatabaseType(EmbeddedDatabaseType.H2);
- factory.setDatabasePopulator(databasePopulator());
- return factory.getDatabase();
- }
-
- // internal helpers
-
- private DatabasePopulator databasePopulator() {
- ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
- populator.addScript(new ClassPathResource("JdbcUsersConnectionRepository.sql", JdbcUsersConnectionRepository.class));
- return populator;
- }
+ @Bean
+ public DatabasePopulator databasePopulator() {
+ ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
+ populator.addScript(new ClassPathResource("JdbcUsersConnectionRepository.sql", JdbcUsersConnectionRepository.class));
+ return populator;
+ }
}
47 web/src/main/java/org/springframework/social/flickr/config/SocialConfig.java
View
@@ -3,6 +3,8 @@
import javax.inject.Inject;
import javax.sql.DataSource;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
@@ -21,20 +23,22 @@
import org.springframework.social.flickr.user.SimpleConnectionSignUp;
import org.springframework.social.flickr.user.SimpleSignInAdapter;
import org.springframework.social.flickr.user.User;
-import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
-@Configuration
+import java.util.logging.Logger;
+@Configuration
public class SocialConfig {
-
+
+ protected Log logger = LogFactory.getLog(getClass());
+
@Inject
private DataSource dataSource;
@Inject
private Environment environment;
-
+
@Bean
public ConnectionFactoryLocator connectionFactoryLocator() {
System.out.println("inside the connection facotry locator");
@@ -48,49 +52,44 @@ public ConnectionFactoryLocator connectionFactoryLocator() {
@Bean
@Scope(value="request", proxyMode=ScopedProxyMode.INTERFACES)
public ConnectionRepository connectionRepository(){
- System.out.println("inside the connectionRepository");
+ logger.debug("inside the connectionRepository");
User user = SecurityContext.getCurrentUser();
return usersConnectionRepository().createConnectionRepository(user.getId());
}
@Bean
public UsersConnectionRepository usersConnectionRepository() {
- System.out.println("inside the usersConnectionRepository");
- JdbcUsersConnectionRepository repository = new JdbcUsersConnectionRepository(dataSource,
+ logger.debug("inside the usersConnectionRepository");
+ JdbcUsersConnectionRepository repository =
+ new JdbcUsersConnectionRepository(dataSource,
connectionFactoryLocator(), Encryptors.noOpText());
repository.setConnectionSignUp(new SimpleConnectionSignUp());
return repository;
}
-
+
+
@Bean
- @Scope(value="request", proxyMode=ScopedProxyMode.INTERFACES)
+ @Scope(value="request", proxyMode=ScopedProxyMode.INTERFACES)
public Flickr flickr() {
- System.out.println("inside the flickr");
+ logger.debug("inside the flickr");
return connectionRepository().getPrimaryConnection(Flickr.class).getApi();
}
-
- /*@Bean
- public ConnectController connectController() {
- ConnectController controller = new ConnectController(
- connectionFactoryLocator(), connectionRepository());
- return controller;
- }*/
-
@Bean
public ProviderSignInController providerSignInController() {
- System.out.println("inside the providerSignInController");
- ProviderSignInController psc= new ProviderSignInController(connectionFactoryLocator(), usersConnectionRepository(),
- new SimpleSignInAdapter());
- return psc;
+ logger.debug("inside the providerSignInController");
+ return new ProviderSignInController(
+ connectionFactoryLocator(),
+ usersConnectionRepository(),
+ new SimpleSignInAdapter());
}
@Bean
public CommonsMultipartResolver multipartResolver(){
- System.out.println("calling CommonsMultipartResolver");
+ logger.debug("calling CommonsMultipartResolver");
CommonsMultipartResolver c = new CommonsMultipartResolver();
- c.setMaxUploadSize(100000);
+ c.setMaxUploadSize(100 * 1000);
return c;
}
}
1  web/src/main/java/org/springframework/social/flickr/config/WebMvcConfig.java
View
@@ -29,6 +29,7 @@
public class WebMvcConfig extends WebMvcConfigurerAdapter {
public void addViewControllers(ViewControllerRegistry registry) {
+ registry.addViewController("/").setViewName("signin");
registry.addViewController("/signin");
registry.addViewController("/signout");
}
2  web/src/main/java/org/springframework/social/flickr/config/flickr.properties
View
@@ -1,2 +0,0 @@
-clientId=your client id
-clientSecret=your client secret
5 web/src/main/java/org/springframework/social/flickr/user/User.java
View
@@ -15,11 +15,6 @@
*/
package org.springframework.social.flickr.user;
-/**
- * Simple little User model.
- * Just stores the user's id for simplicity.
- * @author Keith Donald
- */
public final class User {
private final String id;
3  web/src/main/java/org/springframework/social/flickr/user/UserInterceptor.java
View
@@ -85,8 +85,7 @@ private boolean requireSignIn(HttpServletRequest request, HttpServletResponse re
}
private boolean userNotFound(String userId) {
- // doesn't bother checking a local user database: simply checks if the userId is connected to Facebook
- //return connectionRepository.createConnectionRepository(userId).findPrimaryConnection(Facebook.class) != null;
+ //return connectionRepository.createConnectionRepository(userId).findPrimaryConnection(Facebook.class) != null;
return false;
}
19 web/src/main/resources/org/springframework/social/flickr/config/flickr.properties
View
@@ -1,2 +1,17 @@
-clientId=Your Key
-clientSecret=Your Secret Key
+
+clientId=fb989d7b35310d3084d6efc4fd67fe79
+clientSecret=d3ba7487be359983
+
+accessToken = 72157632360086343-da5e83d8b56edaa2
+accessTokenSecret = 6e003b587e169ee2
+
+
+
+
+
+dataSource.user=photos
+dataSource.db=photos
+dataSource.password=photos
+dataSource.host=127.0.0.1
+dataSource.driverClassName=org.postgresql.Driver
+dataSource.port=5432
0  web/src/main/webapp/signin.jsp → web/src/main/webapp/WEB-INF/jsp/signin.jsp
View
File renamed without changes
39 web/src/main/webapp/WEB-INF/jsp/welcome.jsp
View
@@ -0,0 +1,39 @@
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+ <title>Welcome Page</title>
+</head>
+<body>
+Welcome to Spring Social Flickr, ${flickrUser}!
+<br/>
+${messages}
+<br>
+
+<h1>Testing Photo Template</h1>
+<hr>
+<h2>add tags to photo</h2>
+
+<form action="addtags" method="POST">
+ <label>Tags(comma separated) : </label><input type="text" name="tags"/>
+ <label>Photo Id : </label><input type="text" name="photoid"/>
+ <input type="submit" value="add tags"/>
+</form>
+
+<h2>delete photo</h2>
+
+<form action="deletephoto" method="POST">
+ <label>Photo Id : </label><input type="text" name="photoid"/>
+ <input type="submit" value="delete photo"/>
+</form>
+
+<h2>upload photo</h2>
+
+<form action="uploadphoto" method="POST" enctype="multipart/form-data">
+ <label>Photo : </label>
+ <input type="file" name="photo"/>
+ <input type="text" name="title"/>
+ <input type="submit" value="upload photo"/>
+</form>
+
+</body>
+</html>
35 web/src/main/webapp/WEB-INF/jsp/welcomePage.jsp
View
@@ -1,35 +0,0 @@
-
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
-<title>Welcome Page</title>
-</head>
-<body>
- ${welcomeMessage}
- ${messages}
- <br>
- <h1>Testing Photo Template</h1>
- <hr>
- <h2>Add tags to photo</h2>
- <form action="addtags" method="POST">
- <label>Tags(comma separated) : </label><input type="text" name="tags"/>
- <label>Photo Id : </label><input type="text" name="photoid"/>
- <input type="submit" value="add tags"/>
- </form>
-
- <h2>delete photo</h2>
- <form action="deletephoto" method="POST">
- <label>Photo Id : </label><input type="text" name="photoid"/>
- <input type="submit" value="delete photo"/>
- </form>
-
- <h2>upload photo</h2>
- <form action="uploadphoto" method="POST" enctype="multipart/form-data">
- <label>Photo : </label>
- <input type="file" name="photo"/>
- <input type="text" name="title"/>
- <input type="submit" value="upload photo"/>
- </form>
-
-</body>
-</html>
12 web/src/main/webapp/hello.jsp
View
@@ -1,12 +0,0 @@
-<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"%>
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
-<title>Insert title here</title>
-</head>
-<body>
-got it
-</body>
-</html>
2  web/src/main/webapp/redirect.jsp
View
@@ -1,2 +0,0 @@
-<%@page contentType="text/html" pageEncoding="UTF-8"%>
-<% response.sendRedirect("welcome.htm"); %>
Please sign in to comment.
Something went wrong with that request. Please try again.