Rev 1764 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1764 | Rev 1827 | ||
---|---|---|---|
1 | <%@ tag import="jomm.dao.impl.AbstractDao" %> |
1 | <%@tag import="jomm.dao.impl.AbstractDao" %> |
2 | <%@ tag import="pt.estgp.estgweb.filters.filters.ResourceAccessControl" %> |
2 | <%@tag import="pt.estgp.estgweb.filters.filters.ResourceAccessControl" %> |
3 | <%@ tag import="pt.estgp.estgweb.services.data.IRepositoryFile" %> |
3 | <%@tag import="pt.estgp.estgweb.services.data.IRepositoryFile" %> |
4 | <%@ tag import="pt.estgp.estgweb.services.data.RepositoryService" %> |
4 | <%@tag import="pt.estgp.estgweb.services.data.RepositoryService" %> |
5 | <%@ tag import="pt.estgp.estgweb.web.UserSessionProxy" %> |
5 | <%@tag import="pt.estgp.estgweb.web.UserSessionProxy" %> |
6 | <%@tag description="Repository File Tag for Download" pageEncoding="UTF-8"%> |
6 | <%@tag description="Repository File Tag for Download" pageEncoding="UTF-8"%> |
7 | <%@attribute name="staticTag" type="java.lang.Boolean" required="false" %> |
7 | <%@attribute name="staticTag" type="java.lang.Boolean" required="false" %> |
8 | <%@attribute name="transactional" type="java.lang.Boolean" required="true" %> |
8 | <%@attribute name="transactional" type="java.lang.Boolean" required="true" %> |
9 | <%@attribute name="repositoryStream" type="java.lang.String" required="false"%> |
9 | <%@attribute name="repositoryStream" type="java.lang.String" required="false"%> |
10 | <%@attribute name="badge" type="java.lang.Boolean" required="false" %> |
10 | <%@attribute name="badge" type="java.lang.Boolean" required="false" %> |
11 | <%@attribute name="label" type="java.lang.String" required="false" %> |
11 | <%@attribute name="label" type="java.lang.String" required="false" %> |
12 | <%@attribute name="iconClasses" type="java.lang.String" required="false" %> |
12 | <%@attribute name="iconClasses" type="java.lang.String" required="false" %> |
13 | <%@attribute name="downloadIcon" type="java.lang.Boolean" required="false" %> |
13 | <%@attribute name="downloadIcon" type="java.lang.Boolean" required="false" %> |
14 | <%@attribute name="showHistory" type="java.lang.Boolean" required="false" %> |
14 | <%@attribute name="showHistory" type="java.lang.Boolean" required="false" %> |
15 | <%@attribute name="target" type="java.lang.String" required="false" %> |
15 | <%@attribute name="target" type="java.lang.String" required="false" %> |
16 | <%@attribute name="btnXs" type="java.lang.Boolean" required="false" %> |
16 | <%@attribute name="btnXs" type="java.lang.Boolean" required="false" %> |
17 | <%@attribute name="iconLeft" type="java.lang.Boolean" required="false" %> |
17 | <%@attribute name="iconLeft" type="java.lang.Boolean" required="false" %> |
18 | 18 | ||
19 | <% |
19 | <% |
20 | 20 | ||
21 | String targetStr = target == null ? "" : " target=\"" + target + "\" "; |
21 | String targetStr = target == null ? "" : " target=\"" + target + "\" "; |
22 | boolean history = showHistory == null ? true: showHistory; |
22 | boolean history = showHistory == null ? true: showHistory; |
23 | boolean iconLeftPos = iconLeft == null ? false: true; |
23 | boolean iconLeftPos = iconLeft == null ? false: true; |
24 | String btnXsClass = btnXs != null && btnXs == true ? " btn-xs " : ""; |
24 | String btnXsClass = btnXs != null && btnXs == true ? " btn-xs " : ""; |
25 | request.setAttribute("btnXsClass",btnXsClass); |
25 | request.setAttribute("btnXsClass",btnXsClass); |
26 | if(staticTag != null && staticTag) |
26 | if(staticTag != null && staticTag) |
27 | { |
27 | { |
28 | %> |
28 | %> |
29 | <div style="display: inline-block"> |
29 | <div style="display: inline-block"> |
30 | <% |
30 | <% |
31 | if(label != null) |
31 | if(label != null) |
32 | { |
32 | { |
33 | %> |
33 | %> |
34 | <label>${label}</label> |
34 | <label>${label}</label> |
35 | <% |
35 | <% |
36 | } |
36 | } |
37 | %> |
37 | %> |
38 | <a data-toggle="tooltip" title="Descarregar" <%=targetStr%> class="btn ${btnXsClass} btn-default <%=iconClasses!= null?iconClasses:""%>" href="<%=request.getContextPath()%>/repositoryStream/${repositoryStream}"><span class="glyphicon glyphicon-download-alt"></span></a> |
38 | <a data-toggle="tooltip" title="Descarregar" <%=targetStr%> class="btn ${btnXsClass} btn-default <%=iconClasses!= null?iconClasses:""%>" href="<%=request.getContextPath()%>/repositoryStream/${repositoryStream}"><span class="glyphicon glyphicon-download-alt"></span></a> |
39 | <% |
39 | <% |
40 | if(history){%> |
40 | if(history){%> |
41 | <a data-toggle="tooltip" title="Histórico" class="btn ${btnXsClass} btn-default <%=iconClasses!= null?iconClasses:""%>" target="_blank" href="<%=request.getContextPath()%>/user/data.jsp?id=${repositoryStream}"><span class="icon icon-history icon-large"></span></a> |
41 | <a data-toggle="tooltip" title="Histórico" class="btn ${btnXsClass} btn-default <%=iconClasses!= null?iconClasses:""%>" target="_blank" href="<%=request.getContextPath()%>/user/data.jsp?id=${repositoryStream}"><span class="icon icon-history icon-large"></span></a> |
42 | <%}%> |
42 | <%}%> |
43 | </div> |
43 | </div> |
44 | <% |
44 | <% |
45 | } |
45 | } |
46 | else if(repositoryStream != null && repositoryStream.length() > 0) |
46 | else if(repositoryStream != null && repositoryStream.length() > 0) |
47 | { |
47 | { |
48 | if(!transactional.booleanValue()) |
48 | if(!transactional.booleanValue()) |
49 | { |
49 | { |
50 | AbstractDao.getCurrentSession().beginTransaction(); |
50 | AbstractDao.getCurrentSession().beginTransaction(); |
51 | } |
51 | } |
52 | boolean canAccess = ResourceAccessControl.canAccessResource(repositoryStream,request); |
52 | boolean canAccess = ResourceAccessControl.canAccessResource(repositoryStream,request); |
53 | IRepositoryFile repositoryFile = new RepositoryService().load(repositoryStream, UserSessionProxy.loadUserSessionFromRequest(request)); |
53 | IRepositoryFile repositoryFile = new RepositoryService().load(repositoryStream, UserSessionProxy.loadUserSessionFromRequest(request)); |
54 | String iconFile = "icon-file-text"; |
54 | String iconFile = "icon-file-text"; |
55 | if(repositoryFile != null) |
55 | if(repositoryFile != null) |
56 | { |
56 | { |
57 | if(downloadIcon != null && downloadIcon) |
57 | if(downloadIcon != null && downloadIcon) |
58 | { |
58 | { |
59 | iconFile = "glyphicon glyphicon-download-alt"; |
59 | iconFile = "glyphicon glyphicon-download-alt"; |
60 | }else if(repositoryFile.getExtension().equalsIgnoreCase("pdf")) |
60 | }else if(repositoryFile.getExtension().equalsIgnoreCase("pdf")) |
61 | { |
61 | { |
62 | iconFile = "icon icon-file-pdf icon-large"; |
62 | iconFile = "icon icon-file-pdf icon-large"; |
63 | }else if(repositoryFile.getExtension().equalsIgnoreCase("xls") || repositoryFile.getExtension().equalsIgnoreCase("xlsx") || repositoryFile.getExtension().equalsIgnoreCase("csv")) |
63 | }else if(repositoryFile.getExtension().equalsIgnoreCase("xls") || repositoryFile.getExtension().equalsIgnoreCase("xlsx") || repositoryFile.getExtension().equalsIgnoreCase("csv")) |
64 | { |
64 | { |
65 | iconFile = "icon icon-file-excel icon-large"; |
65 | iconFile = "icon icon-file-excel icon-large"; |
66 | }else if(repositoryFile.getExtension().equalsIgnoreCase("doc") || repositoryFile.getExtension().equalsIgnoreCase("docx")) |
66 | }else if(repositoryFile.getExtension().equalsIgnoreCase("doc") || repositoryFile.getExtension().equalsIgnoreCase("docx")) |
67 | { |
67 | { |
68 | iconFile = "icon icon-file-word icon-large"; |
68 | iconFile = "icon icon-file-word icon-large"; |
69 | }else if(repositoryFile.getExtension().equals("zip") || repositoryFile.getExtension().equalsIgnoreCase("tgz") || repositoryFile.getExtension().equalsIgnoreCase("gz") |
69 | }else if(repositoryFile.getExtension().equals("zip") || repositoryFile.getExtension().equalsIgnoreCase("tgz") || repositoryFile.getExtension().equalsIgnoreCase("gz") |
70 | || repositoryFile.getExtension().equalsIgnoreCase("rar") || repositoryFile.getExtension().equalsIgnoreCase("7z") || repositoryFile.getExtension().equalsIgnoreCase("7zip")) |
70 | || repositoryFile.getExtension().equalsIgnoreCase("rar") || repositoryFile.getExtension().equalsIgnoreCase("7z") || repositoryFile.getExtension().equalsIgnoreCase("7zip")) |
71 | { |
71 | { |
72 | iconFile = "icon icon-file-zip icon-large"; |
72 | iconFile = "icon icon-file-zip icon-large"; |
73 | } |
73 | } |
74 | } |
74 | } |
75 | %> |
75 | %> |
76 | 76 | ||
77 | 77 | ||
78 | 78 | ||
79 | <% |
79 | <% |
80 | if(badge != null && badge) |
80 | if(badge != null && badge) |
81 | { |
81 | { |
82 | if(canAccess) |
82 | if(canAccess) |
83 | { |
83 | { |
84 | if(label != null) |
84 | if(label != null) |
85 | { |
85 | { |
86 | %> |
86 | %> |
87 | ${label} |
87 | ${label} |
88 | <% |
88 | <% |
89 | } |
89 | } |
90 | %> |
90 | %> |
91 | 91 | ||
92 | <span class="badge icon <%=iconClasses!= null?iconClasses:""%>"> |
92 | <span class="badge icon <%=iconClasses!= null?iconClasses:""%>"> |
93 | <a data-toggle="tooltip" <%=targetStr%> title="Descarregar" href="<%=request.getContextPath()%>/repositoryStream/${repositoryStream}"><span class="<%=iconFile%>"></span></a> |
93 | <a data-toggle="tooltip" <%=targetStr%> title="Descarregar" href="<%=request.getContextPath()%>/repositoryStream/${repositoryStream}"><span class="<%=iconFile%>"></span></a> |
94 | </span> |
94 | </span> |
95 | <%if(history){%> |
95 | <%if(history){%> |
96 | <span class="badge icon <%=iconClasses!= null?iconClasses:""%>"> |
96 | <span class="badge icon <%=iconClasses!= null?iconClasses:""%>"> |
97 | <a data-toggle="tooltip" title="Histórico" href="javascript:invoqueDataVersionForm(${repositoryStream})"><span class="icon icon-history icon-large"></span></a> |
97 | <a data-toggle="tooltip" title="Histórico" href="javascript:invoqueDataVersionForm(${repositoryStream})"><span class="icon icon-history icon-large"></span></a> |
98 | </span> |
98 | </span> |
99 | 99 | ||
100 | <%}%> |
100 | <%}%> |
101 | <% |
101 | <% |
102 | } |
102 | } |
103 | else |
103 | else |
104 | { |
104 | { |
105 | %> |
105 | %> |
106 | <!-- |
106 | <!-- |
107 | <span class="icon icon-history icon-large"></span> |
107 | <span class="icon icon-history icon-large"></span> |
108 | <span class="icon <%=iconFile%> icon-large"></span>--> |
108 | <span class="icon <%=iconFile%> icon-large"></span>--> |
109 | <% |
109 | <% |
110 | } |
110 | } |
111 | } |
111 | } |
112 | else |
112 | else |
113 | { |
113 | { |
114 | if(canAccess) |
114 | if(canAccess) |
115 | { |
115 | { |
116 | 116 | ||
117 | %> |
117 | %> |
118 | <div style="display: inline-block"> |
118 | <div style="display: inline-block"> |
119 | <% |
119 | <% |
120 | if(label != null) |
120 | if(label != null) |
121 | { |
121 | { |
122 | %> |
122 | %> |
123 | <label>${label}</label> |
123 | <label>${label}</label> |
124 | <% |
124 | <% |
125 | } |
125 | } |
126 | %> |
126 | %> |
127 | <a data-toggle="tooltip" title="Descarregar" <%=targetStr%> class="btn ${btnXsClass} btn-default <%=iconClasses!= null?iconClasses:""%>" href="<%=request.getContextPath()%>/repositoryStream/${repositoryStream}"><span class="<%=iconFile%>"></span></a> |
127 | <a data-toggle="tooltip" title="Descarregar" <%=targetStr%> class="btn ${btnXsClass} btn-default <%=iconClasses!= null?iconClasses:""%>" href="<%=request.getContextPath()%>/repositoryStream/${repositoryStream}"><span class="<%=iconFile%>"></span></a> |
128 | <%if(history){%> |
128 | <%if(history){%> |
129 | <a data-toggle="tooltip" title="Histórico" class="btn ${btnXsClass} btn-default <%=iconClasses!= null?iconClasses:""%>" href="javascript:invoqueDataVersionForm(${repositoryStream})"><span class="icon icon-history icon-large"></span></a> |
129 | <a data-toggle="tooltip" title="Histórico" class="btn ${btnXsClass} btn-default <%=iconClasses!= null?iconClasses:""%>" href="javascript:invoqueDataVersionForm(${repositoryStream})"><span class="icon icon-history icon-large"></span></a> |
130 | <%}%> |
130 | <%}%> |
131 | </div> |
131 | </div> |
132 | <% |
132 | <% |
133 | } |
133 | } |
134 | else |
134 | else |
135 | { |
135 | { |
136 | %> |
136 | %> |
137 | <!--<span class="icon <%=iconFile%> icon-large"></span>--> |
137 | <!--<span class="icon <%=iconFile%> icon-large"></span>--> |
138 | <% |
138 | <% |
139 | } |
139 | } |
140 | } |
140 | } |
141 | 141 | ||
142 | if(!transactional.booleanValue()) |
142 | if(!transactional.booleanValue()) |
143 | { |
143 | { |
144 | AbstractDao.getCurrentSession().getTransaction().commit(); |
144 | AbstractDao.getCurrentSession().getTransaction().commit(); |
145 | } |
145 | } |
146 | } |
146 | } |
147 | %> |
147 | %> |
148 | 148 | ||
149 | Generated by GNU Enscript 1.6.5.2. |
149 | Generated by GNU Enscript 1.6.5.2. |
150 | 150 | ||
151 | 151 |