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