1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.webserver;
16  
17  import com.liferay.portal.kernel.util.GetterUtil;
18  import com.liferay.portal.kernel.util.HttpUtil;
19  import com.liferay.portal.kernel.util.StringPool;
20  
21  import java.util.Date;
22  
23  /**
24   * <a href="WebServerEntry.java.html"><b><i>View Source</i></b></a>
25   *
26   * @author Brian Wing Shun Chan
27   */
28  public class WebServerEntry {
29  
30      public WebServerEntry(String path, String name) {
31          this(path, name, null, null, null, 0);
32      }
33  
34      public WebServerEntry(
35          String path, String name, Date createDate, Date modifiedDate,
36          String description, long size) {
37  
38          _path = getPath(path, name);
39          _name = name;
40          _createDate = createDate;
41          _modifiedDate = modifiedDate;
42          _description = GetterUtil.getString(description);
43          _size = size;
44      }
45  
46      public Date getCreateDate() {
47          return _createDate;
48      }
49  
50      public String getDescription() {
51          return _description;
52      }
53  
54      public Date getModifiedDate() {
55          return _modifiedDate;
56      }
57  
58      public String getName() {
59          return _name;
60      }
61  
62      public String getPath() {
63          return _path;
64      }
65  
66      public long getSize() {
67          return _size;
68      }
69  
70      public void setCreateDate(Date createDate) {
71          _createDate = createDate;
72      }
73  
74      public void setDescription(String description) {
75          _description = description;
76      }
77  
78      public void setModifiedDate(Date modifiedDate) {
79          _modifiedDate = modifiedDate;
80      }
81  
82      public void setName(String name) {
83          _name = name;
84      }
85  
86      public void setPath(String path) {
87          _path = path;
88      }
89  
90      public void setSize(long size) {
91          _size = size;
92      }
93  
94      protected String getPath(String path, String name) {
95          if (name.endsWith(StringPool.SLASH)) {
96              name = HttpUtil.fixPath(name, false, true);
97  
98              return getPath(path, name) + StringPool.SLASH;
99          }
100 
101         if (path.endsWith(StringPool.SLASH)) {
102             path = path + HttpUtil.encodeURL(name, true);
103         }
104         else {
105             path = path + StringPool.SLASH + HttpUtil.encodeURL(name, true);
106         }
107 
108         return path;
109     }
110 
111     private Date _createDate;
112     private String _description;
113     private Date _modifiedDate;
114     private String _name;
115     private String _path;
116     private long _size;
117 
118 }