Rev 1627 | Rev 1679 | 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" %> |
1586 | jmachado | 15 | <% |
1675 | jmachado | 16 | |
17 | boolean history = showHistory == null ? true: showHistory; |
||
18 | if(staticTag != null && staticTag) |
||
1586 | jmachado | 19 | { |
1675 | jmachado | 20 | %> |
21 | <div style="display: inline-block"> |
||
22 | <% |
||
23 | if(label != null) |
||
24 | { |
||
25 | %> |
||
26 | <label>${label}</label> |
||
27 | <% |
||
28 | } |
||
29 | %> |
||
30 | <a data-toggle="tooltip" title="Descarregar" class="btn btn-small btn-default <%=iconClasses!= null?iconClasses:""%>" href="<%=request.getContextPath()%>/repositoryStream/${repositoryStream}"><span class="glyphicon glyphicon-download-alt"></span></a> |
||
31 | <% |
||
32 | if(history){%> |
||
33 | <a data-toggle="tooltip" title="Histórico" class="btn btn-small btn-default <%=iconClasses!= null?iconClasses:""%>" target="_blank" href="<%=request.getContextPath()%>/user/data.jsp?id=${repositoryStream}"><span class="icon icon-history icon-large"></span></a> |
||
34 | <%}%> |
||
35 | </div> |
||
36 | <% |
||
37 | } |
||
38 | else if(repositoryStream != null && repositoryStream.length() > 0) |
||
39 | { |
||
1598 | jmachado | 40 | if(!transactional.booleanValue()) |
1586 | jmachado | 41 | { |
42 | AbstractDao.getCurrentSession().beginTransaction(); |
||
43 | } |
||
44 | boolean canAccess = ResourceAccessControl.canAccessResource(repositoryStream,request); |
||
45 | IRepositoryFile repositoryFile = new RepositoryService().load(repositoryStream, UserSessionProxy.loadUserSessionFromRequest(request)); |
||
46 | String iconFile = "icon-file-text"; |
||
47 | if(repositoryFile != null) |
||
48 | { |
||
49 | if(downloadIcon != null && downloadIcon) |
||
50 | { |
||
51 | iconFile = "glyphicon glyphicon-download-alt"; |
||
52 | }else if(repositoryFile.getExtension().equals("pdf")) |
||
53 | { |
||
54 | iconFile = "icon icon-file-pdf icon-large"; |
||
55 | }else if(repositoryFile.getExtension().equals("xls") || repositoryFile.getExtension().equals("xlsx") || repositoryFile.getExtension().equals("csv")) |
||
56 | { |
||
57 | iconFile = "icon icon-file-excel icon-large"; |
||
58 | }else if(repositoryFile.getExtension().equals("doc") || repositoryFile.getExtension().equals("docx")) |
||
59 | { |
||
60 | iconFile = "icon icon-file-word icon-large"; |
||
61 | }else if(repositoryFile.getExtension().equals("zip") || repositoryFile.getExtension().equals("tgz") || repositoryFile.getExtension().equals("gz") |
||
62 | || repositoryFile.getExtension().equals("rar") || repositoryFile.getExtension().equals("7z") || repositoryFile.getExtension().equals("7zip")) |
||
63 | { |
||
64 | iconFile = "icon icon-file-zip icon-large"; |
||
65 | } |
||
66 | } |
||
67 | %> |
||
68 | |||
69 | |||
70 | |||
71 | <% |
||
72 | if(badge != null && badge) |
||
73 | { |
||
74 | if(canAccess) |
||
75 | { |
||
76 | if(label != null) |
||
77 | { |
||
78 | %> |
||
79 | ${label} |
||
80 | <% |
||
81 | } |
||
82 | %> |
||
83 | |||
1675 | jmachado | 84 | <span class="badge icon <%=iconClasses!= null?iconClasses:""%>"> |
1627 | jmachado | 85 | <a data-toggle="tooltip" title="Descarregar" href="javascript:invoqueDataVersionForm(${repositoryStream})"><span class="icon icon-history icon-large"></span></a> |
1586 | jmachado | 86 | </span> |
1675 | jmachado | 87 | <%if(history){%> |
88 | <span class="badge icon <%=iconClasses!= null?iconClasses:""%>"> |
||
1627 | jmachado | 89 | <a data-toggle="tooltip" title="Histórico" href="<%=request.getContextPath()%>/repositoryStream/${repositoryStream}"><span class="<%=iconFile%>"></span></a> |
1586 | jmachado | 90 | </span> |
1675 | jmachado | 91 | <%}%> |
1586 | jmachado | 92 | <% |
93 | } |
||
94 | else |
||
95 | { |
||
96 | %> |
||
97 | <!-- |
||
98 | <span class="icon icon-history icon-large"></span> |
||
99 | <span class="icon <%=iconFile%> icon-large"></span>--> |
||
100 | <% |
||
101 | } |
||
102 | } |
||
103 | else |
||
104 | { |
||
105 | if(canAccess) |
||
106 | { |
||
107 | |||
108 | %> |
||
109 | <div style="display: inline-block"> |
||
110 | <% |
||
111 | if(label != null) |
||
112 | { |
||
113 | %> |
||
114 | <label>${label}</label> |
||
115 | <% |
||
116 | } |
||
117 | %> |
||
1675 | jmachado | 118 | <a data-toggle="tooltip" title="Descarregar" class="btn btn-small btn-default <%=iconClasses!= null?iconClasses:""%>" href="<%=request.getContextPath()%>/repositoryStream/${repositoryStream}"><span class="<%=iconFile%>"></span></a> |
119 | <%if(history){%> |
||
120 | <a data-toggle="tooltip" title="Histórico" class="btn btn-small btn-default <%=iconClasses!= null?iconClasses:""%>" href="javascript:invoqueDataVersionForm(${repositoryStream})"><span class="icon icon-history icon-large"></span></a> |
||
121 | <%}%> |
||
1586 | jmachado | 122 | </div> |
123 | <% |
||
124 | } |
||
125 | else |
||
126 | { |
||
127 | %> |
||
128 | <!--<span class="icon <%=iconFile%> icon-large"></span>--> |
||
129 | <% |
||
130 | } |
||
131 | } |
||
132 | |||
1598 | jmachado | 133 | if(!transactional.booleanValue()) |
1586 | jmachado | 134 | { |
135 | AbstractDao.getCurrentSession().getTransaction().commit(); |
||
136 | } |
||
137 | } |
||
138 | %> |