org.jdom2.input.JDOMParseException Java Examples

The following examples show how to use org.jdom2.input.JDOMParseException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: YWorklistGUI.java    From yawl with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void reportGeneralProblem(Exception e) {
    String message;
    if (e instanceof IOException || e instanceof JDOMParseException) {
        message = "There was a problem parsing your input data.  \n" +
                "Perhaps check that the XML is well formed.";
    } else if (e instanceof YQueryException) {
        message = e.getMessage();
    } else {
        message = e.getMessage();
    }
    e.printStackTrace();
    JOptionPane.showMessageDialog(
            this,
            message,
            "Problem with data input",
            JOptionPane.ERROR_MESSAGE);
}
 
Example #2
Source File: ApiXmlLoginResult.java    From wpcleaner with Apache License 2.0 6 votes vote down vote up
/**
 * Execute login request.
 * 
 * @param properties Properties defining request.
 * @return Login result.
 * @throws APIException Exception thrown by the API.
 */
@Override
public LoginResult executeLogin(
    Map<String, String> properties)
        throws APIException {
  try {
    LoginResult result = constructLogin(getRoot(properties, 1));
    if ((result != null) && (result.isTokenNeeded())) {
      properties.put(ApiLoginRequest.PROPERTY_TOKEN, result.getDetails());
      result = constructLogin(getRoot(properties, 1));
    }
    return result;
  } catch (JDOMParseException e) {
    log.error("Exception in MediaWikiAPI.login()", e);
    throw new APIException("Couldn't login");
  }
}
 
Example #3
Source File: InvalidXMLException.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
public static InvalidXMLException fromJDOM(JDOMParseException e, String documentPath) {
  return new InvalidXMLException(
      e.getMessage(),
      null,
      e.getPartialDocument(),
      documentPath,
      e.getLineNumber(),
      e.getLineNumber(),
      e.getColumnNumber(),
      e);
}
 
Example #4
Source File: MapLogRecord.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public boolean suppressStackTrace() {
    // Don't dump the stack if the root cause is just a parse error
    Throwable thrown = getThrown();
    while(thrown instanceof InvalidXMLException) thrown = thrown.getCause();
    return thrown == null ||
           (thrown instanceof JDOMParseException) ||
           super.suppressStackTrace();
}
 
Example #5
Source File: ApiXmlLogoutResult.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
/**
 * Execute logout request.
 * 
 * @param properties Properties defining request.
 * @throws APIException Exception thrown by the API.
 */
@Override
public void executeLogout(
    Map<String, String> properties)
        throws APIException {
  try {
    getRoot(properties, 1);
  } catch (JDOMParseException e) {
    log.error("Exception in MediaWikiAPI.logout()", e);
    throw new APIException("Couldn't logout");
  }
}
 
Example #6
Source File: ApiXmlDeleteResult.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
/**
 * Execute delete request.
 * 
 * @param properties Properties defining request.
 * @throws APIException Exception thrown by the API.
 */
@Override
public void executeDelete(
    Map<String, String> properties)
        throws APIException {
  try {
    checkForError(getRoot(properties, ApiRequest.MAX_ATTEMPTS));
  } catch (JDOMParseException e) {
    log.error("Error deleting page", e);
    throw new APIException("Error parsing XML", e);
  }
}
 
Example #7
Source File: ApiXmlPurgeResult.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
/**
 * Execute purge request.
 * 
 * @param properties Properties defining request.
 * @throws APIException Exception thrown by the API.
 */
@Override
public void executePurge(
    Map<String, String> properties)
        throws APIException {
  try {
    checkForError(getRoot(properties, ApiRequest.MAX_ATTEMPTS));
  } catch (JDOMParseException e) {
    log.error("Error purging page cache", e);
    throw new APIException("Error parsing XML", e);
  }
}
 
Example #8
Source File: MediaWikiAPI.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
/**
 * @param wikipedia Wikipedia.
 * @param pages List of pages.
 * @throws APIException Exception thrown by the API.
 */
public void retrieveContentsWithoutRedirects(EnumWikipedia wikipedia, List<Page> pages)
    throws APIException {
  Map<String, String> properties = getProperties(ApiRequest.ACTION_QUERY, true);
  properties.put("prop", "revisions");
  properties.put("continue", "");
  properties.put("rvprop", "content");
  properties.put("rvslots", "main");
  StringBuilder titles = new StringBuilder();
  for (int i = 0; i < pages.size();) {
    titles.setLength(0);
    for (int j = 0; (j < MAX_PAGES_PER_QUERY) && (i < pages.size()); i++, j++) {
      Page p = pages.get(i);
      if (j > 0) {
        titles.append("|");
      }
      titles.append(p.getTitle());
    }
    properties.put("titles", titles.toString());
    try {
      constructContents(
          pages,
          getRoot(wikipedia, properties, ApiRequest.MAX_ATTEMPTS),
          "/api/query/pages/page");
    } catch (JDOMParseException e) {
      log.error("Error retrieving redirects", e);
      throw new APIException("Error parsing XML", e);
    }
  }
}
 
Example #9
Source File: MediaWikiAPI.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize the information concerning redirects.
 * 
 * @param wiki Wiki.
 * @param pages List of pages.
 * @throws APIException Exception thrown by the API.
 */
@Override
public void initializeRedirect(
    EnumWikipedia wiki, List<Page> pages) throws APIException {
  if ((pages == null) || (pages.isEmpty())) {
    return;
  }
  Map<String, String> properties = getProperties(ApiRequest.ACTION_QUERY, true);
  properties.put("redirects", "");
  StringBuilder titles = new StringBuilder();
  for (int i = 0; i < pages.size();) {
    titles.setLength(0);
    for (int j = 0; (j < MAX_PAGES_PER_QUERY) && (i < pages.size()); i++, j++) {
      Page p = pages.get(i);
      if (j > 0) {
        titles.append("|");
      }
      titles.append(p.getTitle());
    }
    properties.put("titles", titles.toString());
    try {
      updateRedirectStatus(
          wiki, pages,
          getRoot(wiki, properties, ApiRequest.MAX_ATTEMPTS));
    } catch (JDOMParseException e) {
      log.error("Error retrieving redirects", e);
      throw new APIException("Error parsing XML", e);
    }
  }
}
 
Example #10
Source File: MagicalGoConfigXmlWriterTest.java    From gocd with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldNotAllowEmptyAuthInApproval() throws Exception {
    CruiseConfig cruiseConfig = ConfigMigrator.load(ConfigFileFixture.ONE_PIPELINE);
    StageConfig stageConfig = com.thoughtworks.go.helper.StageConfigMother.custom("newStage", new AuthConfig());
    cruiseConfig.pipelineConfigByName(new CaseInsensitiveString("pipeline1")).add(stageConfig);

    try {
        xmlWriter.write(cruiseConfig, output, false);
        assertThat("Should not allow approval with empty auth", output.toString().contains("<auth"), is(false));
    } catch (JDOMParseException expected) {
        assertThat(expected.getMessage(), containsString("The content of element 'auth' is not complete"));
    }
}
 
Example #11
Source File: XmlUtilsTest.java    From gocd with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldThrowExceptionWhenXmlIsMalformed() throws Exception {
    expectedException.expect(JDOMParseException.class);
    expectedException.expectMessage(containsString("Error on line 1: XML document structures must start and end within the same entity"));

    String xmlContent = "<foo name='invalid'";
    buildXmlDocument(xmlContent, GoConfigSchema.getCurrentSchema());
}
 
Example #12
Source File: InvalidXMLException.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
public static InvalidXMLException fromJDOM(JDOMParseException e, String documentPath) {
    return new InvalidXMLException(e.getMessage(), null, e.getPartialDocument(), documentPath, e.getLineNumber(), e.getLineNumber(), e.getColumnNumber(), e);
}
 
Example #13
Source File: XmlUtilsTest.java    From gocd with Apache License 2.0 4 votes vote down vote up
private void expectDOCTYPEDisallowedException() {
    expectedException.expect(JDOMParseException.class);
    expectedException.expectMessage(containsString("DOCTYPE is disallowed when the feature \"http://apache.org/xml/features/disallow-doctype-decl\" set to true"));
}
 
Example #14
Source File: ParsingFeedException.java    From rome with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the line number of the end of the text where the parse error occurred.
 * <p>
 * The first line in the document is line 1.
 * </p>
 *
 * @return an integer representing the line number, or -1 if the information is not available.
 */
public int getLineNumber() {
    if (getCause() instanceof JDOMParseException) {
        return ((JDOMParseException) getCause()).getLineNumber();
    } else {
        return -1;
    }
}
 
Example #15
Source File: ParsingFeedException.java    From rome with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the column number of the end of the text where the parse error occurred.
 * <p>
 * The first column in a line is position 1.
 * </p>
 *
 * @return an integer representing the column number, or -1 if the information is not available.
 */
public int getColumnNumber() {
    if (getCause() instanceof JDOMParseException) {
        return ((JDOMParseException) getCause()).getColumnNumber();
    } else {
        return -1;
    }
}