<div dir="ltr"><div>Hi,<br><br></div>My solution, is not elegance solution, but don´t
have time for correcty solution, used cmspermissionset, dont work change
permission instance my cmsobject, sorry because poor code:<br><br><%@page import="org.opencms.file.<div dir="ltr">CmsResource"%><br><%@page import="java.util.Iterator"%><br><%@page import="java.util.List"%><br><%@page import="java.util.Date"%><br><%@page import="org.opencms.file.history.I_CmsHistoryResource"%><br><%@page import="org.opencms.jsp.CmsJspLoginBean"%><span class="im"><br><%@page import="java.text.SimpleDateFormat"%><br><%@page import="org.opencms.file.CmsObject"%><br></span><%@page import="org.opencms.jsp.CmsJspActionElement"%><span class="im"><br><%@ page import="org.opencms.workplace.*" %><% <br><br></span><span class="im">CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);<br><br></span>boolean testLogin = false;<br>CmsObject cmso = cms.getCmsObject();<span class="im"><br>SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm"); <br></span>CmsJspLoginBean loginBean= new CmsJspLoginBean(pageContext, request, response);<br><br>try {<br> <br> if(loginBean.getUser().isGuestUser()){<br> cmso.loginUser("Admin", "admin");<br> testLogin = true;<span class="im"><br> }<br> <br> Date dt = null;<br> String dataConvertida = null;<br> String dataPesquisada = "01/01/2014 00:01";<br> I_CmsHistoryResource res = null;<br> Long dataCurrentLong = null;<br> Date dataSearchLong = null;<br> List list = cmso.readDeletedResources("/", true); <br> String arquivo;<br> Iterator iter = list.iterator();<br> out.println("Lista: "+ list.size()+"<br>");<br> <br></span><span class="im"> dataPesquisada = request.getParameter("data").toLowerCase();<br> dataSearchLong = sdf.parse(dataPesquisada);<br> out.println("Data a ser pesquisada maior que: <b>" + dataPesquisada + "</b><br><br>");<br> <br> while (iter.hasNext()) {<br> res = (I_CmsHistoryResource)iter.next();<br> //dataConvertida = String.valueOf(res.getDateLastModified());<br> dataCurrentLong = res.getDateLastModified();<br> arquivo = cmso.getSitePath((CmsResource)res);<br> dt = new Date(dataCurrentLong);<br> dataConvertida = sdf.format(dt);<br> if(dataCurrentLong > dataSearchLong.getTime()){<br> //cmso.readResource(arquivo).getStructureId().toString()<br>
out.println(" <b>Nome do recurso excluido:
</b>" + arquivo +" - <b>UUID:</b> " +
res.getResourceId().toString() + " <b>Data da exclusão:</b>
" + dataConvertida + "<br><br>");<br> }<br> }<br> <br> } catch (Exception e) {<br> out.println("<br><b>O formato da data deve ser dd/mm/yyyy HH:mm </b>" +e.getMessage());<br></span> } finally{<br> out.println("<br>Operação realizada com sucesso.");<br> if(testLogin){<br> session.invalidate();<br> }<br> }<br> <br> %></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-11-24 18:46 GMT-02:00 Deiverson Silveira <span dir="ltr"><<a href="mailto:deiverson@solutioncms.com" target="_blank">deiverson@solutioncms.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I again...</div><div><br></div><div>I see the problem:</div><div><br></div><div>in classe CmsObject.java, I have this:</div><div><br></div><div><div> public List<I_CmsHistoryResource> readDeletedResources(String resourcename, boolean readTree) throws CmsException {</div><div><br></div><div> CmsResource resource = readResource(resourcename, CmsResourceFilter.ALL);</div><div> return m_securityManager.readDeletedResources(m_context, resource, readTree);</div><div> }<br></div></div><div><br></div><div>This is a problem >>> return m_securityManager.readDeletedResources(m_context, resource, readTree);<br></div><div><br></div><div>How can set permission in my object?</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-11-24 16:59 GMT-02:00 Deiverson Silveira <span dir="ltr"><<a href="mailto:deiverson@solutioncms.com" target="_blank">deiverson@solutioncms.com</a>></span>:<div><div class="h5"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><div dir="ltr"><span style="font-family:arial,sans-serif;font-size:12.7272720336914px">ahhhh, it is test:</span><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><div style="font-size:12.7272720336914px">cmso.getRequestContext().setSiteRoot(OpenCms.getSiteManager().getDefaultSite().getSiteRoot());<span style="font-size:12.7272720336914px;white-space:pre-wrap"> </span><span style="font-size:12.7272720336914px">cmso.getRequestContext().</span><span style="font-size:12.7272720336914px">setCurrentProject(cmso.</span><span style="font-size:12.7272720336914px">readProject("Offline"));</span></div></div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><span style="font-size:12.7272720336914px"><br></span></div><div style="font-family:arial,sans-serif;font-size:12.7272720336914px"><span style="font-size:12.7272720336914px">But dont work, for work online/offline, remove this.</span></div></div></span><div class="gmail_extra"><br><div class="gmail_quote"><span>2014-11-24 16:58 GMT-02:00 Deiverson Silveira <span dir="ltr"><<a href="mailto:deiverson@solutioncms.com" target="_blank">deiverson@solutioncms.com</a>></span>:<br></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi List,<div><div><div><br></div><div>I'm building a code that need to return the list of deleted files and the uuid from a past date by parameter , however my code works only when I am logged in, if I force the login on the object with admin, works , however it would inject a security breach , this code works online logged in / offline , the problem is when this offline , the file list is reset , someone what should I do to set the permissions of my object so that even offline return my list of deleted resources?</div><div><br></div><div>My Code (but work logged online and offline, but I need work logout :~( :</div><div><div><%@page import="org.opencms.file.CmsProject"%></div><div><%@page import="org.opencms.util.CmsUUID"%></div><div><%@page import="java.io.File"%></div><div><%@page import="java.util.Collections"%></div><div><%@page import="org.apache.commons.io.comparator.LastModifiedFileComparator"%></div><div><%@page import="java.util.Date"%></div><div><%@page import="org.opencms.jsp.CmsJspActionElement"%></div><div><%@page import="java.text.SimpleDateFormat"%></div><div><%@page import="org.opencms.file.CmsObject"%></div><div><%@page import="org.opencms.file.CmsResource"%></div><div><%@page import="org.opencms.workplace.list.CmsListItem"%></div><div><%@page import="org.opencms.file.history.I_CmsHistoryResource"%></div><div><%@page import="org.opencms.main.OpenCms"%></div><div><%@page import="org.opencms.workplace.list.CmsHtmlList"%></div><div><%@page import="java.util.List"%></div><div><%@page import="org.opencms.workplace.commons.CmsDeletedResourcesList"%></div><div><%@page import="java.util.Iterator"%></div><div><%@page import="java.util.Set"%></div><div><%@page import="java.util.Map"%></div><div><%@ page import="org.opencms.workplace.*" %><%<span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm"); </div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);</div><div><span style="white-space:pre-wrap"> </span>CmsObject cmso = cms.getCmsObject();</div><div><br></div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>cmso.getRequestContext().setSiteRoot(OpenCms.getSiteManager().getDefaultSite().getSiteRoot());</div><div><span style="white-space:pre-wrap"> </span>cmso.getRequestContext().setCurrentProject(cmso.readProject("Offline"));</div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>Date dt = null;</div><div><span style="white-space:pre-wrap"> </span>String dataConvertida = null;</div><div><span style="white-space:pre-wrap"> </span>String dataPesquisada = "01/01/2014 00:01";</div><div><span style="white-space:pre-wrap"> </span>I_CmsHistoryResource res = null;</div><div><span style="white-space:pre-wrap"> </span>Long dataCurrentLong = null;</div><div><span style="white-space:pre-wrap"> </span>Date dataSearchLong = null;</div><div><span style="white-space:pre-wrap"> </span>List list = cmso.readDeletedResources("/", true); </div><div><span style="white-space:pre-wrap"> </span>String arquivo;</div><div><span style="white-space:pre-wrap"> </span>Iterator iter = list.iterator();</div><div><span style="white-space:pre-wrap"> </span>out.println("Lista: "+ list.size()+"<br>");</div><div><span style="white-space:pre-wrap"> </span>try {</div><div><span style="white-space:pre-wrap"> </span>dataPesquisada = request.getParameter("data").toLowerCase();</div><div><span style="white-space:pre-wrap"> </span>dataSearchLong = sdf.parse(dataPesquisada);</div><div><span style="white-space:pre-wrap"> </span>out.println("Data a ser pesquisada maior que: <b>" + dataPesquisada + "</b><br><br>");</div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>while (iter.hasNext()) {</div><div><span style="white-space:pre-wrap"> </span> res = (I_CmsHistoryResource)iter.next();</div><div><span style="white-space:pre-wrap"> </span> //dataConvertida = String.valueOf(res.getDateLastModified());</div><div><span style="white-space:pre-wrap"> </span>dataCurrentLong = res.getDateLastModified();</div><div><span style="white-space:pre-wrap"> </span>arquivo = cmso.getSitePath((CmsResource)res);</div><div><span style="white-space:pre-wrap"> </span> dt = new Date(dataCurrentLong);</div><div><span style="white-space:pre-wrap"> </span>dataConvertida = sdf.format(dt);</div><div><span style="white-space:pre-wrap"> </span>if(dataCurrentLong > dataSearchLong.getTime()){</div><div><span style="white-space:pre-wrap"> </span>//cmso.readResource(arquivo).getStructureId().toString()</div><div><span style="white-space:pre-wrap"> </span> <span style="white-space:pre-wrap"> </span>out.println(" <b>Nome do recurso excluido: </b>" + arquivo +" - <b>UUID:</b> " + res.getResourceId().toString() + " <b>Data da exclusão:</b> " + dataConvertida + "<br><br>");</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>} catch (Exception e) {</div><div><span style="white-space:pre-wrap"> </span>out.println("<br><b>O formato da data deve ser dd/mm/yyyy HH:mm </b>" +e.getMessage());</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>%></div></div><div><br></div><div><br></div><div>Help, please experts!</div><div><br></div><div>Regards,</div><div><br></div><div>Deiverson</div><span><font color="#888888"><div><br clear="all"><div><br></div>-- <br><div><i><div><span style="font-style:normal"><i><div><span style="font-style:normal"><i><div style="display:inline!important"><span style="font-style:normal"><i><a href="http://www.solutioncms.com" target="_blank">www.solutioncms.com</a></i></span></div></i></span></div><div><span style="font-style:normal"><i><span style="font-style:normal"><i><div><span style="font-style:normal"><i><div style="display:inline!important"><span style="font-style:normal"><i><span style="font-style:normal"><i><div style="display:inline!important"><i>The Brazilian </i><span style="font-style:normal"><i><div style="display:inline!important"><span style="font-style:normal"><i><span style="font-style:normal"><i><div style="display:inline!important"><i>Official Provider OpenCms</i></div></i></span></i></span></div></i></span></div></i></span></i></span></div></i></span></div></i></span></i></span></div></i></span></div></i></div>
</div></font></span></div></div></div>
</blockquote></div><div><div><br><br clear="all"><div><br></div>-- <br><div><i><div><span style="font-style:normal"><i><div><span style="font-style:normal"><i><div style="display:inline!important"><span style="font-style:normal"><i><a href="http://www.solutioncms.com" target="_blank">www.solutioncms.com</a></i></span></div></i></span></div><div><span style="font-style:normal"><i><span style="font-style:normal"><i><div><span style="font-style:normal"><i><div style="display:inline!important"><span style="font-style:normal"><i><span style="font-style:normal"><i><div style="display:inline!important"><i>The Brazilian </i><span style="font-style:normal"><i><div style="display:inline!important"><span style="font-style:normal"><i><span style="font-style:normal"><i><div style="display:inline!important"><i>Official Provider OpenCms</i></div></i></span></i></span></div></i></span></div></i></span></i></span></div></i></span></div></i></span></i></span></div></i></span></div></i></div>
</div></div></div>
</blockquote></div></div></div><div><div class="h5"><br><br clear="all"><div><br></div>-- <br><div><i><div><span style="font-style:normal"><i><div><span style="font-style:normal"><i><div style="display:inline!important"><span style="font-style:normal"><i><a href="http://www.solutioncms.com" target="_blank">www.solutioncms.com</a></i></span></div></i></span></div><div><span style="font-style:normal"><i><span style="font-style:normal"><i><div><span style="font-style:normal"><i><div style="display:inline!important"><span style="font-style:normal"><i><span style="font-style:normal"><i><div style="display:inline!important"><i>The Brazilian </i><span style="font-style:normal"><i><div style="display:inline!important"><span style="font-style:normal"><i><span style="font-style:normal"><i><div style="display:inline!important"><i>Official Provider OpenCms</i></div></i></span></i></span></div></i></span></div></i></span></i></span></div></i></span></div></i></span></i></span></div></i></span></div></i></div>
</div></div></div>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><i><div><span style="font-style:normal"><i><div><span style="font-style:normal"><i><div style="display:inline!important"><span style="font-style:normal"><i><a href="http://www.solutioncms.com" target="_blank">www.solutioncms.com</a></i></span></div></i></span></div><div><span style="font-style:normal"><i><span style="font-style:normal"><i><div><span style="font-style:normal"><i><div style="display:inline!important"><span style="font-style:normal"><i><span style="font-style:normal"><i><div style="display:inline!important"><i>The Brazilian </i><span style="font-style:normal"><i><div style="display:inline!important"><span style="font-style:normal"><i><span style="font-style:normal"><i><div style="display:inline!important"><i>Official Provider OpenCms</i></div></i></span></i></span></div></i></span></div></i></span></i></span></div></i></span></div></i></span></i></span></div></i></span></div></i></div>
</div>