Example #1
0
 public void attachFile(String space, String page, String name, File file, boolean failIfExists)
     throws Exception {
   InputStream is = new FileInputStream(file);
   try {
     attachFile(space, page, name, is, failIfExists);
   } finally {
     is.close();
   }
 }
Example #2
0
  // FIXME: improve that with a REST API to directly import a XAR
  public void importXar(File file) throws Exception {
    // attach file
    attachFile("XWiki", "Import", file.getName(), file, false);

    // import file
    executeGet(
        BASE_BIN_URL
            + "import/XWiki/Import?historyStrategy=add&importAsBackup=true&ajax&action=import&name="
            + escapeURL(file.getName()),
        Status.OK.getStatusCode());
  }
Example #3
0
 /** @since 5.1M2 */
 public void attachFile(
     String space,
     String page,
     String name,
     InputStream is,
     boolean failIfExists,
     UsernamePasswordCredentials credentials)
     throws Exception {
   if (credentials != null) {
     this.adminHTTPClient.getState().setCredentials(AuthScope.ANY, credentials);
   }
   attachFile(space, page, name, is, failIfExists);
 }
Example #4
0
 /** @since 5.1M2 */
 public ViewPage createPageWithAttachment(
     String space,
     String page,
     String content,
     String title,
     String attachmentName,
     InputStream attachmentData,
     UsernamePasswordCredentials credentials)
     throws Exception {
   ViewPage vp = createPage(space, page, content, title);
   attachFile(space, page, attachmentName, attachmentData, false, credentials);
   return vp;
 }