cancel
Showing results for 
Search instead for 
Did you mean: 

HTTPConfigSource??

soeursourire
Champ in-the-making
Champ in-the-making
Hi!

I am trying to read a XML file that is stored in Company_Home by its http url however I have this error :

caused by:
org.alfresco.config.ConfigException: Failed to parse config stream

caused by:
org.dom4j.DocumentException: Error on line 31 of document : Open quote is expected for attribute "width" associated with an element type "table". Nested exception: Open quote is expected for attribute "width" associated with an element type "table".


I get this error when I am doing this:
XMLConfigService svc = new XMLConfigService(new HTTPConfigSource(http://localhost:8080/alfresco/download/direct/workspace/SpacesStore/4cc5bdbc-c323-11da-9641-7f540d7...));
svc.init();


Although I do not have error while doing this with the same xml file:

XMLConfigService svc = new XMLConfigService(new FileConfigSource("./src/projects/web-client/source/web/WEB-INF/EF_Config_Pages.xml"));
svc.init();       


Cannot I use XMLConfigService with a url? What do I do wrong here?
Thanks
34 REPLIES 34

soeursourire
Champ in-the-making
Champ in-the-making
I countourned this problem now by adding my service documentsBeanService in Wizard class instead of ef_PersonProperties. Is the problem due to the fact that I am doing storeEPP = new ef_PersonProperties() ? That is thus not working with Spring?

now I am getting the same error than before even after changing permissions:

org.dom4j.DocumentException: Error on line 31 of document : Open quote is expected for attribute "width" associated with an element type "table". Nested exception: Open quote is expected for attribute "width" associated with an element type "table".

here are the permissions I have on my xml file (I checked in nodeBrowser):

Permissions Inherit: true
Assigned Permission To Authority Access
All                             admin        ALLOWED

And if I am testing the path in a external internet explorer I have again to login to see my xml file. I should not as I have all permissions no? I did my test as admin user…

gavinc
Champ in-the-making
Champ in-the-making
It all looks OK to me, I will attempt to reproduce a similar scenario here to see if I get similar results.

However, we are getting close to our 1.3 release so I can't give any guarantees as to when that will be.

soeursourire
Champ in-the-making
Champ in-the-making
Oki thanks I will see if I find a solution as well and wait for your results.

Could you also just tell me what is the best way to use to parse the xml in order to write in it? XMLConfigSource? ContentService to retrieve a OutputStream?

Thanks.

gavinc
Champ in-the-making
Champ in-the-making
The config service is read-only so you won't be able to update via that.

If your XML file is in the repository then, yes you can use the ContentService to update it.

soeursourire
Champ in-the-making
Champ in-the-making
Thanks for your answer. My XML file will be in alfresco in admin home space. So I will still be able to use the ContentService to update this XML file?

soeursourire
Champ in-the-making
Champ in-the-making
I am confused between SAX, XMLConfigService and ContentService:

- I can overwrite on my xml file contained in admin space with the ContentService:
ContentWriter writer = contentService.getWriter(recordRef, ContentModel.PROP_CONTENT, true);
writer.setMimetype("text/xml");
writer.setEncoding("UTF-8");
String content="blabla";
writer.putContent(content);


- But I would like not to overwrite but write in my xml file at a specific xplace between the tags <function> </function> contained in the tags <specialFields></specialFields> So for this I was thinking of using SAX:

SAXReader xmlReader = new SAXReader();
File xmlFile = new File(url);
Document doc = xmlReader.read(xmlFile);
Element root = doc.getRootElement();
SAXReader xmlReader = new SAXReader();
File xmlFile = new File(url);
Document doc = xmlReader.read(xmlFile);
Element root = doc.getRootElement();


But then should I write inside using ContentWriter or SAXWriter? How will I tell my parser where to write?

Thanks in advance

soeursourire
Champ in-the-making
Champ in-the-making
I am writing here the last test I did in case that could help you to find my error when you will have time to check:

//I GET THE NODEREF ON MY XML FILE
NodeRef recordRef = getRecordNodeRef(recordId);

//I GET THE URL: PATH+ID+/+TITLE OF THE FILE
MapNode recordNode = new MapNode(recordRef);
Map<String, Object> recordProps = recordNode.getProperties();
String title = recordProps.get("{http://www.alfresco.org/model/content/1.0}title").toString();
String url = "http://localhost:8080/alfresco/download/direct/workspace/SpacesStore/" + recordId +"/" + title;
logger.info("url= " + url);

//I GIVE ACCESS TO THE CONNECTED USER         String username = this.authenticationService.getCurrentUserName();
permissionService.setPermission(recordRef,username,PermissionService.ALL_PERMISSIONS, true);
        
SAXReader xmlReader = new SAXReader();
File xmlFile = new File(url);
Document doc = xmlReader.read(url);//xmlFile);
Element root = doc.getRootElement();
String rootValue = root.attributeValue("alfresco-config");
logger.info("" + rootValue);

And I get this error:
org.dom4j.DocumentException: Error on line 31 of document http://localhost:8080/alfresco/faces/jsp/EthicFlow_login.jsp : Open quote is expected for attribute "width" associated with an  element type  "table". Nested exception: Open quote is expected for attribute "width" associated with an  element type  "table".
at org.dom4j.io.SAXReader.read(SAXReader.java:482)

And while putting the url in a new internet page I have again to login.
Do you think I have again a permission problem?
thanks

soeursourire
Champ in-the-making
Champ in-the-making
Even with permissionService.ALL_AUTHORITIES instead of username that does not work. And even with ?guest=true at the end of the url I need to login to access the file…

http://localhost:8080/alfresco/download/direct/workspace/SpacesStore/b06d12c3-c48a-11da-87e8-3be91c4...

kevinr
Star Contributor
Star Contributor
If the login page appears even though "guest=true" is used, then that object is not accessable by the Guest user. Invite the guest user to the parent space or directly using the Manage Content Users.

Thanks,

Kevin

soeursourire
Champ in-the-making
Champ in-the-making
Thanks a lot for your answer. However if I am doing that, everybody will be able to see these files from admin contents space and it is not what I want: I would like to access these files in order to modify them without the connected user can see them… It is just in my program that I need to modify these files when the user does an action but the user should not see them… So I guess I have no other solutions than using ContentReader and ContentWriter and I will have to manipulate String (the content of the file) instead of XMLConfigService (I will not be able to use XML parser tools then)?
Thanks again
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.