本文整理汇总了Java中org.javarosa.xml.util.InvalidStructureException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidStructureException类的具体用法?Java InvalidStructureException怎么用?Java InvalidStructureException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InvalidStructureException类属于org.javarosa.xml.util包,在下文中一共展示了InvalidStructureException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processResponse
import org.javarosa.xml.util.InvalidStructureException; //导入依赖的package包/类
/**
* Process the response to the current message (may have side effects).
*
* @param message A completed transport message with an available response.
* @return A string with the user facing messages which were parsed out from that response.
* @throws InvalidStructureException If the response is present, but incorrectly structured
* @throws IOException
* @throws UnfullfilledRequirementsException If the isn't capable of processing the provided message
* for well recognized reasons (Like the API version of the response being above that currently understood)
* @throws XmlPullParserException
*/
public String processResponse(SimpleHttpTransportMessage message) throws InvalidStructureException, IOException, UnfullfilledRequirementsException, XmlPullParserException {
if(message.getResponseProperties() != null && ONE_OH.equals(message.getResponseProperties().getORApiVersion())) {
//TODO: Eliminate byte arrays, and replace with an active stream of the response
byte[] response = message.getResponseBody();
DataModelPullParser parser = new DataModelPullParser(new ByteArrayInputStream(response), factory);
boolean success = parser.parse();
if(factory.getResponseMessage() != null) {
return factory.getResponseMessage();
} else {
return null;
}
}
//throw some exception
throw new UnfullfilledRequirementsException("Unrecognized response type", CommCareElementParser.SEVERITY_ENVIRONMENT);
}
示例2: parse
import org.javarosa.xml.util.InvalidStructureException; //导入依赖的package包/类
@Override
public FormInstance parse() throws InvalidStructureException, IOException, XmlPullParserException {
this.checkNode("instance");
String instanceId = parser.getAttributeValue(null, "src");
if(instanceId == null) {
throw new InvalidStructureException("Instance lacking src", parser);
}
//Get to the data root
parser.nextTag();
//TODO: We need to overwrite any matching records here.
TreeElement root = new TreeElementParser(parser, 0, null).parse();
return new FormInstance(root, instanceId);
}
示例3: parse
import org.javarosa.xml.util.InvalidStructureException; //导入依赖的package包/类
@Override
public RootTranslator parse() throws InvalidStructureException, IOException, XmlPullParserException {
this.checkNode("root");
String id = parser.getAttributeValue(null, "prefix");
String readonly = parser.getAttributeValue(null, "readonly");
//Get the child or error out if none exists
getNextTagInBlock("root");
String referenceType = parser.getName().toLowerCase();
String path = parser.getAttributeValue(null, "path");
if (referenceType.equals("filesystem")) {
return new RootTranslator("jr://" + id + "/", "jr://file" + path);
} else if (referenceType.equals("resource")) {
return new RootTranslator("jr://" + id + "/", "jr://resource" + path);
} else if (referenceType.equals("absolute")) {
return new RootTranslator("jr://" + id + "/", path);
} else {
throw new InvalidStructureException("No available reference types to parse out reference root " + referenceType, parser);
}
}
示例4: parse
import org.javarosa.xml.util.InvalidStructureException; //导入依赖的package包/类
public Hashtable<String, String> parse() throws InvalidStructureException, IOException, XmlPullParserException, UnfullfilledRequirementsException {
String name = parser.getName();
Hashtable<String, String> ret = new Hashtable<String, String>();
boolean expecting = false;
String expected = null;
while (this.nextTagInBlock(name)) {
if (expecting) {
if (parser.getEventType() == KXmlParser.TEXT) {
ret.put(expected, parser.getText());
}
expecting = false;
}
if (matches()) {
expecting = true;
expected = parser.getName();
}
}
commit(ret);
return ret;
}
示例5: parse
import org.javarosa.xml.util.InvalidStructureException; //导入依赖的package包/类
public Integer parse() throws InvalidStructureException, IOException, XmlPullParserException {
checkNode("grid");
String gridx = parser.getAttributeValue(null, "grid-x");
builder.setGridX(Integer.parseInt(gridx));
String gridy = parser.getAttributeValue(null, "grid-y");
builder.setGridY(Integer.parseInt(gridy));
String gridw = parser.getAttributeValue(null, "grid-width");
builder.setGridWidth(Integer.parseInt(gridw));
String gridh = parser.getAttributeValue(null, "grid-height");
builder.setGridHeight(Integer.parseInt(gridh));
//exit grid block
parser.nextTag();
return new Integer(1);
}
示例6: parseXPath
import org.javarosa.xml.util.InvalidStructureException; //导入依赖的package包/类
private Text parseXPath() throws InvalidStructureException, IOException, XmlPullParserException {
checkNode("xpath");
String function = parser.getAttributeValue(null, "function");
Hashtable<String, Text> arguments = new Hashtable<String, Text>();
//Now get all of the variables which might be used
while (nextTagInBlock("xpath")) {
checkNode("variable");
String name = parser.getAttributeValue(null, "name");
Text variableText = new TextParser(parser).parseBody();
arguments.put(name, variableText);
}
try {
return Text.XPathText(function, arguments);
} catch (XPathSyntaxException e) {
e.printStackTrace();
throw new InvalidStructureException("Invalid XPath Expression : " + function + ". Parse error: " + e.getMessage(), parser);
}
}
示例7: parse
import org.javarosa.xml.util.InvalidStructureException; //导入依赖的package包/类
public RootTranslator parse() throws InvalidStructureException, IOException, XmlPullParserException {
this.checkNode("root");
String id = parser.getAttributeValue(null, "prefix");
String readonly = parser.getAttributeValue(null, "readonly");
//Get the child or error out if none exists
getNextTagInBlock("root");
String referenceType = parser.getName().toLowerCase();
String path = parser.getAttributeValue(null, "path");
if (referenceType.equals("filesystem")) {
return new RootTranslator("jr://" + id + "/", "jr://file" + path);
} else if (referenceType.equals("resource")) {
return new RootTranslator("jr://" + id + "/", "jr://resource" + path);
} else if (referenceType.equals("absolute")) {
return new RootTranslator("jr://" + id + "/", path);
} else {
throw new InvalidStructureException("No available reference types to parse out reference root " + referenceType, parser);
}
}
示例8: updateAndWriteRecord
import org.javarosa.xml.util.InvalidStructureException; //导入依赖的package包/类
/**
* Reparse the saved form instance associated with the form record and
* apply any updates found to the form record, such as UUID and date
* modified, returning an updated copy with the status set to saved. Write
* the updated record to storage.
*
* @param context Used to get the filepath of the form instance
* associated with the record.
* @param oldRecord Reparse this record and return an updated copy of it
* @param storage User storage where updated FormRecord is written
* @return The reparsed form record and the associated case id, if present
* @throws IOException Problem opening the saved form
* attached to the record.
* @throws InvalidStructureException Occurs during reparsing of the
* form attached to record.
* @throws XmlPullParserException
* @throws UnfullfilledRequirementsException Parsing encountered a platform
* versioning problem
*/
public static FormRecord updateAndWriteRecord(Context context,
FormRecord oldRecord,
SqlStorage<FormRecord> storage)
throws InvalidStructureException, IOException,
XmlPullParserException, UnfullfilledRequirementsException {
Pair<FormRecord, String> recordUpdates = reparseRecord(context, oldRecord);
FormRecord updated = recordUpdates.first;
String caseId = recordUpdates.second;
if (caseId != null &&
FormRecord.STATUS_UNINDEXED.equals(oldRecord.getStatus())) {
throw new RuntimeException("Trying to update an unindexed record without performing the indexing");
}
storage.write(updated);
return updated;
}
示例9: parseProcessingFailureResponse
import org.javarosa.xml.util.InvalidStructureException; //导入依赖的package包/类
public static String parseProcessingFailureResponse(InputStream responseStream)
throws IOException, InvalidStructureException, UnfullfilledRequirementsException,
XmlPullParserException {
KXmlParser baseParser = ElementParser.instantiateParser(responseStream);
ElementParser<String> responseParser = new ElementParser<String>(baseParser) {
@Override
public String parse() throws InvalidStructureException, IOException,
XmlPullParserException, UnfullfilledRequirementsException {
checkNode("OpenRosaResponse");
nextTag("message");
String natureOfResponse = parser.getAttributeValue(null, "nature");
if ("processing_failure".equals(natureOfResponse)) {
return parser.nextText();
} else {
throw new UnfullfilledRequirementsException(
"<message> for 422 response did not contain expected content",
CommCareElementParser.SEVERITY_UNKOWN);
}
}
};
return responseParser.parse();
}
示例10: queryIndexedLookup
import org.javarosa.xml.util.InvalidStructureException; //导入依赖的package包/类
@Test
public void queryIndexedLookup() throws XPathSyntaxException, UnfullfilledRequirementsException,
XmlPullParserException, IOException, InvalidStructureException {
ParseUtils.parseIntoSandbox(getClass().getResourceAsStream("/indexed-fixture.xml"), sandbox);
EvaluationContext ec =
MockDataUtils.buildContextWithInstance(sandbox, "products", CaseTestUtils.FIXTURE_INSTANCE_PRODUCT);
CaseTestUtils.xpathEvalAndAssert(ec, "instance('products')/products/product[@id = 'a6d16035b98f6f962a6538bd927cefb3']/name", "CU");
// ensure that the entire fixture is stored in the normal storage.
// This is to ensure if we ever change the indexed data model, we can
// perform offline data migrations
assertEquals(1, sandbox.getUserFixtureStorage().getNumRecords());
// make sure the fixture is stored in the indexed fixture storage
assertEquals(4, sandbox.getIndexedFixtureStorage("commtrack:products").getNumRecords());
}
示例11: buildUserParser
import org.javarosa.xml.util.InvalidStructureException; //导入依赖的package包/类
private TransactionParser buildUserParser(KXmlParser parser) {
return new UserXmlParser(parser) {
@Override
protected void commit(User parsed) throws IOException, InvalidStructureException {
if (!parsed.getUserType().equals(User.TYPE_DEMO)) {
throw new InvalidStructureException(
"Demo user restore file must be for a user with user_type set to demo");
}
if ("".equals(parsed.getUsername()) || parsed.getUsername() == null) {
throw new InvalidStructureException(
"Demo user restore file must specify a username in the Registration block");
} else {
OfflineUserRestore.this.username = parsed.getUsername();
}
}
@Override
public User retrieve(String entityId) {
return null;
}
};
}
示例12: install
import org.javarosa.xml.util.InvalidStructureException; //导入依赖的package包/类
@Override
public boolean install(Resource r, ResourceLocation location,
Reference ref, ResourceTable table,
CommCarePlatform platform, boolean upgrade)
throws UnresolvedResourceException, UnfullfilledRequirementsException {
try {
OfflineUserRestore offlineUserRestore = OfflineUserRestore.buildInMemoryUserRestore(ref.getStream());
storage(platform).write(offlineUserRestore);
if (upgrade) {
table.commit(r, Resource.RESOURCE_STATUS_INSTALLED);
} else {
table.commit(r, Resource.RESOURCE_STATUS_UPGRADE);
}
cacheLocation = offlineUserRestore.getID();
} catch (IOException | XmlPullParserException | InvalidStructureException e) {
throw new UnresolvedResourceException(r, e.getMessage());
}
return true;
}
示例13: process
import org.javarosa.xml.util.InvalidStructureException; //导入依赖的package包/类
public static void process(final UserSandbox sandbox, InputStream stream)
throws InvalidStructureException, IOException, XmlPullParserException,
UnfullfilledRequirementsException {
process(stream, new TransactionParserFactory() {
@Override
public TransactionParser getParser(KXmlParser parser) {
if (LedgerXmlParsers.STOCK_XML_NAMESPACE.equals(parser.getNamespace())) {
return new LedgerXmlParsers(parser, sandbox.getLedgerStorage());
} else if ("case".equalsIgnoreCase(parser.getName())) {
return new CaseXmlParser(parser, sandbox.getCaseStorage());
}
return null;
}
});
}
示例14: loadCase
import org.javarosa.xml.util.InvalidStructureException; //导入依赖的package包/类
private Case loadCase(Case caseForBlock, String caseId, Map<String, Case> currentOperatingSet,
boolean errorIfMissing) throws InvalidStructureException {
if (caseForBlock == null) {
caseForBlock = currentOperatingSet.get(caseId);
}
if (errorIfMissing && caseForBlock == null) {
throw new InvalidStructureException("Unable to update or close case " + caseId + ", it wasn't found");
}
return caseForBlock;
}
示例15: DataModelPullParser
import org.javarosa.xml.util.InvalidStructureException; //导入依赖的package包/类
public DataModelPullParser(InputStream is, TransactionParserFactory factory, boolean failfast, boolean deep, CommCareOTARestoreListener rListener) throws InvalidStructureException, IOException {
super(ElementParser.instantiateParser(is));
this.is = is;
this.failfast = failfast;
this.factory = factory;
errors = new Vector<>();
this.deep = deep;
this.rListener = rListener;
}