[AWPR-4] AWPr is dispalying junk characters(binary data)in aportlet instead of image for alfresco webscript returning binary data Created: 17/Jul/09 Updated: 22/Jul/09 Resolved: 21/Jul/09 |
|
| Status: | Resolved |
| Project: | Alfresco Web script Portlet rivet |
| Component/s: | awpr-liferay-portal |
| Affects Version/s: | 1.3.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major |
| Reporter: | nilendra | Assignee: | Al El-Nattar |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: | Alfresco labs 3.0 Lifreray portal 5.2.3 Star 1.3 | ||
| Attachments: |
|
| Resolution Date: |
| Description |
|
AWPr is dispalying junk characters(binary data)in aportlet instead of image for alfresco webscript returning binary data Scrpit executed is alfresco webscript for Content Retrival(getContent) Content Retrieval (getContent) GET /alfresco/service/api/node/content{property}/{store_type}/{store_id}/{id}?a={attach?} GET /alfresco/service/api/path/content{property}/{store_type}/{store_id}/{id}?a={attach?} GET /alfresco/service/api/avmpath/content{property}/{store_id}/{id}?a={attach?} GET /alfresco/service/api/node/{store_type}/{store_id}/{id}/content{property}?a={attach?} GET /alfresco/service/api/path/{store_type}/{store_id}/{id}/content{property}?a={attach?} Notes: Some CMIS protocol bindings MAY choose not to explicitly implement a "getContentStream" method, in cases where the protocol itself provides built-in mechanisms for retrieving byte streams. (E.g. in the ATOM/REST binding, content streams may be retrieved via standard HTTP gets on an "edit-media" URL, rather than a CMIS-specific "getContentStream" URL). See Part II of the CMIS specification for additional details. when we open bmp and jpeg conent from alfresco it explorer displays image properly but in awpr it displays junk character We tried setting the mime type response on servlet but still we get binary junk charcters since a it is enclosed by div tag |
| Comments |
| Comment by nilendra [ 17/Jul/09 ] |
| I have attached both webscript opened in IE and webscript opened through awpr |
| Comment by Al El-Nattar [ 17/Jul/09 ] |
|
Hi, AWPr 1.3.0 doesn't support resource URLs. Please try to upgrade to the latest AWPr version 1.5.0 and let us know how that goes. Thanks. |
| Comment by nilendra [ 20/Jul/09 ] |
|
Thanks Alaaedin, I still get junk character for Content Retrieval (getContent) GET /alfresco/service/api/node/content{property}/{store_type}/{store_id}/{id}?a={attach?} using AWPr 1.5 I tried modifying doView of JSPPortlet with following COde public void doView(RenderRequest req, RenderResponse res) throws IOException, PortletException { WebscriptPreferences wsprefs = (WebscriptPreferences) req.getPortletSession().getAttribute( Constants.SESSION_ATTRIBUTE_WSPREFS); if (wsprefs == null) { wsprefs = new WebscriptPreferences(); wsprefs.readPortletPreferences(req); req.getPortletSession().setAttribute(Constants.SESSION_ATTRIBUTE_WSPREFS, wsprefs); } if ("".equals(wsprefs.getAlfrescoHost()) || "".equals(wsprefs.getWebscriptUrl()) || wsprefs.getAlfrescoHost() == null || wsprefs.getWebscriptUrl() == null) { include(viewJSP, req, res); } else { // Get Alfresco ticket for the user String alfTicket = getAlfrescoTicket(req, wsprefs); System.out.println("Alfresco Ticket Generated: " + alfTicket); System.out.println("wsPrefs WebScriptURL sent: : " + wsprefs.getWebscriptUrl()); // Execute script byte[] image=executeScript(req, res, wsprefs, alfTicket); //byte[] image=(byte[])req.getAttribute("webscript-content"); HttpServletResponse httpResponse = PortalUtil.getHttpServletResponse(res); httpResponse.setContentType("image/gif"); javax.servlet.ServletOutputStream outputStream = httpResponse.getOutputStream(); outputStream.write(image, 0, (int)image.length); outputStream.flush(); //include(webscriptJSP, req, res); } Even though I set httpResponse contenttype to image/gif I still get Junk characters on portlet. When i did view source I found that the content is wrapped by div tag so I am not able to set the contenttype |
| Comment by Al El-Nattar [ 20/Jul/09 ] |
|
Please attach your webscript code so I can take a look at it. Thanks. |
| Comment by nilendra [ 20/Jul/09 ] |
|
Webscript is alfreco out of box implementation for get contentContent Retrieval (getContent) in alfresco labs 3.0 <webscript> <shortname>Content Retrieval (getContent)</shortname> <description> <![CDATA[ The service returns the content-stream for a document. This is the only service that returns content-stream.<br> <br> Inputs:<br> <br> ID documentId: Document to return the content-stream<br> (Optional) Integer offset:<br> (Optional) Integer length:<br> <br> Outputs:<br> <br> Byte[] stream<br> <br> Notes:<br> <br> Some CMIS protocol bindings MAY choose not to explicitly implement a “getContentStream� method, in cases where the protocol itself provides built-in mechanisms for retrieving byte streams. (E.g. in the ATOM/REST binding, content streams may be retrieved via standard HTTP gets on an “edit-media� URL, rather than a CMIS-specific “getContentStream� URL). See Part II of the CMIS specification for additional details.<br> Each CMIS protocol binding will provide a way for fetching a sub-range within a content stream, in a manner appropriate to that protocol.<br> ]]> </description> <url>/api/node/content{property}/{store_type}/{store_id}/{id}?a={attach?}</url> <url>/api/path/content{property}/{store_type}/{store_id}/{id}?a={attach?}</url> <url>/api/avmpath/content{property}/{store_id}/{id}?a={attach?}</url> <url>/api/node/{store_type}/{store_id}/{id}/content{property}?a={attach?}</url> <url>/api/path/{store_type}/{store_id}/{id}/content{property}?a={attach?}</url> <authentication>guest</authentication> <format default="">argument</format> <family>CMIS</family> <lifecycle>public_api</lifecycle> </webscript> |
| Comment by Al El-Nattar [ 20/Jul/09 ] |
| What I meant to say is how are you calling the content retreival Web script from your code? |
| Comment by nilendra [ 21/Jul/09 ] |
|
I set following link in alfresco preference http://3.209.35.66:8081/alfresco/service/api/node/content/workspace/SpacesStore/1a4d715b-316b-4a92-9b31-8b6163e26742/ORG-CHART.gif I set Alfresco Host: http://3.209.35.66:8081 Alfresco Context Path :/alfresco and Script Url:/api/node/content/workspace/SpacesStore/1a4d715b-316b-4a92-9b31-8b6163e26742/ORG-CHART.gif and then click on save and then return to full page |
| Comment by Al El-Nattar [ 21/Jul/09 ] |
|
I see what the problem is now. This is not a bug. AWPr is not meant to be used this way. Content streaming Web scripts are special since they stream binary content that must be handled differently. For binary content we must use Portlet 2.0 resource URLs and thus to achieve what you want you must do the following: - Create a new Web script in your Alfresco repository and add the following line in your FTL: <img src="${url.serviceContext}/api/node/content/workspace/SpacesStore/1a4d715b-316b-4a92-9b31-8b6163e26742/ORG-CHART.gif/> Note: It would be advisable to generalize the image information (storeType, storeId, Id, FileName) by getting it through Web script arguments that can be passed from AWPr using the "Constant Script Parameters" preference. - Next add a new AWPr portlet to your page and use your new Web script's URL ( you can call it image_viewer or something :) ). That should do it. Hope this helps. |
| Comment by nilendra [ 22/Jul/09 ] |
|
Thanks Now we are able to view images by creating new script |