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:-
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
Solved! Go to Solution.
Views
Replies
Total Likes
Your bunlde seems fine (nice application logic too). The issue you have is your bundle is referencing a lib that is not part of CQ -- as shown here in the CQ dependency finder:
[img]AbundleNov.png[/img]
(see: http://localhost:4502/system/console/depfinder)
What you have to do is get a JAR file that contains this Java package. Then you have to create an OSGi bunlde fragment that contains this JAR file and deploy it to CQ. You can see an example of creating an OSGi bundle fragment that contains a JSON lib in this article:
http://scottsdigitalcommunity.blogspot.ca/2013/06/posting-form-data-to-adobe-cq-using.html
You are looking for this section:
To create an OSGi bundle fragment, perform these tasks:
1. Start Eclipse (Indigo). The steps below have been tested on Eclipse Java EE IDE for Web Developers version Indigo Service Release 1.
2. Select File, New, Other.
3. Under the Plug-in Development folder, choose Plug-in from Existing JAR Archives. Name your project jsonBundle.
4. In the JAR selection dialog, click the Add external button, and browse to the <YOUR JAR FILE>.
5. Click Next.
6. In the Plug-in Project properties dialog, ensure that you check the checkbox for Analyze library contents and add dependencies.
7. Make sure that the Target Platform is the standard OSGi framework.
8. Ensure the checkboxes for Unzip the JAR archives into the project and Update references to the JAR files are both checked.
9. Click Next, and then Finish.
10. Click the Runtime tab.
11. Make sure that the Exported Packages list is populated.
12. Make sure these packages have been added under the Export-Package header in MANIFEST.MF. Remove the version information in the MANIFEST.MF file. Version numbers can cause conflicts when you upload the OSGi bundle to Adobe CQ.
13. Also make sure that the Import-Package header in MANIFEST.MF is also populated, as shown here (this is an example - also remove all version information in the Export-Package and Import-Package sections).
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: JsonObject
Bundle-SymbolicName: jsonObject
Bundle-Version: 1.0.0
Export-Package: org.json.simple,
org.json.simple.parser
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
14. Save the project.
15. Build the OSGi bundle by right-clicking the project in the left pane, choose Export, Plug-in Development, Deployable plug-ins and fragments, and click Next.
16. Select a location for the export (C:\TEMP) and click Finish. (Ignore any error messages).
17. In C:\TEMP\plugins, you should now find the OSGi bundle.
18. Login to Adobe CQ’s Apache Felix Web Console at http://server:port/system/console/bundles (default admin user = admin with password= admin).
19. Sort the bundle list by Id and note the Id of the last bundle.
20. Click the Install/Update button.
21. Check the Start Bundle checkbox.
22. Browse to the bundle JAR file you just built. (C:\TEMP\plugins).
23. Click Install.
24. Click the Refresh Packages button.
25. Check the bundle with the highest Id.
26. Your new bundle should now be listed with the status Active.
**************************************************************************************************************
Once you do this -- you will be able to start your bundle.
Hope this helps...
Views
Replies
Total Likes
Your bunlde seems fine (nice application logic too). The issue you have is your bundle is referencing a lib that is not part of CQ -- as shown here in the CQ dependency finder:
[img]AbundleNov.png[/img]
(see: http://localhost:4502/system/console/depfinder)
What you have to do is get a JAR file that contains this Java package. Then you have to create an OSGi bunlde fragment that contains this JAR file and deploy it to CQ. You can see an example of creating an OSGi bundle fragment that contains a JSON lib in this article:
http://scottsdigitalcommunity.blogspot.ca/2013/06/posting-form-data-to-adobe-cq-using.html
You are looking for this section:
To create an OSGi bundle fragment, perform these tasks:
1. Start Eclipse (Indigo). The steps below have been tested on Eclipse Java EE IDE for Web Developers version Indigo Service Release 1.
2. Select File, New, Other.
3. Under the Plug-in Development folder, choose Plug-in from Existing JAR Archives. Name your project jsonBundle.
4. In the JAR selection dialog, click the Add external button, and browse to the <YOUR JAR FILE>.
5. Click Next.
6. In the Plug-in Project properties dialog, ensure that you check the checkbox for Analyze library contents and add dependencies.
7. Make sure that the Target Platform is the standard OSGi framework.
8. Ensure the checkboxes for Unzip the JAR archives into the project and Update references to the JAR files are both checked.
9. Click Next, and then Finish.
10. Click the Runtime tab.
11. Make sure that the Exported Packages list is populated.
12. Make sure these packages have been added under the Export-Package header in MANIFEST.MF. Remove the version information in the MANIFEST.MF file. Version numbers can cause conflicts when you upload the OSGi bundle to Adobe CQ.
13. Also make sure that the Import-Package header in MANIFEST.MF is also populated, as shown here (this is an example - also remove all version information in the Export-Package and Import-Package sections).
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: JsonObject
Bundle-SymbolicName: jsonObject
Bundle-Version: 1.0.0
Export-Package: org.json.simple,
org.json.simple.parser
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
14. Save the project.
15. Build the OSGi bundle by right-clicking the project in the left pane, choose Export, Plug-in Development, Deployable plug-ins and fragments, and click Next.
16. Select a location for the export (C:\TEMP) and click Finish. (Ignore any error messages).
17. In C:\TEMP\plugins, you should now find the OSGi bundle.
18. Login to Adobe CQ’s Apache Felix Web Console at http://server:port/system/console/bundles (default admin user = admin with password= admin).
19. Sort the bundle list by Id and note the Id of the last bundle.
20. Click the Install/Update button.
21. Check the Start Bundle checkbox.
22. Browse to the bundle JAR file you just built. (C:\TEMP\plugins).
23. Click Install.
24. Click the Refresh Packages button.
25. Check the bundle with the highest Id.
26. Your new bundle should now be listed with the status Active.
**************************************************************************************************************
Once you do this -- you will be able to start your bundle.
Hope this helps...
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies