在WSO2 GREG中使用SchemaFilter的异常

时间:2013-04-24 16:37:20

标签: java xsd wso2 wso2greg

我得到了这个例外

    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisO
peration.java:413) ~[axis2_1.6.1-wso2v7.jar:na]
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(Out
InAxisOperation.java:224) ~[axis2_1.6.1-wso2v7.jar:na]
Caused by: org.apache.axiom.om.OMException: Stream Errorjava.io.IOException: Bad
 chunk size:
    at org.apache.axiom.attachments.Attachments.<init>(Attachments.java:242)
 ~[axiom_1.2.11-wso2v3.jar:na]
    at org.apache.axis2.builder.BuilderUtil.createAttachments(BuilderUtil.ja
va:594) ~[axis2_1.6.1-wso2v7.jar:na]
    at org.apache.axis2.builder.BuilderUtil.createAttachmentsMap(BuilderUtil
.java:545) ~[axis2_1.6.1-wso2v7.jar:na]
    at org.apache.axis2.builder.MIMEBuilder.processDocument(MIMEBuilder.java
:39) ~[axis2_1.6.1-wso2v7.jar:na]
    at org.apache.axis2.transport.TransportUtils.createDocumentElement(Trans
portUtils.java:179) ~[axis2_1.6.1-wso2v7.jar:na]
    at org.apache.axis2.transport.TransportUtils.createSOAPMessage(Transport
Utils.java:145) ~[axis2_1.6.1-wso2v7.jar:na]
Caused by: java.io.IOException: Bad chunk size:
    at org.apache.commons.httpclient.ChunkedInputStream.getChunkSizeFromInpu
tStream(ChunkedInputStream.java:306) ~[commons-httpclient_3.1.0-wso2v2.jar:na]
    at org.apache.commons.httpclient.ChunkedInputStream.nextChunk(ChunkedInp
utStream.java:221) ~[commons-httpclient_3.1.0-wso2v2.jar:na]
    at org.apache.commons.httpclient.ChunkedInputStream.read(ChunkedInputStr
eam.java:146) ~[commons-httpclient_3.1.0-wso2v2.jar:na]
    at java.io.FilterInputStream.read(FilterInputStream.java:83) ~[na:1.7.0_
04]
    at org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInpu
tStream.java:88) ~[commons-httpclient_3.1.0-wso2v2.jar:na]
    at java.io.FilterInputStream.read(FilterInputStream.java:83) ~[na:1.7.0_
04]
org.wso2.carbon.governance.api.exception.GovernanceException: Error in retrievin
g governance artifact by path. path: /trunk/schemas/com/mycorp/xmlns/common/faul
t/v1/common_fault_v1.2.xsd.
    at org.wso2.carbon.governance.api.util.GovernanceUtils.retrieveGovernanc
eArtifactByPath(GovernanceUtils.java:805)
    at org.wso2.carbon.governance.api.schema.SchemaManager.getAllSchemas(Sch
emaManager.java:385)
    at org.wso2.carbon.governance.api.schema.SchemaManager.findSchemas(Schem
aManager.java:351)
    at wso2client.SchemaDAO.getReusableSchemas(SchemaDAO.java:62)

当我在我的班级wso2client.SchemaDAO中运行以下代码时:

public static List<models.domain.Schema> getReusableSchemas() {
    List<models.domain.Schema> domainSchemas = null;
    try {
        registry = Util.initialize();
        governanceRegistry = Util.getGovernanceRegistry(registry);

        // starting with the schema manager created with governanceRegistry
        schemaManager = new SchemaManager(governanceRegistry);

        // get schemas with attribute "creator" == "yyy"
        List<Schema> schemas = Arrays.asList(
            schemaManager.findSchemas(new ReusableSchemaFilter())
        );

        System.out.println("Number of matches:" + schemas.size());
        domainSchemas = DTOMapper.Wso2Schemas2DomainSchemas(schemas);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } 
    return domainSchemas;
}

private static class ReusableSchemaFilter implements SchemaFilter {

    @Override
    public boolean matches(Schema wso2Schema) throws GovernanceException {
        boolean schemaIsReusable = false;
        // in order to read the properties (not attributes!) of the schema I need to retrieve the resource.
        try {
            Resource resource = governanceRegistry.get(wso2Schema.getPath());

            boolean isDeprecated = "Deprecated".equals(wso2Schema.getLifecycleState());
            boolean isCanonical = "canonicalInformation1".equals(resource.getProperty("informationModelRelation"));
            schemaIsReusable = (isCanonical && !isDeprecated);
        } catch (RegistryException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return schemaIsReusable;
    }

}

你看到可能出现什么问题吗?

1 个答案:

答案 0 :(得分:0)

我按如下方式更改了过滤器:

private static class ReusableSchemaFilter implements SchemaFilter {

    @Override
    public boolean matches(Schema wso2Schema) throws GovernanceException {
        boolean schemaIsReusable = false;
        // in order to read the properties (not attributes!) of the schema I need to retrieve the resource.
        try {
            //Resource resource = governanceRegistry.get(wso2Schema.getPath());

            boolean isDeprecated = "Deprecated".equals(wso2Schema.getLifecycleState());
            boolean isCanonical = "canonicalInformation1".equals(wso2Schema.getAttribute("informationModelRelation"));
            schemaIsReusable = (isCanonical && !isDeprecated);
        } catch (RegistryException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return schemaIsReusable;
    }

}

换句话说,我在WSO2 Schema类上使用了getAttribute而不是使用Resource类的getProperty,我没有得到任何异常。

我仍然很困惑为什么我可以使用getAttribute方法检索Schema的属性值。无法使用setAttribute方法设置相同的属性。为此,您需要使用setProperty。