JCR or Jackrabbit or WEBDAV based update a document or File under the etc/design node in Publish instance using WEBDAV jackrabbit
Hi
I am trying to update the autosuggest_dict.xml (attached) often using CQ5 Jackrabbit api of webdav feature. I could not find any method as get, put, copy and update.
Instead I have getMethod, PutMethod which has only one parameter(). we should have two parameter as (source, target).
The below code is working fine as main method:-
// Slide Simple WebDAV client example --- slide-webdavlib-2.1.jar
import java.io.*;
import java.io.IOException;
import java.net.MalformedURLException;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpURL;
import org.apache.webdav.lib.WebdavResource;
public class SlideTest {
public static void main (String args[])
{
try
{
System.out.println("h");
HttpURL hrl = new HttpURL("http://servername:<port>/etc/designs/awsportal/dictionary/autosuggest_dict.xml");
System.out.println("h1");
hrl.setUserinfo("admin","admin");
WebdavResource wdr = new WebdavResource(hrl);
System.out.println("h2");
File fn = new File("autosuggest_dict.xml");
System.out.println("h3");
if(wdr.getMethod(fn)){
System.out.println("true");
FileWriter fileWriter = new FileWriter(fn.getPath());
BufferedWriter bufferedWriter =
new BufferedWriter(fileWriter);
// Note that write() does not automatically
// append a newline character.
bufferedWriter.write("<autosuggest_dictionary><keyword suggest=\"Business Track\" sitetype=\"fdinternal\"/><keyword suggest=\"My Profile\" sitetype=\"all\"/><keyword suggest=\"Help\" sitetype=\"all\"/></autosuggest_dictionary>");
// Always close files.
bufferedWriter.close();
wdr.putMethod(fn);
}else{
System.out.println("f");
}
wdr.close();
}
catch(MalformedURLException mue)
{
mue.getLocalizedMessage();
}
catch(HttpException he)
{
he.getLocalizedMessage();
}
catch(IOException ioe)
{
ioe.getMessage();
}
}
}
I could not start the bundle in felix console as it is saying, org.apache.webdav.lib.WebdavResource - could not be resolved and the bundle is in installed state (could not Active)
Steps I followed:-
- Converted the above main method as a class, which will be invoked from cq5 client end
- Updated the sufficient dependency tags in pom.xml as below
- Included the jars in .m2 directory
- Build and installed using Maven (success)
- Uploaded in Flex console of (publish installed), could not make the status as "Active) (Error: org.apache.webdav.lib.WebdavResource - could not be resolved).
POM.xml dependency tag for webdavresources
<dependency> <groupId>slide</groupId> <artifactId>slide-webdavlib</artifactId> <version>2.1</version> </dependency>
Attaching the pom.xml as well
But when, build and install using maven (worked fine).
Could not install in felix console
How we can achieve the same using JACk rabbit (JCR) based webdav