Rev 1586 | Rev 1675 | 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"%> |
||
7 | <%@attribute name="transactional" type="java.lang.Boolean" required="true" %> |
||
8 | <%@attribute name="repositoryStream" type="java.lang.String" required="false"%> |
||
9 | <%@attribute name="badge" type="java.lang.Boolean" required="false" %> |
||
10 | <%@attribute name="label" type="java.lang.String" required="false" %> |
||
11 | <%@attribute name="downloadIcon" type="java.lang.Boolean" required="false" %> |
||
12 | <% |
||
13 | if(repositoryStream != null && repositoryStream.length() > 0) |
||
14 | { |
||
1598 | jmachado | 15 | if(!transactional.booleanValue()) |
1586 | jmachado | 16 | { |
17 | AbstractDao.getCurrentSession().beginTransaction(); |
||
18 | } |
||
19 | boolean canAccess = ResourceAccessControl.canAccessResource(repositoryStream,request); |
||
20 | IRepositoryFile repositoryFile = new RepositoryService().load(repositoryStream, UserSessionProxy.loadUserSessionFromRequest(request)); |
||
21 | String iconFile = "icon-file-text"; |
||
22 | if(repositoryFile != null) |
||
23 | { |
||
24 | if(downloadIcon != null && downloadIcon) |
||
25 | { |
||
26 | iconFile = "glyphicon glyphicon-download-alt"; |
||
27 | }else if(repositoryFile.getExtension().equals("pdf")) |
||
28 | { |
||
29 | iconFile = "icon icon-file-pdf icon-large"; |
||
30 | }else if(repositoryFile.getExtension().equals("xls") || repositoryFile.getExtension().equals("xlsx") || repositoryFile.getExtension().equals("csv")) |
||
31 | { |
||
32 | iconFile = "icon icon-file-excel icon-large"; |
||
33 | }else if(repositoryFile.getExtension().equals("doc") || repositoryFile.getExtension().equals("docx")) |
||
34 | { |
||
35 | iconFile = "icon icon-file-word icon-large"; |
||
36 | }else if(repositoryFile.getExtension().equals("zip") || repositoryFile.getExtension().equals("tgz") || repositoryFile.getExtension().equals("gz") |
||
37 | || repositoryFile.getExtension().equals("rar") || repositoryFile.getExtension().equals("7z") || repositoryFile.getExtension().equals("7zip")) |
||
38 | { |
||
39 | iconFile = "icon icon-file-zip icon-large"; |
||
40 | } |
||
41 | } |
||
42 | %> |
||
43 | |||
44 | |||
45 | |||
46 | <% |
||
47 | if(badge != null && badge) |
||
48 | { |
||
49 | if(canAccess) |
||
50 | { |
||
51 | if(label != null) |
||
52 | { |
||
53 | %> |
||
54 | ${label} |
||
55 | <% |
||
56 | } |
||
57 | %> |
||
58 | |||
59 | <span class="badge icon"> |
||
60 | <a href="javascript:invoqueDataVersionForm(${repositoryStream})"><span class="icon icon-history icon-large"></span></a> |
||
61 | </span> |
||
62 | <span class="badge icon"> |
||
63 | <a href="<%=request.getContextPath()%>/repositoryStream/${repositoryStream}"><span class="<%=iconFile%>"></span></a> |
||
64 | </span> |
||
65 | <% |
||
66 | } |
||
67 | else |
||
68 | { |
||
69 | %> |
||
70 | <!-- |
||
71 | <span class="icon icon-history icon-large"></span> |
||
72 | <span class="icon <%=iconFile%> icon-large"></span>--> |
||
73 | <% |
||
74 | } |
||
75 | } |
||
76 | else |
||
77 | { |
||
78 | if(canAccess) |
||
79 | { |
||
80 | |||
81 | %> |
||
82 | <div style="display: inline-block"> |
||
83 | <% |
||
84 | if(label != null) |
||
85 | { |
||
86 | %> |
||
87 | <label>${label}</label> |
||
88 | <% |
||
89 | } |
||
90 | %> |
||
91 | <a class="btn btn-small btn-default" href="<%=request.getContextPath()%>/repositoryStream/${repositoryStream}"><span class="<%=iconFile%>"></span></a> |
||
92 | <a class="btn btn-small btn-default" href="javascript:invoqueDataVersionForm(${repositoryStream})"><span class="icon icon-history icon-large"></span></a> |
||
93 | </div> |
||
94 | <% |
||
95 | } |
||
96 | else |
||
97 | { |
||
98 | %> |
||
99 | <!--<span class="icon <%=iconFile%> icon-large"></span>--> |
||
100 | <% |
||
101 | } |
||
102 | } |
||
103 | |||
1598 | jmachado | 104 | if(!transactional.booleanValue()) |
1586 | jmachado | 105 | { |
106 | AbstractDao.getCurrentSession().getTransaction().commit(); |
||
107 | } |
||
108 | } |
||
109 | %> |