0

I am trying to render richtext content from WCM using wcm API. I have jsp to do so. It renders properly for all user group except anonymous. When I view rendered content I see broken image inside richtext. When I log in and view the rendered content, image is displayed.

here is my code:

Workspace ws = WCM_API.getRepository().getSystemWorkspace();
ws.login();
DocumentLibrary lib = ws.getDocumentLibrary("Portal Site");
String s1 = "";
String s2 = "";


if (lib!=null) {
    DocumentIdIterator<Document> it = ws.findByName(DocumentTypes.Content,"kino");

    if (it.hasNext()) {
        DocumentId<Document> docid = it.next();

        Content doc = (Content) ws.getById(docid);
        s1 = "Title: " + doc.getTitle() + "\n";

        RichTextComponent c = (RichTextComponent) doc.getComponent("Body");

        s2 = "Text: " + c.getRichText();
    }
} 
out.println(s1);
out.println(s2);

s2 is outputs richtext with image for authorized users. When I logout and view s2 output: text is displayed but image is broken

ᄂ ᄀ
  • 5,669
  • 6
  • 43
  • 57
Gabit Kemelov
  • 106
  • 1
  • 8

2 Answers2

0

Please make sure that you have anonymous access granted to all your RichText component and parent site areas at user level. And add this call on workspace object

workspace.useUserAccess(true);
Georgy Gobozov
  • 13,633
  • 8
  • 72
  • 78
0

Solution has nothing to do with access level in my case! I checked url of the content and in both cases it consisted /myconnect word (example: http:ip_address:port/wps/wcm/myconnect/...) I found out that myconnect is for authorized user and connect is for anon users. (example: http:ip_address:port/wps/wcm/connect/...) Just by replacing myconnect with connect in the url to the wcm content I managed to solve the problem:

Gabit Kemelov
  • 106
  • 1
  • 8