Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7766363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:23:48+00:00 2026-06-01T15:23:48+00:00

I am trying to get the node ref of file uploaded to default root

  • 0

I am trying to get the node ref of file uploaded to default root directory in my java class.

I tried this link.

But it is returning empty result set. How can I write search query to get the particular file node. Or Is there any way to create node ref from sting in java class.

My code :

NodeRef companyHomeNodeRef = null;
            StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE,
                    "SpacesStore");

            ResultSet rs = searchService.query(storeRef,
                    SearchService.LANGUAGE_LUCENE, "\\\"/app:company_home/app:user_homes/sys:boris/cm:mypics\\");

            try {
                System.out.println("length :" + rs.length());
                if (rs.length() == 0) {
                    // throw new Exception("Didn't find Company Home");
                } else {
                    companyHomeNodeRef = rs.getNodeRef(0);
                }
            } finally {
                rs.close();
            }

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:23:49+00:00Added an answer on June 1, 2026 at 3:23 pm

    I have resolved the issue. Below is code to create node ref of file from node ref string and update the content of file.

               AuthenticationUtil.runAs(new RunAsWork<String>() {
    
                    @Override
                    public String doWork() throws Exception {
    
                        NodeRef nodeRef = new NodeRef("workspace://SpacesStore/f1a5e908-80cb-4c6e-b919-cc80fe53b835");
                        if(contentService != null) {
                            ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
                            if(writer != null) {
                                writer.putContent(new ByteArrayInputStream("updated content".getBytes()));
                            } 
                        } 
                        return null;
                    }
    
                }, AuthenticationUtil.getSystemUserName());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get the root node of a PHP DOM Document. This
I'm trying to get a node-set from a xsl variable for calculating. But my
I'm trying to get a node.js server to send css files. I'm modifying this
I'm trying to get cdata text from a node using dom4j java. My issue
I am trying to get to grips with node.js, this looked like a fun
I am trying to get an attribute value from an XML file, but my
I am trying to get the text content of first node in this XML.
I am trying to get the attribute of a single node in VBA, but
I am trying to get the number of children that a node has but
I am new to hadoop and trying to get a single node setup of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.