code: @Override
      public URI createDocument(URI docRemoteLocation, String fileExtension, String mediaType) throws DocumentException {
  
          log.debug("Creating document from {} - File extension: {}", docRemoteLocation, fileExtension);
          URI newDocUri = this.generateUniqueDocumentUri();
          try {
              URI internalDocUri = this.getDocumentInternalUri(newDocUri);
              File docDir = new File(internalDocUri);
              FileUtil.createDirIfNotExists(docDir);
              File file = new File(new StringBuilder(docDir.getAbsolutePath()).append("/index.").append(fileExtension).toString());
              FileOutputStream out = new FileOutputStream(file);
              FileUtil.createDirIfNotExists(file.getParentFile());
              URLConnection connection = docRemoteLocation.toURL().openConnection();
              connection.addRequestProperty("Accept", mediaType);
              int size = IOUtils.copy(connection.getInputStream(), out);
              log.info("Document internal URI - " + internalDocUri.toASCIIString() + " - " + size + " bytes.");
              storeMediaType(file.getAbsolutePath(), mediaType);
              if (fileExtension.equals("json")) {
                  storeSwaggerApiDeclarations(file, docDir.getAbsolutePath(), docRemoteLocation, mediaType);
              }
          } catch (IOException e) {
              throw new DocumentException("Unable to add document to service.", e);
          }
  
          // Generate Event
          this.getEventBus().post(new DocumentCreatedEvent(new Date(), newDocUri));
  
          return newDocUri;
      }
docs: /* (non-Javadoc)
  @see uk.ac.open.kmi.iserve.sal.manager.DocumentManager#createDocument(java.io.InputStream, java.lang.String )