1 /*******************************************************************************
2 * Copyright (c) 2012-2013 University of Stuttgart.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * and the Apache License 2.0 which both accompany this distribution,
6 * and are available at http://www.eclipse.org/legal/epl-v10.html
7 * and http://www.apache.org/licenses/LICENSE-2.0
10 * Oliver Kopp - initial API and implementation
11 *******************************************************************************/
12 package org.eclipse.winery.repository.datatypes;
14 import java.io.IOException;
16 import javax.xml.bind.annotation.XmlRootElement;
18 import org.apache.commons.io.FilenameUtils;
19 import org.eclipse.winery.common.RepositoryFileReference;
20 import org.eclipse.winery.repository.Constants;
21 import org.eclipse.winery.repository.Prefs;
22 import org.eclipse.winery.repository.Utils;
23 import org.eclipse.winery.repository.backend.Repository;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
29 * https://github.com/blueimp/jQuery-File-Upload/wiki/Google-App-Engine-Java
31 * The getters are named according to the requirements of the template in
32 * jquery-file-upload-full.jsp
35 public class FileMeta {
37 private static final Logger logger = LoggerFactory.getLogger(FileMeta.class);
43 String deleteType = "DELETE";
47 public String getName() {
51 public long getSize() {
55 public String getUrl() {
59 public String getDeleteUrl() {
60 return this.deleteUrl;
63 public String getDeleteType() {
64 return this.deleteType;
67 public String getThumbnailUrl() {
68 return this.thumbnailUrl;
71 public FileMeta(String filename, long size, String url, String thumbnailUrl) {
75 this.thumbnailUrl = thumbnailUrl;
79 public FileMeta(RepositoryFileReference ref) {
80 this.name = ref.getFileName();
82 this.size = Repository.INSTANCE.getSize(ref);
83 } catch (IOException e) {
84 FileMeta.logger.error(e.getMessage(), e);
87 this.url = Utils.getAbsoluteURL(ref);
88 this.deleteUrl = this.url;
89 this.thumbnailUrl = Prefs.INSTANCE.getResourcePath() + Constants.PATH_MIMETYPEIMAGES + FilenameUtils.getExtension(this.name) + Constants.SUFFIX_MIMETYPEIMAGES;
93 * @param ref the reference to get information from
94 * @param URLprefix the string which should be prepended the actual URL.
97 public FileMeta(RepositoryFileReference ref, String URLprefix) {
99 this.url = URLprefix + this.url;
103 * The constructor is used for JAX-B only. Therefore, the warning "unused"
106 @SuppressWarnings("unused")