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