Subversion Repositories SmartDukaan

Rev

Rev 210 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 210 Rev 242
Line 11... Line 11...
11
import java.io.File;
11
import java.io.File;
12
import java.io.FileInputStream;
12
import java.io.FileInputStream;
13
import java.io.FileOutputStream;
13
import java.io.FileOutputStream;
14
import java.io.InputStream;
14
import java.io.InputStream;
15
import java.io.OutputStream;
15
import java.io.OutputStream;
-
 
16
import java.net.URLDecoder;
16
import java.util.Collection;
17
import java.util.Collection;
17
import java.util.HashMap;
18
import java.util.HashMap;
18
import java.util.Map;
19
import java.util.Map;
19
 
20
 
20
import org.apache.commons.io.IOUtils;
21
import org.apache.commons.io.IOUtils;
Line 42... Line 43...
42
	private static Log log = LogFactory.getLog(MediaController.class);
43
	private static Log log = LogFactory.getLog(MediaController.class);
43
	
44
	
44
	/**
45
	/**
45
	 * 
46
	 * 
46
	 */
47
	 */
-
 
48
	private String id;
47
	private String entityID;
49
	private String entityID;
48
	private String label;
50
	private String label;
49
	private File pic;
51
	private File pic;
50
	private String picContentType;
52
	private String picContentType;
51
	private String picFileName;
53
	private String picFileName;
Line 114... Line 116...
114
 
116
 
115
		this.redirectURL = "media?entityID=" + this.getEntityID();
117
		this.redirectURL = "media?entityID=" + this.getEntityID();
116
    	
118
    	
117
		return "redirect";
119
		return "redirect";
118
    }
120
    }
-
 
121
 
-
 
122
    // DELETE /entity/1000001
-
 
123
    /**
-
 
124
     * 
-
 
125
     */
-
 
126
    public String destroy() {
-
 
127
    	log.info("MediaController.destroy");
-
 
128
    	try {
-
 
129
    		long entityID = Long.parseLong(this.getEntityID());
-
 
130
    		String label = this.getId();
-
 
131
    		log.info("label:" + label);
-
 
132
    		
-
 
133
    		label = URLDecoder.decode(label, "UTF-8");
-
 
134
    		
-
 
135
    		CreationUtils.removeMedia(entityID, label);
-
 
136
		} catch (Exception e) {
-
 
137
			log.error(CreationUtils.getStackTrace(e));
-
 
138
			this.setErrorString(CreationUtils.getStackTrace(e));
-
 
139
			return "fatal";
-
 
140
		}
-
 
141
 
-
 
142
		this.redirectURL = "media?entityID=" + this.getEntityID();
-
 
143
    	
-
 
144
		return "redirect";
119
    
145
    }
120
    /**
146
    /**
121
     * 
147
     * 
122
     * @return
148
     * @return
123
     * @throws Exception 
149
     * @throws Exception 
124
     */
150
     */
Line 302... Line 328...
302
			IOUtils.closeQuietly(out);
328
			IOUtils.closeQuietly(out);
303
		}
329
		}
304
		
330
		
305
		return mediaFileName;
331
		return mediaFileName;
306
	}
332
	}
-
 
333
 
-
 
334
	/**
-
 
335
	 * @param id the id to set
-
 
336
	 */
-
 
337
	public void setId(String id) {
-
 
338
		this.id = id;
-
 
339
	}
-
 
340
 
-
 
341
	/**
-
 
342
	 * @return the id
-
 
343
	 */
-
 
344
	public String getId() {
-
 
345
		return id;
-
 
346
	}
307
}
347
}