What is the best practise to provide a text file for a Java class in a OSGi bundle in CQ?

This is probably a very basic question so please bear with me.
What is the best way to provide a .txt file to be read by a Java class in a OSGi bundle in CQ 5.5?
I have been able to read a file called "test.txt" that I put in a structure like this /src/resources/<any-sub-folder>/test.txt  from my java class  at /src/main/java/com/test/mytest/Test.java using the bundle's getResource and getEntry calls but I was not able to use the context.getDataFile. How is this getDataFile method call to be used?
And what if I want to read the file located in another bundle, is it possible? or can I add the file to some repository and then access it - but I am not clear how to do this.
And I would also like to know what is the best practise if I need to provide a large  data set in a flat file to be read by a Java class in CQ5.
Please provide detailed steps or point me to a how to guide or other helpful resources as I am a novice.
Thank you in advance for your time and help.
VS

As you can read in the OSGi Core specification (section 4.5.2), the getDataFile() method is to read/write a file in the bundle's private persistent area. It cannot be used to read files contained in the bundle. The issue Sham mentions refers to a version of Felix which is not used in CQ.
The methods you mentioned (getResource and getEntry) are appropriate for reading files contained in a bundle.
Reading a file from the repository is done using the JCR API. You can see a blueprint for how to do this by looking at the readFile method in http://svn.apache.org/repos/asf/jackrabbit/tags/2.4.0/jackrabbit-jcr-commons/src/main/java /org/apache/jackrabbit/commons/JcrUtils.java. Unfortunately, this method is not currently usable as it was declared incorrectly (should be a static method, but is an instance method).
Regards,
Justin

Similar Messages

  • What is the best way of creating admin-only parameters for a java iView?

    Hi,
    I would appreciate some advice from more experienced developers...
    The scenario is as follows: I have created an Org Chart maintenance application that generates and renders xml&xsl-based Org Charts. This is the maintenance iView.
    I am creating a second iView that points to each org chart(the 'Viewer' iView). This iView will be re-used many times, for different parts of our organisation. My problem is I want the portal administrator to be able to set the specific Org Chart that each instance of the 'viewer' iView points to. This needs to be editable as a configurable property.
    I imagine that this is accomplished through the use of properties, what is the best way to accomplish this?
    Many thanks,
    Mark Hockings

    I believe that you should be able to specify the 'personalization' property to be no-dialog. This doesn't allow users to be able to change the property, but can be changed when creating the iView definition
    I hope this helps
    D

  • What is the best practise for setting dirty flag of a page/view?

    For a page/view, normaylly there are 2 things to do for diry data:
    1. when it's clean, Save button is disabled, when it's dirty, save button is enabled.
    2. when it's dirty and the window is closed, a popup says "you have unsaved data, close will lose the data".
    My thought is: it must be handled at client side, because not all valuechange is auto submitted. E.g., you type the 1st letter of a string in a input box, the server side does not know it, but save button should be enabled immediately.
    Is it possible to capture all valueChange events in a page or a view at client side?
    I'm not sure what is the best practise for setting dirty flag? If there is better solution? Does ADF provide facility for this?

    public void save(ActionEvent event){
    boolean formValid = isFormValid();
       if (formValid) {
      save button is enabled.
        private boolean isFormValid() {
            boolean valid = true;
            if (Check Condition 1) {
                valid = false;
               showErrorMessage1();
            if (Check Condition 2) {
                valid = false;
               showErrorMessage1();
            return valid;
        private void showErrorMessage1() {
                    when it's dirty and the window is closed, a popup says "you have unsaved data, close will lose the data".

  • What is the best free email provider for a small business? E.g gmail or iCloud etc

    What is the best free email provider for a small business? E.g gmail or iCloud etc

    svdmmanta wrote:
    Is there a free anti-virus download for Macs? Do they do the job or do I have to spend money on something better?
    In General 3rd Party AV Software and Cleaning Utilities tend to cause More Issues than they claim to fix...
    They Not Required...
    Mac OS X tends to look after itself.
    See  >  Mac OS X Built in Security  >  http://www.apple.com/osx/what-is/security.html
    More Info Here  >   https://discussions.apple.com/thread/4545776?tstart=0
    And Here  >  Antivirus Discussion
    The Safe Mac  >  http://www.thesafemac.com/mmg/

  • Need input on creating archive pool in IXos. What is the best practise ..

    In my company we are using ixos as archiving content server. I will like to know what is the standard /general configuration which is used while creating Archive POOL in ixos. What is the Best practice
    DO we create one archive for each type of document we want to archive Like for FI doc we create one FI pool, for HR we create another pool and so on. How do we handle object which contains logs  like "BC_DBLOGS" . Do we create one archive to store all type of logs.
    Or we just create one or two pool and store every type of document in there ?..
    So i would like to get some feedback , idea what people are doing in there companies to archive different type of data and what the best practice .

    I think the best way known so far for transporting Roles is through PFCG by using Customizing request.
    I dont think there is any program or smthing for roles transport.
    Last question is the transport policy different between Role menu transport and Rôle on Data transport
    I am not sure what do u mean by Role on data transport.
    Rgds
    Priyanka

  • What is the best way to keep my personal files stored in iCloud separate from my work-related files?

    What is the best way to keep my personal files stored in iCloud separate from my work-related files? It seems that I'm not allowed to link my iPad mini and my work iMac using two different accounts, so I'm wondering how to make my single personal account work for both, while keeping personal vs work files reasonably separated.
    Thanks for any suggestions.

    Is it possible for you to upgrade your account to iCloud Drive? That would mean, all Macs upgraded to Yosemite, and all mobile devices to iOS8?
    See:  iCloud Drive FAQ and iCloud: About using iWork for iOS and iCloud
    In iCloud Drive you could create two separate custom folders, one for work documents and one for private documents and organize your documents there.  Don't use the app specific folders (Keynote, Pages, Numbers, ...) , because you can only create one level of folders inside these folders.

  • What's the best way to detect that text fits into ContainerControllers without scrolling?

    Hi.
    Question
    What's the best way to detect that text typed by user (or added programmatically) exceeds available container space and find out where starts truncated part? Is there available some other (than described bellow) easy way to detect it or disallow set of controllers to receive more characters that can be displayed in given composition area?
    My partialy failed attempt (simplified)
    For example lets say that I've got an editable textflow with attached two instances of ContainerController.
    var flow:TextFlow = createSomeFlowFromGivenString(sampleText),
        firstController = new ContainerController(firstSprite, 100, 30),
        lastController = new ContainerController(secondSprite, 600, 30);
    flow.interactionManager = new EditManager(new UndoManager());
    flow.flowComposer.addController(firstController);
    flow.flowComposer.addController(lastController);
    flow.flowComposer.updateAllControllers();
    With enabled vertical scroll policy I can compare height of the composition in last controller with height of the content:
    var bounds:Rectangle = lastController.getContentBounds(),
        overflow:Boolean =  lastController.compositionHeight < bounds.height;
    trace('Content does not fit into given area?', overflow)
    But when I switch vertical scroll policy off (lastController.verticalScrollPolicy = ScrollPolicy.OFF) - unfortunately this no longer works...(In my case scrolling should be dissabled, since text areas might have only one line with restricted width)
    Use case
    I want to create fillable form. Field might have a single or multiple lines. One field might start in the middle of the page, continue in the next line where it spreads through whole page and end in the - quarter of page width long  - third line. Text typed by the user can't exceed given area since it might cover some static text that sits right after/below field.
    Something like ascii image bellow:
    |                <PAGE>                    |
    |                                          |
    |                                          |
    |                                          |
    |               [Field starts here........ | 
    | ........................................ |
    | ........................................ |
    | Ends here..]                             |
    |                                          |
    |                                          |
    | [Another field] xxxx  xxxx xxxxxxxx x xx |
    | xxxxxxxxxxxxxxxxxxx                      |
    |                                          |
    |                              [One more.. |
    | .....]                                   |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    |                                          |
    Info:
    [......]  <-- form fields starts with '[' character, and ends with ']'
    xxx       <-- sample, static text
    | and _   <-- page borders

    I've tried something like that previously, but it didn't work because then I've got vertical scroll policy to set to 'auto'. After changing verticalScrollPolicy to ScrollPolicy.OFF  in the last container it worked like a charm.
    Thanks zhen bian

  • What is the best USB 3.0 (small) ext HDD for recording my music on

    Hello everybody!
    i start with saying...........
    A Happy Newyear!!!!!
    I wish you all the very best and love.
    Now for my question.
    I would like to know what is the best portable usb 3.0 external HDD for recording my music on.
    Because since today i am a very happy new owner of the new Retina Macbook Pro 2.3 GHz, with 8 GB of Ram and 256 GB of Flash.
    .... and yes it has the Samsung Retina Display
    Since 8 years i use Logic Pro and because the flash is only 256 Gb i want to record on a external drive
    and not on the internal storage (and especially now with usb 3.0).
    But i would like to know what is the best portible external HDD for this function.
    500 GB is enough for me because i have 2x a 2 TB for my Mac Pro and Macbook pro where i make back ups from all my music (2 back ups just to be safe).
    Some Examples i saw:
    - WD My passport USB 3.0 - 500 GB harde schijf
    - G-Technology 500GB G-DRIVE Slim USB 3.0-harde schijf
    - LaCie 500GB Rugged Triple USB 3.0 externe harde schijf
    - Freecom Mobile drive mg 500 GB harde schijf
    - Western Digital My Passport Essential SE USB 3.0 500 GB harde schijf
    I would really like some good advise in this.
    Hope you guys can help me out with this.
    Greetings,
    Glenn Cornelisse
    Gaya Productions Studio
    The Hague, Netherlands

    I cannot speak specifically about any of those Ext HDs because i don't own any of them..
    But...
    Make sure the external drive is 7200rpm.... and not 5400rpm or a 'green' drive with something called "varipower' or a similar name...

  • What is the best practice in securing deployed source files

    hi guys,
    Just yesterday, I developed a simple image cropper using ajax
    and flash. After compiling the package, I notice the
    package/installer delivers the same exact source files as in
    developed to the installed folder.
    This doesnt concern me much at first, but coming to think of
    it. This question keeps coming out of my head.
    "What is the best practice in securing deployed source
    files?"
    How do we secure application installed source files from
    being tampered. Especially, when it comes to tampering of the
    source files after it's been installed. E.g. modifying spraydata.js
    files for example can be done easily with an editor.

    Hi,
    You could compute a SHA or MD5 hash of your source files on
    first run and save these hashes to EncryptedLocalStore.
    On startup, recompute and verify. (This, of course, fails to
    address when the main app's swf / swc / html itself is
    decompiled)

  • What is the best USB powered portable 1TB hard drive for a macbook pro that allows Time machine to work, windows (thru Parallels software) and mac storage and is available in Australia?

    What is the best USB powered portable 1TB hard drive for a macbook pro that allows Time machine to work, windows (thru Parallels software) and mac storage and is available in Australia?

    I agree with teh OWC sggestion above, but why must it be USB powered? I find that far more unreliable, and the low power devices slow.
    I'd frankly get a good external enclosure and buy a bare drive.  But the OWC stuff is quite good - vastly better than some of the majors (WD being aprime example of stuff that's boderline quality and often not compatible)
    Grant

  • What is the best edge to edge glass screen protector for iPhone 6

    What is the best edge to edge glass screen protector for iPhone 6

    none of the ones at the link below are glass - they are all film - if you are looking for glass i know of several options
    Zeos - www.zeosdirect.com
    Crown - www.bodyguardz.com
    Moshi - www.moshi.com
    i think Zagg may have one www.zagg.com
    and im sure there are others
    search Amazon for iPhone 6 tempered glass screen protectors

  • What is the best free word processing or office program for OS X Mountain Lion

    What is the best free word processing or office program for OS X Mountain Lion?

    "Best" is quite subjective. As William points out, TextEdit may be the "best" in someones eyes as it isn't cludged up with crap you don't need.
    What are your requirements?
    Basic text editing?
    Do you need:
    Table of Contents
    Index
    Footnote/endnote management
    Different headers/footers
    Page Layout
    What are you going to use it for?
    Technical Reports
    Screenplay
    Leaflets and newsletters
    Coding

  • What is the best video editing software i can get for a macbook pro without slowing my computer way down

    What is the best video editing software i can get for a macbook pro without slowing my computer way down. I need it to be able to take hd videos. With the camera i got i can't even upload my videos to imovie.

      MacBook Pro
    https://discussions.apple.com/community/notebooks/macbook_pro
    https://discussions.apple.com/community/mac_os?view=discussions
    http://www.apple.com/support/macbookpro
    http://www.apple.com/support/
    http://www.apple.com/support/iphoto
    You stumbled on a Mac Tower forum, not notebooks.
    If you are running 10.6.8 then you must have bought it 3-4 yrs ago?
    Might want to check the specs and then look at various programs and their requirements as to whether Final Cut Express and ah, you want to import media to an app, not "upload."
    http://www.apple.com/support/imovie
    http://www.apple.com/support/finalcutexpress
    Checked AppStore, Google or even the forums for various Apple programs.

  • What is the best way to maintain your Battery Life for Iphone 5 ?

    What is the best way to maintain your Battery Life for Iphone 5 ?

    hi,
    so what would you suggest to do here then. let it get to 50% then run the battery down and at say 5-%ish re-charge it fully.
    is there anything i could switch off on my phone to save battery power. ive taken off he location services apart from ym locate my iphone, stopped the fetch new data and set it to manaul . this is also the same for the icloud as well.more or less everything has been set to manual or set to off ??

  • What's the best way to charge my iphone 6 for the first time ?

    what's the best way to charge my iphone 6 for the first time ?

    Just charge it to 100%.
    Use it on the charger when possible. Recharge when the battery is around 50% when possible. Avoid to let the battery go down below 20%.
    Read here about modern Li batteries
    http://batteryuniversity.com
    Lex

Maybe you are looking for

  • How to make something like this in Edge Animate?

    Hi, I'm hoping to make something like this – https://www.youtube.com/watch?v=OJeDppEHI1g – in Edge Animate but I'm not sure where to start. I'm new to Edge but am keen to explore. Anyone have any feedback on whether: 1. It's possible, and 2. What tec

  • Chart item - overall result

    Hello, I'm working with the BEx Web Application Designer BI AddOn /.X (based on 6.40) and I want to display the result of query in a chart item. The problem hereby is that i also want to display the overall result! How can I do this? Thanks, Margit

  • 5320 XM Radio issue

    Hi! I recently noticed that when playing radio on my 5320, the sound stops for a second or so. This happens once a minute or even more often and is very annoying. Before updating the software to version 04.13  I had'nt had this problem. Any ideas, pl

  • MD player for Mac - to use with  Garageband

    Hi, could someone suggest a good MD player that is compatible with Mac. I´ve heard that the Sony MZ-RH10 that can transfer data through USB doesn´t work so well. So I´m thinking of buying a cheeper MD player (without the USB transfer possibility) and

  • Spark.core.ContentCache with AIR 3.7 on iOS not working

    I've been trying to migrate a large Flex 4.6 mobile project from AIR 3.5 to AIR 3.7 for several days with no luck. The issue that kills me is Error #3747: Multiple application domains are not supported on this operating system. This happens only on i