[opencms-dev] how to find unused/not linked/orphan files in vfs - pls help
always.work.in.progress always.work.in.progress
always.work.in.progress at gmail.com
Tue Feb 27 13:24:26 CET 2018
hi Stephan,
yes it helps a lot!
i created a new "test.jsp" file inside my opencms site with your code;
unfortunately it does not work telling me the following error:
"CmsRelation cannot be resolved to a type"
related to this line code:
List<CmsRelation> relations = cms.getRelationsForResource(file,
CmsRelationFilter.SOURCES);
can be due to some "missing import or declaration of specific java class" ?
at the top of my test.jsp file i have the following "java class page
import":
<%@ page import="java.sql.*,org.opencms.db.*,java.util.*,org.opencms.
jsp.*,org.opencms.file.*,org.opencms.main.*,org.opencms.jsp.util.CmsJspElFunctions"
%>
Thanks again.
Il martedì 27 febbraio 2018, Stephan Schrader <zstephanz at gmail.com> ha
scritto:
> Try to embed this code in a JSP:
>
> String folder = "/test";
>
> CmsObject cms = CmsJspElFunctions.getCmsObject(pageContext);
> List<CmsResource> files = cms.getFilesInFolder(folder);
>
> for (CmsResource file : files) {
> List<CmsRelation> relations = cms.getRelationsForResource(file,
> CmsRelationFilter.SOURCES);
> out.print(file.getRootPath() + " is orphan: " +
> (relations.size() == 0));
> }
>
> Hope this helps you.
>
> Stephan
>
> 2018-02-27 9:58 GMT+01:00 always.work.in.progress always.work.in.progress
> <always.work.in.progress at gmail.com>:
>
>> hi Stephan :)
>> i really thank you for your reply!
>> Can you show me a simple code example in order to better undestand that method
>> you have suggested to me ?
>> say that i have a "test" folder inside opencms VFS:
>>
>> /test
>>
>> and this folder contains some files (.pdf, .docx, etc)
>> how can i create the script in order to check the "orphaned" relations for
>> files inside "/test" folder ?
>>
>> thanks in advance.
>>
>>
>> Il martedì 27 febbraio 2018, Stephan Schrader <zstephanz at gmail.com> ha
>> scritto:
>>
>>> Hi,
>>>
>>> you can use: *CmsObject.getRelationsForResource(CmsResource resource,
>>> CmsRelationFilter filter)* with *CmsRelationFilter.SOURCE* as
>>> parameter. If the result is empty, no other resource references the given
>>> resource.
>>>
>>> Stephan
>>>
>>>
>>>
>>> 2018-02-23 17:59 GMT+01:00 always.work.in.progress
>>> always.work.in.progress <always.work.in.progress at gmail.com>:
>>>
>>>> hi all...
>>>> i am using Opencms 10.0.0/mysql set up in multisite environment (apache
>>>> + mod proxy)
>>>> i manage some large web sites plenty of xml contents/pages that link to
>>>> many internal uploaded pdf/images files/other filetypes etc..
>>>> often these files that are not needed anymore, are unlinked from
>>>> related xml contents, but unfortunately they are not deleted from the vfs
>>>> workplace and so become "forgotten".. :(
>>>>
>>>> Is there an internal workplace jsp script or function in order to find
>>>> these "orphan files" ?
>>>> i mean files that are present in vfs but not anymore linked from any
>>>> xml contents page;
>>>>
>>>> these files waste db blob space and the mysql database under opencms is
>>>> growing in size and getting more and more big..
>>>>
>>>> i tried to look for a way to do that but i've never found a similar
>>>> function/method..
>>>> it would be really useful in order to locate these unused files and
>>>> delete them.
>>>>
>>>> thanks in advance for your reply.
>>>>
>>>> bye.
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> 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
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>> _______________________________________________
>> 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
>>
>>
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20180227/140d55e3/attachment.htm>
More information about the opencms-dev
mailing list