package org.mvnsearch.ali.oss.spring.services;

import java.util.Date;

/**
 * oss object document
 *
 * @author linux_china
 */
public class OssObjectDocument {
    /**
     * bucket
     */
    private String bucket;
    /**
     * path
     */
    private String path;
    /**
     * name
     */
    private String name;
    /**
     * created timestamp
     */
    private Date date;
    /**
     * content type
     */
    private String contentType;
    /**
     * content length
     */
    private Integer contentLength;

    public String getBucket() {
        return bucket;
    }

    public void setBucket(String bucket) {
        this.bucket = bucket;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public String getContentType() {
        return contentType;
    }

    public void setContentType(String contentType) {
        this.contentType = contentType;
    }

    public Integer getContentLength() {
        return contentLength;
    }

    public void setContentLength(Integer contentLength) {
        this.contentLength = contentLength;
    }
}

@@ -41,16 +41,205 @@
 vices;%0A%0A
+import com.aliyun.openservices.oss.model.OSSObjectSummary;%0Aimport org.springframework.mail.javamail.ConfigurableMimeFileTypeMap;%0Aimport org.springframework.shell.support.util.StringUtils;%0A%0A
 import j
@@ -344,16 +344,110 @@
 ument %7B%0A
+    private static ConfigurableMimeFileTypeMap mimeTypes = new ConfigurableMimeFileTypeMap();%0A
     /**%0A
@@ -1065,16 +1065,36 @@
 s.path =
+ path == null ? %22%22 :
  path;%0A 
@@ -1711,11 +1711,1170 @@
 h;%0A    %7D
+%0A%0A    /**%0A     * get object uri%0A     *%0A     * @return object uri%0A     */%0A    public String getObjectUri() %7B%0A        String objectKey = StringUtils.defaultIfEmpty(path, %22%22) + %22/%22 + name;%0A        return new OSSUri(bucket, objectKey).toString();%0A    %7D%0A%0A    /**%0A     * construct from object summary%0A     *%0A     * @param objectSummary object summary%0A     * @return object document%0A     */%0A    public static OssObjectDocument constructFromObjectSummary(OSSObjectSummary objectSummary) %7B%0A        OssObjectDocument document = new OssObjectDocument();%0A        document.setBucket(objectSummary.getBucketName());%0A        String objectKey = objectSummary.getKey();%0A        if (objectKey.contains(%22/%22)) %7B%0A            document.setPath(objectKey.substring(0, objectKey.lastIndexOf(%22/%22)));%0A            document.setName(objectKey.substring(objectKey.lastIndexOf(%22/%22) + 1));%0A        %7D else %7B%0A            document.setName(objectKey);%0A        %7D%0A        document.setContentType(mimeTypes.getContentType(document.getName()));%0A        document.setContentLength((int) objectSummary.getSize());%0A        document.setDate(objectSummary.getLastModified());%0A        return document;%0A    %7D
 %0A%7D%0A

add method