Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many exceptions occur in SSRF.fromXml() #20

Open
hosokawatakeshi opened this issue Sep 27, 2021 · 1 comment
Open

Many exceptions occur in SSRF.fromXml() #20

hosokawatakeshi opened this issue Sep 27, 2021 · 1 comment

Comments

@hosokawatakeshi
Copy link

I'm evaluating the openssrf.
My code is below.

public class Test extends HttpServlet {
    private static final long serialVersionUID = 1L;
 
    public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
    PrintWriter out;
    SSRF ssrf = new SSRF()
      .withProperty("cls", "UNCLASSIFIED")
      .withContact(new Contact()
      .withEMail(new EMail()
      .withAddress("[email protected]"))
      .withLastName("Doe")
      .withFirstName("John")
      .withTelephoneFax(new TelephoneFax()
      .withNumber("(123)456.7890")));
    res.setContentType("text/html; charset=utf-8");
    out = res.getWriter();
    out.println("<html><body>");
    String xml;
    try {
      xml = ssrf.toXML();
      System.out.println(xml);
      SSRF ssrf2 = SSRF.fromXml(xml);
    } catch (Exception e) {
      e.printStackTrace();
    }
    out.println("</body></html>");
  }
}

The results are as follows.
toXML() is good, but fromXml is bad.
How should I resolve the following exception?

[apache-tomcat-8.5.71-2]: <?xml version="1.0" encoding="UTF-8"?>
<s:SSRF xmlns:s="urn:us:gov:dod:standard:ssrf:3.1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <s:Contact cls="U">
      <s:Serial cls="U">USA::CN:9af76d4e9d2449</s:Serial>
      <s:EntryDateTime cls="U">2021-09-27T01:23:34.020Z</s:EntryDateTime>
      <s:FirstName cls="U">John</s:FirstName>
      <s:LastName cls="U">Doe</s:LastName>
      <s:TelephoneFax>
         <s:Number cls="U">(123)456.7890</s:Number>
      </s:TelephoneFax>
      <s:EMail>
         <s:Address cls="U">[email protected]</s:Address>
      </s:EMail>
   </s:Contact>
</s:SSRF>

[apache-tomcat-8.5.71-2]: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 132 counts of IllegalAnnotationExceptions
@XmlValue is not allowed on a class that derives another class.
	this problem is related to the following location:
		at protected java.util.Calendar us.gov.dod.standard.ssrf._3_1.metadata.domains.D.value
		at us.gov.dod.standard.ssrf._3_1.metadata.domains.D
		at private us.gov.dod.standard.ssrf._3_1.metadata.domains.D us.gov.dod.standard.ssrf._3_1.Contact.effectiveDate
		at us.gov.dod.standard.ssrf._3_1.Contact
		at protected java.util.Set us.gov.dod.standard.ssrf._3_1.SchemaRoot.contact
		at us.gov.dod.standard.ssrf._3_1.SchemaRoot
		at us.gov.dod.standard.ssrf.SSRF
@XmlValue is not allowed on a class that derives another class.
	this problem is related to the following location:
		at protected java.lang.String us.gov.dod.standard.ssrf._3_1.metadata.domains.S10.value
		at us.gov.dod.standard.ssrf._3_1.metadata.domains.S10
		at private us.gov.dod.standard.ssrf._3_1.metadata.domains.S10 us.gov.dod.standard.ssrf._3_1.Contact.titleRank
		at us.gov.dod.standard.ssrf._3_1.Contact
		at protected java.util.Set us.gov.dod.standard.ssrf._3_1.SchemaRoot.contact
		at us.gov.dod.standard.ssrf._3_1.SchemaRoot
		at us.gov.dod.standard.ssrf.SSRF
...
@hosokawatakeshi
Copy link
Author

I was able to fix it with the following code.
Please could you confirm?

diff --git a/src/main/java/us/gov/dod/standard/ssrf/_3_1/metadata/AMetadata.java b/src/main/java/us/gov/dod/standard/ssrf/_3_1/metadata/AMetadata.java
index c0e7dfe..e98a96f 100644
--- a/src/main/java/us/gov/dod/standard/ssrf/_3_1/metadata/AMetadata.java
+++ b/src/main/java/us/gov/dod/standard/ssrf/_3_1/metadata/AMetadata.java
@@ -65,6 +65,7 @@ import us.gov.dod.standard.ssrf._3_1.metadata.lists.ListCCL;
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "AMetadata", propOrder = {"cls"})
 @SuppressWarnings("unchecked")
[email protected]
 public abstract class AMetadata<T> {
 
   /**

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant