src/main/java/com/sourcesense/confluence/cmis/macros/BaseCMISMacro.java
protected String fetchDocumentLink(ConfluenceCMISRepository confluenceCmisRepository, Session session, String documentId, boolean useProxy)
      throws MacroException {
    ObjectServiceImpl objectServices = (ObjectServiceImpl) session.getBinding().getObjectService();
    Class<?>[] parameterTypes = {String.class, String.class, String.class, String.class};
    String res = null;
    try {
      Method loadLink = AbstractAtomPubService.class.getDeclaredMethod("loadLink", parameterTypes);
      loadLink.setAccessible(true);
      res = (String) loadLink.invoke(objectServices, session.getRepositoryInfo().getId(), documentId, Constants.REL_EDITMEDIA, null);
    } catch (Exception e) {
      logger.error(e.getMessage() + "Link retrieval failed");
    }
    if (useProxy && res != null) {
      try {
        res = rewriteUrl(res, confluenceCmisRepository.getServerName());
      } catch (MalformedURLException e) {
        throw new MacroException(e);
      }
    }
    return res;
  }
/**
   * Grabs the link to a cmis:document content stream. Put in a separate method to ease testing.
   *
   * @param confluenceCmisRepository CMIS Repository descriptor
   * @param session                  CMIS Session object already opened with the CMIS Repository
   * @param documentId               ID of the document we want to link to
   * @param useProxy                 Whether communication should be proxied by the CMIS plugin or issued directly to the CMIS provider
   * @return The fetched link
   * @throws MacroException When fetched URL is malformed
   */
Grabs the link to a cmis:document content stream. Put in a separate method to ease testing.
Grabs the link to a cmis : document content stream . Put in a separate method to ease testing .
protected String fetchDocumentLink(ConfluenceCMISRepository confluenceCmisRepository, Session session, String documentId, boolean useProxy)
      throws MacroException {
    ObjectServiceImpl objectServices = (ObjectServiceImpl) session.getBinding().getObjectService();
    Class<?>[] parameterTypes = {String.class, String.class, String.class, String.class};
    String res = null;
    try {
      Method loadLink = AbstractAtomPubService.class.getDeclaredMethod("loadLink", parameterTypes);
      loadLink.setAccessible(true);
      res = (String) loadLink.invoke(objectServices, session.getRepositoryInfo().getId(), documentId, Constants.REL_EDITMEDIA, null);
    } catch (Exception e) {
      logger.error(e.getMessage() + "Link retrieval failed");
    }
    if (useProxy && res != null) {
      try {
        res = rewriteUrl(res, confluenceCmisRepository.getServerName());
      } catch (MalformedURLException e) {
        throw new MacroException(e);
      }
    }
    return res;
  }
protected String fetchDocumentLink ( ConfluenceCMISRepository confluenceCmisRepository , Session session , String documentId , boolean useProxy ) throws MacroException { ObjectServiceImpl objectServices = ( ObjectServiceImpl ) session . getBinding ( ) . getObjectService ( ) ; Class < ? > [ ] parameterTypes = { String . class , String . class , String . class , String . class } ; String res = null ; try { Method loadLink = AbstractAtomPubService . class . getDeclaredMethod ( "loadLink" , parameterTypes ) ; loadLink . setAccessible ( true ) ; res = ( String ) loadLink . invoke ( objectServices , session . getRepositoryInfo ( ) . getId ( ) , documentId , Constants . REL_EDITMEDIA , null ) ; } catch ( Exception e ) { logger . error ( e . getMessage ( ) + "Link retrieval failed" ) ; } if ( useProxy && res != null ) { try { res = rewriteUrl ( res , confluenceCmisRepository . getServerName ( ) ) ; } catch ( MalformedURLException e ) { throw new MacroException ( e ) ; } } return res ; }
Grabs the link to a cmis:document content stream.
Grabs the link to a cmis : document content stream .