001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.webserver;
016    
017    import com.liferay.portal.kernel.util.GetterUtil;
018    import com.liferay.portal.kernel.util.HttpUtil;
019    import com.liferay.portal.kernel.util.StringPool;
020    
021    import java.util.Date;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     */
026    public class WebServerEntry {
027    
028            public WebServerEntry(String path, String name) {
029                    this(path, name, null, null, null, 0);
030            }
031    
032            public WebServerEntry(
033                    String path, String name, Date createDate, Date modifiedDate,
034                    String description, long size) {
035    
036                    _path = getPath(path, name);
037                    _name = name;
038                    _createDate = createDate;
039                    _modifiedDate = modifiedDate;
040                    _description = GetterUtil.getString(description);
041                    _size = size;
042            }
043    
044            public Date getCreateDate() {
045                    return _createDate;
046            }
047    
048            public String getDescription() {
049                    return _description;
050            }
051    
052            public Date getModifiedDate() {
053                    return _modifiedDate;
054            }
055    
056            public String getName() {
057                    return _name;
058            }
059    
060            public String getPath() {
061                    return _path;
062            }
063    
064            public long getSize() {
065                    return _size;
066            }
067    
068            public void setCreateDate(Date createDate) {
069                    _createDate = createDate;
070            }
071    
072            public void setDescription(String description) {
073                    _description = description;
074            }
075    
076            public void setModifiedDate(Date modifiedDate) {
077                    _modifiedDate = modifiedDate;
078            }
079    
080            public void setName(String name) {
081                    _name = name;
082            }
083    
084            public void setPath(String path) {
085                    _path = path;
086            }
087    
088            public void setSize(long size) {
089                    _size = size;
090            }
091    
092            protected String getPath(String path, String name) {
093                    if (name.endsWith(StringPool.SLASH)) {
094                            name = HttpUtil.fixPath(name, false, true);
095    
096                            return getPath(path, name) + StringPool.SLASH;
097                    }
098    
099                    if (path.endsWith(StringPool.SLASH)) {
100                            path = path + HttpUtil.encodeURL(name, true);
101                    }
102                    else {
103                            path = path + StringPool.SLASH + HttpUtil.encodeURL(name, true);
104                    }
105    
106                    return path;
107            }
108    
109            private Date _createDate;
110            private String _description;
111            private Date _modifiedDate;
112            private String _name;
113            private String _path;
114            private long _size;
115    
116    }