2017-05-31 58 views
1

文檔我目前使用深化發展作爲露天GED和春季爲framework.I要顯示在導航文件而不認證requirment.So我該怎麼辦that.By的方式一個Java/JEE應用我在我的項目2個模塊:前臺和後臺,它們通過休息calls.From通信的後端我試圖傳遞對象的字節數組,但不幸的是我收到它作爲字符串,所以我不能用it.So任何建議工作解決這個問題?顯示沒有認證

public Map<String, Object> getCourrierDetails(String idCourrier) throws Exception { 
     Map<String, Object> courriersDetails = runtimeService.getVariables(idCourrier); 
courriersDetails.put("idCourrier", idCourrier); 
     DocumentDaoImpl dao=new DocumentDaoImpl(); 

     Document docCmis = (Document) dao.getDocument("workspace://SpacesStore/73871a36-9a6c-42c6-b3e3-7d68362fe9c0"); 

     byte[] myByteArray = readContent(docCmis.getContentStream().getStream()); 


     ByteArrayResource resource = new ByteArrayResource(myByteArray) { 
      @Override 
      public String getFilename() { 
       return docCmis.getContentStreamFileName(); 
      } 
     }; 
     System.out.println(resource.getFilename()); 
     //courriersDetails.put("resources", myByteArray); 
     System.out.println(courriersDetails.get("resources")+" rrrr"); 
     //courriersDetails.put("contentStream",docCmis.getContentStream().getStream()); 
     return courriersDetails; 
    } 
+0

據我所知你只能顯示PDF文檔,你將使用InputStream –

回答

3

假設您的前端和後端是定製和後端與露天通信,所有你需要做的是編寫駐留在後端的代理。

代理可以露天使用具​​有訪問內容的預先配置的「服務帳戶」建立會話。通過這種方式,使用自定義Web應用程序不使用自己的憑據的人擺脫露天的對象。而是使用服務帳戶,並且Web應用程序將其傳送給請求者。

例如,在我的項目之一,我有一個使用CMIS擺脫內容的InputStream給予其ID的AssetService:

public InputStream download(String assetId) { 
    CmisObject obj = session.getObject(assetId); 
    Document doc = null; 
    if (obj.getBaseTypeId().equals(BaseTypeId.CMIS_DOCUMENT)) { 
     doc = (Document) obj; 
    } 
    return doc.getContentStream().getStream(); 
} 

然後,我的控制器只要求提供資產獲得一些服務關於它的信息可以很容易設置一些有用的頭,然後將其從資產服務獲取輸入流,並返回:

@RequestMapping(value = "/api/asset/{assetId:.+}/download/{name}", method = RequestMethod.GET) 
public ResponseEntity<InputStreamResource> downloadAsset(
     @PathVariable("assetId") String assetId, 
     @PathVariable("name") String name) { 

    // get the asset so we can get some info about it 
    Asset asset = assetService.getAsset(assetId); 

    // set the http headers (mimetype and length at a minimum) 
    HttpHeaders httpHeaders = new HttpHeaders(); 
    httpHeaders.setContentType(MediaType.parseMediaType(asset.getMimetype())); 
    httpHeaders.setContentLength(asset.getLength()); 

    // get the content stream 
    InputStream inputStream = assetService.download(assetId); 
    InputStreamResource inputStreamResource = new InputStreamResource(inputStream); 

    return new ResponseEntity<InputStreamResource>(inputStreamResource, httpHeaders, HttpStatus.OK); 
} 

本例中使用Spring MVC的一個春天啓動的應用程序中,但當然,你可以這樣做與普通的舊servlet類似如果你想。

+0

當你在戶外創建一個文檔時,有可能在沒有認證的情況下得到它,這是否意味着每個人都可以訪問文檔? ? –

+0

不,這是不可能得到其不進行驗證,除非你做這樣的事情是我的建議上面,基本上把一個代理在露天的前面並獲取代表用戶的文檔。如果一個人能猜出一個節點的參考,他們會能夠得到在「服務帳戶」訪問回購任何文件。 –

+0

謝謝@jeffPotts的回覆和你的時間 –