[opencms-dev] Problem with read deleted files, work online/offline, but not work logout...
Deiverson Silveira
deiverson at solutioncms.com
Tue Nov 25 16:59:17 CET 2014
Hi Kai,
Thank you for response, I Belive this method
CmsResourceFilter.includeDeleted() very usefull for my case, my difficulty
is readDeletedResources (function class CmsObject), this check permission
for read resource (CmsManagedSecurity), then I logout, dont work my code, I
solved, logged user admin, and finally I destroy session (but only Admin is
not logged before, only login if user is guest).
Regards,
Deiverson
2014-11-25 13:20 GMT-02:00 Schliemann, Kai <K.Schliemann at comundus.com>:
> Hi Deiverson,
>
> I did not check what your code does.
>
> But if you need a non-standard list of resources, you can use the class
> CmsResourceFilter (
> http://files.opencms.org/javadoc/core/org/opencms/file/CmsResourceFilter.html
> ).
>
> HTH
>
> Best regards
>
> Kai
>
>
>
> *Von:* opencms-dev-bounces at opencms.org [mailto:
> opencms-dev-bounces at opencms.org] *Im Auftrag von *Deiverson Silveira
> *Gesendet:* Dienstag, 25. November 2014 13:40
> *An:* The OpenCms mailing list
> *Betreff:* Re: [opencms-dev] Problem with read deleted files, work
> online/offline, but not work logout...
>
>
>
> Hi,
>
> 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:
>
> <%@page import="org.opencms.file.
>
> CmsResource"%>
> <%@page import="java.util.Iterator"%>
> <%@page import="java.util.List"%>
> <%@page import="java.util.Date"%>
> <%@page import="org.opencms.file.history.I_CmsHistoryResource"%>
> <%@page import="org.opencms.jsp.CmsJspLoginBean"%>
> <%@page import="java.text.SimpleDateFormat"%>
> <%@page import="org.opencms.file.CmsObject"%>
> <%@page import="org.opencms.jsp.CmsJspActionElement"%>
> <%@ page import="org.opencms.workplace.*" %><%
>
> CmsJspActionElement cms = new CmsJspActionElement(pageContext, request,
> response);
>
> boolean testLogin = false;
> CmsObject cmso = cms.getCmsObject();
> SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm");
> CmsJspLoginBean loginBean= new CmsJspLoginBean(pageContext, request,
> response);
>
> try {
>
> if(loginBean.getUser().isGuestUser()){
> cmso.loginUser("Admin", "admin");
> testLogin = true;
> }
>
> Date dt = null;
> String dataConvertida = null;
> String dataPesquisada = "01/01/2014 00:01";
> I_CmsHistoryResource res = null;
> Long dataCurrentLong = null;
> Date dataSearchLong = null;
> List list = cmso.readDeletedResources("/", true);
> String arquivo;
> Iterator iter = list.iterator();
> out.println("Lista: "+ list.size()+"<br>");
>
> dataPesquisada = request.getParameter("data").toLowerCase();
> dataSearchLong = sdf.parse(dataPesquisada);
> out.println("Data a ser pesquisada maior que: <b>" +
> dataPesquisada + "</b><br><br>");
>
> while (iter.hasNext()) {
> res = (I_CmsHistoryResource)iter.next();
> //dataConvertida = String.valueOf(res.getDateLastModified());
> dataCurrentLong = res.getDateLastModified();
> arquivo = cmso.getSitePath((CmsResource)res);
> dt = new Date(dataCurrentLong);
> dataConvertida = sdf.format(dt);
> if(dataCurrentLong > dataSearchLong.getTime()){
> //cmso.readResource(arquivo).getStructureId().toString()
> out.println(" <b>Nome do recurso excluido: </b>" + arquivo
> +" - <b>UUID:</b> " + res.getResourceId().toString() + " <b>Data da
> exclusão:</b> " + dataConvertida + "<br><br>");
> }
> }
>
> } catch (Exception e) {
> out.println("<br><b>O formato da data deve ser dd/mm/yyyy HH:mm
> </b>" +e.getMessage());
> } finally{
> out.println("<br>Operação realizada com sucesso.");
> if(testLogin){
> session.invalidate();
> }
> }
>
> %>
>
>
>
> 2014-11-24 18:46 GMT-02:00 Deiverson Silveira <deiverson at solutioncms.com>:
>
> I again...
>
>
>
> I see the problem:
>
>
>
> in classe CmsObject.java, I have this:
>
>
>
> public List<I_CmsHistoryResource> readDeletedResources(String
> resourcename, boolean readTree) throws CmsException {
>
>
>
> CmsResource resource = readResource(resourcename,
> CmsResourceFilter.ALL);
>
> return m_securityManager.readDeletedResources(m_context, resource,
> readTree);
>
> }
>
>
>
> This is a problem >>> return
> m_securityManager.readDeletedResources(m_context, resource, readTree);
>
>
>
> How can set permission in my object?
>
>
>
>
>
> 2014-11-24 16:59 GMT-02:00 Deiverson Silveira <deiverson at solutioncms.com>:
>
>
>
> ahhhh, it is test:
>
> cmso.getRequestContext().setSiteRoot(OpenCms.getSiteManager().getDefaultSite().getSiteRoot());
> cmso.getRequestContext().setCurrentProject(cmso.readProject("Offline"));
>
>
>
> But dont work, for work online/offline, remove this.
>
>
>
> 2014-11-24 16:58 GMT-02:00 Deiverson Silveira <deiverson at solutioncms.com>:
>
> Hi List,
>
>
>
> 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?
>
>
>
> My Code (but work logged online and offline, but I need work logout :~( :
>
> <%@page import="org.opencms.file.CmsProject"%>
>
> <%@page import="org.opencms.util.CmsUUID"%>
>
> <%@page import="java.io.File"%>
>
> <%@page import="java.util.Collections"%>
>
> <%@page
> import="org.apache.commons.io.comparator.LastModifiedFileComparator"%>
>
> <%@page import="java.util.Date"%>
>
> <%@page import="org.opencms.jsp.CmsJspActionElement"%>
>
> <%@page import="java.text.SimpleDateFormat"%>
>
> <%@page import="org.opencms.file.CmsObject"%>
>
> <%@page import="org.opencms.file.CmsResource"%>
>
> <%@page import="org.opencms.workplace.list.CmsListItem"%>
>
> <%@page import="org.opencms.file.history.I_CmsHistoryResource"%>
>
> <%@page import="org.opencms.main.OpenCms"%>
>
> <%@page import="org.opencms.workplace.list.CmsHtmlList"%>
>
> <%@page import="java.util.List"%>
>
> <%@page import="org.opencms.workplace.commons.CmsDeletedResourcesList"%>
>
> <%@page import="java.util.Iterator"%>
>
> <%@page import="java.util.Set"%>
>
> <%@page import="java.util.Map"%>
>
> <%@ page import="org.opencms.workplace.*" %><%
>
> SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm");
>
> CmsJspActionElement cms = new CmsJspActionElement(pageContext, request,
> response);
>
> CmsObject cmso = cms.getCmsObject();
>
>
>
>
> cmso.getRequestContext().setSiteRoot(OpenCms.getSiteManager().getDefaultSite().getSiteRoot());
>
> cmso.getRequestContext().setCurrentProject(cmso.readProject("Offline"));
>
> Date dt = null;
>
> String dataConvertida = null;
>
> String dataPesquisada = "01/01/2014 00:01";
>
> I_CmsHistoryResource res = null;
>
> Long dataCurrentLong = null;
>
> Date dataSearchLong = null;
>
> List list = cmso.readDeletedResources("/", true);
>
> String arquivo;
>
> Iterator iter = list.iterator();
>
> out.println("Lista: "+ list.size()+"<br>");
>
> try {
>
> dataPesquisada = request.getParameter("data").toLowerCase();
>
> dataSearchLong = sdf.parse(dataPesquisada);
>
> out.println("Data a ser pesquisada maior que: <b>" + dataPesquisada +
> "</b><br><br>");
>
> while (iter.hasNext()) {
>
> res = (I_CmsHistoryResource)iter.next();
>
> //dataConvertida = String.valueOf(res.getDateLastModified());
>
> dataCurrentLong = res.getDateLastModified();
>
> arquivo = cmso.getSitePath((CmsResource)res);
>
> dt = new Date(dataCurrentLong);
>
> dataConvertida = sdf.format(dt);
>
> if(dataCurrentLong > dataSearchLong.getTime()){
>
> //cmso.readResource(arquivo).getStructureId().toString()
>
> out.println(" <b>Nome do recurso excluido: </b>" + arquivo +" -
> <b>UUID:</b> " + res.getResourceId().toString() + " <b>Data da
> exclusão:</b> " + dataConvertida + "<br><br>");
>
> }
>
> }
>
> } catch (Exception e) {
>
> out.println("<br><b>O formato da data deve ser dd/mm/yyyy HH:mm </b>"
> +e.getMessage());
>
> }
>
> %>
>
>
>
>
>
> Help, please experts!
>
>
>
> Regards,
>
>
>
> Deiverson
>
>
>
>
> --
>
> *www.solutioncms.com <http://www.solutioncms.com>*
>
> *The Brazilian *
>
> *Official Provider OpenCms*
>
>
>
>
>
> --
>
> *www.solutioncms.com <http://www.solutioncms.com>*
>
> *The Brazilian *
>
> *Official Provider OpenCms*
>
>
>
>
>
> --
>
> *www.solutioncms.com <http://www.solutioncms.com>*
>
> *The Brazilian *
>
> *Official Provider OpenCms*
>
>
>
>
> --
>
> *www.solutioncms.com <http://www.solutioncms.com>*
>
> *The Brazilian *
>
> *Official Provider OpenCms*
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev
>
>
>
>
>
--
*www.solutioncms.com <http://www.solutioncms.com>The Brazilian Official
Provider OpenCms*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20141125/52e1fbf8/attachment.htm>
More information about the opencms-dev
mailing list