Forum Ametys

Forum de la communauté Ametys

You are not logged in.

#1 15/07/2014 16:10:36

fahime
Guest
Registered: 27/06/2014
Posts: 18

how can I access to files that uploaded with file explorer

Hi

I want to create a service that search a keyword in content of specific files.
for first version, I want to use Ametys file explorer and upload my files and then search a keyword in content of them

how can I access to files that uploaded with Ametys file explorer?
where are these files?

thanks

Last edited by fahime (15/07/2014 16:13:16)

Offline

#2 15/07/2014 16:22:40

Raphaël Franchet
Expert Team
From: Toulouse
Registered: 10/08/2010
Posts: 1,091

Re: how can I access to files that uploaded with file explorer

Hi,

That files are stored in JCR (not in file system or sql db).

The behavior you want to achieve is complicated to implement ; but fortunately, there is something by default close to what you need.
First, you have to store your documents in attachments of pages (and not in explorer), you hava to consider this page as a tiny document manager. In this page now insert the "Search document service"... and that's it !


Raphael Franchet
Expert Ametys

Offline

#3 19/07/2014 15:30:34

fahime
Guest
Registered: 27/06/2014
Posts: 18

Re: how can I access to files that uploaded with file explorer

thank you dear Raphael Franchet,

How can I see and examine writen codes for Search service and create a new service like it but with my own functionalities?

in cms/WEB-INF/lib path, I can't find any jar file for Search service,,

Offline

#4 21/07/2014 09:57:21

Raphaël Franchet
Expert Team
From: Toulouse
Registered: 10/08/2010
Posts: 1,091

Re: how can I access to files that uploaded with file explorer

You will find all the code in the Ametys svn at https://svn.ametys.org
The search services are so fundamentals that they are part of the kernel web plugin.

To do what you want:
1) You have to create your own plugin.
2) Declare a new service in it, as the current one is declared here : in file https://svn.ametys.org/trunk/web/branch … lugin.xml, the "org.ametys.web.service.ResourcesSearchService" extension.
3) Duplicate in the sitemap the associated "service/search/resources.html" pipeline in file https://svn.ametys.org/trunk/web/branch … temap.xmap
4) But use your own generator by extending https://svn.ametys.org/trunk/web/branch … rator.java for 3.5
5) You will also have to duplicate XSL files (or just add empty xsl importing the default search one) here https://svn.ametys.org/trunk/web/branch … resources/ (use the _3.3.xsl preferently)


Raphael Franchet
Expert Ametys

Offline

#5 22/07/2014 09:33:59

fahime
Guest
Registered: 27/06/2014
Posts: 18

Re: how can I access to files that uploaded with file explorer

thank you dear Raphael Franchet,
your help was very very good smile

when I examin ametys .xmap files, I see tags like <map:transform src="service://@xslt" type="xslt"/>
what does service://@xslt mean?

thanks in advance

Last edited by fahime (22/07/2014 09:36:25)

Offline

#6 22/07/2014 10:15:39

Raphaël Franchet
Expert Team
From: Toulouse
Registered: 10/08/2010
Posts: 1,091

Re: how can I access to files that uploaded with file explorer

Hi,

Protocol "service://" means that the following XSLT file will be looked up in several directories. E.g. service://dir/file.xsl will be tested here
- skins/CURRENT_SKIN/templates/CURRENT_TEMPLATE/stylesheets/SERVICE_PLUGIN/dir/file.xsl
- skins/CURRENT_SKIN/services/SERVICE_PLUGIN/dir/file.xsl
- plugins/SERVICE_PLUGIN/dir/file.xsl

So this allow to offer a default rendering in the plugin, that can be override in a particular skin and even override for a particular template.

----------------

The second part "@xslt" means that it will take the value of the service parameter named "xslt".

---------------

So, all this together, means that the contributor will choose a file in a list when configuring its service ; and that file will be take in the template, the skin or the plugin.


Raphael Franchet
Expert Ametys

Offline

#7 01/08/2014 08:05:39

fahime
Guest
Registered: 27/06/2014
Posts: 18

Re: how can I access to files that uploaded with file explorer

Hi dear Raphael Franchet,
with help of you,I can create service interface.
getting user inputs, search and returning results are another important jobs which I must do.

I examin https://svn.ametys.org/trunk/web/branch … rator.java file and see getQuery,_addTextFieldQuery and ... functions that seem to be used for create query, but I don't know how execution is getting here because form action in Search service doesn't show a url for processing user inputs. url is something like ...index.html#nav

I want to get user input (keyword or reqular expression) and search in content of files that I added to resource explorer then show all sections of file content (for example two words after and two words before keyword) that keyword is found as a result in table.

I need some help,please help me.

thanks in advance

Offline

#8 05/08/2014 03:43:16

fahime
Guest
Registered: 27/06/2014
Posts: 18

Re: how can I access to files that uploaded with file explorer

I want to devide my problem into smaller problems.
First:
I want to have a form with an inputbox and a submit button,when user type a word in inputbox and press submit button show a message like
Hello [enterred word] to user
in sitemap-front.xmap file,I add this codes

<map:match pattern="service/search/concordance.html">
                <map:generate src="service:web://concordance/interface.xml"/>
                <map:transform src="service:web://concordance/transform.xsl"/>
                <map:serialize/>
</map:match>

it's correct and show me my form,transform.xsl file is

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>
My Test Form
</title>
</head>
<body>
<form action="service/search/concordance" method="post">
<input type="textbox" name="keyword"/>
<input type="submit" value="submit"/>
</form>
</body>
</html>
</xsl:template>

now I must add a pipeline for form action,in sitemap-front.xmap file,I add this codes

<map:match pattern="*/service/search/concordance">
                <map:generate src="service:web://concordance/interface.xml"/>
                <map:transform src="service:web://concordance/results.xsl"/>
                <map:serialize/>
</map:match>

but when I press submit button I have error

org.apache.cocoon.ResourceNotFoundException : No pipeline matched request test1/en/service/search/concordance

after show this error,the page is redirecting to index page that I've add my service
how can I solve error?
thanks in advance

Last edited by fahime (05/08/2014 03:45:22)

Offline

#9 25/08/2014 10:36:57

Raphaël Franchet
Expert Team
From: Toulouse
Registered: 10/08/2010
Posts: 1,091

Re: how can I access to files that uploaded with file explorer

Hi!

Short answer:
You have to transmit user input through parameters and do not modifiy the URL.
In java, you will read it with "request.getParameter('myparam')".
In XSLT, you can read it with "ametys:requestParameter('myparam')" https://wiki.ametys.org/display/AMETYSF … Parameter.
In sitemap, you will read it with "{request-param:myparam}"

Long answer:
When you set a pipeline in a plugin its url is not starting from the root.
It is accessible for example through "plugins/myplugin/**"

But, in your case your are doing a service. A service it handler by a page. 2 options :
* cachable services, redirect to another url
* non-cachable service can post parameters to itself. And that is your case.

So, when the page is created with a given service it will always call the url of the service in your plugin : you cannot change "service/search/concordance.html".


Raphael Franchet
Expert Ametys

Offline

Board footer

Powered by FluxBB