use of biblemulticonverter.schema.usx3.ObjectFactory in project midpoint by Evolveum.
the class ParamsTypeUtil method setUnknownJavaObjectEntry.
private static void setUnknownJavaObjectEntry(EntryType entryType, Serializable value) {
UnknownJavaObjectType ujo = new UnknownJavaObjectType();
ujo.setClazz(value.getClass().getName());
ujo.setToString(value.toString());
entryType.setEntryValue(new ObjectFactory().createUnknownJavaObject(ujo));
}
use of biblemulticonverter.schema.usx3.ObjectFactory in project midpoint by Evolveum.
the class OperationResultFactory method createOperationResult.
public static OperationResultType createOperationResult(String operation, OperationResultStatusType status, Map<String, Element> params, String message, String messageCode, String localizedMessage, Object[] localizedArguments) {
OperationResultType result = createOperationResult(operation, status, params, message, messageCode);
if (StringUtils.isEmpty(localizedMessage)) {
return result;
}
ObjectFactory factory = new ObjectFactory();
LocalizedMessageType localizedMessageType = factory.createLocalizedMessageType();
result.setLocalizedMessage(localizedMessageType);
localizedMessageType.setKey(localizedMessage);
if (localizedArguments == null || localizedArguments.length == 0) {
return result;
}
for (Object object : localizedArguments) {
localizedMessageType.getArgument().add(object);
}
return result;
}
use of biblemulticonverter.schema.usx3.ObjectFactory in project ddf by codice.
the class TestGetRecordsResponseConverter method testMarshalRecordCollectionGetSummary.
@Ignore
public void testMarshalRecordCollectionGetSummary() throws UnsupportedEncodingException, JAXBException {
final int totalResults = 5;
XStream xstream = createXStream(CswConstants.GET_RECORDS_RESPONSE);
GetRecordsType getRecords = new GetRecordsType();
QueryType query = new QueryType();
ElementSetNameType set = new ElementSetNameType();
set.setValue(ElementSetType.SUMMARY);
query.setElementSetName(set);
ObjectFactory objectFactory = new ObjectFactory();
getRecords.setAbstractQuery(objectFactory.createAbstractQuery(query));
CswRecordCollection collection = createCswRecordCollection(getRecords, totalResults);
collection.setElementSetType(ElementSetType.SUMMARY);
ArgumentCaptor<MarshallingContext> captor = ArgumentCaptor.forClass(MarshallingContext.class);
String xml = xstream.toXML(collection);
// Verify the context arguments were set correctly
verify(mockProvider, times(totalResults)).marshal(any(Object.class), any(HierarchicalStreamWriter.class), captor.capture());
MarshallingContext context = captor.getValue();
assertThat(context, not(nullValue()));
assertThat(context.get(CswConstants.OUTPUT_SCHEMA_PARAMETER), is(CswConstants.CSW_OUTPUT_SCHEMA));
assertThat(context.get(CswConstants.ELEMENT_SET_TYPE), is(ElementSetType.SUMMARY));
JAXBElement<GetRecordsResponseType> jaxb = (JAXBElement<GetRecordsResponseType>) getJaxBContext().createUnmarshaller().unmarshal(new ByteArrayInputStream(xml.getBytes("UTF-8")));
GetRecordsResponseType response = jaxb.getValue();
// Assert the GetRecordsResponse elements and attributes
assertThat(response, not(nullValue()));
SearchResultsType resultsType = response.getSearchResults();
assertThat(resultsType, not(nullValue()));
assertThat(resultsType.getElementSet(), is(ElementSetType.SUMMARY));
assertThat(resultsType.getNumberOfRecordsMatched().intValue(), is(totalResults));
assertThat(resultsType.getNumberOfRecordsReturned().intValue(), is(totalResults));
assertThat(resultsType.getRecordSchema(), is(CswConstants.CSW_OUTPUT_SCHEMA));
}
use of biblemulticonverter.schema.usx3.ObjectFactory in project ddf by codice.
the class AbstractCswSource method createQuery.
private JAXBElement<QueryType> createQuery(Query query, ElementSetType elementSetType, List<QName> elementNames) throws UnsupportedQueryException {
QueryType queryType = new QueryType();
QName queryTypeQName = null;
try {
if (StringUtils.isNotBlank(cswSourceConfiguration.getQueryTypeName())) {
String[] parts = cswSourceConfiguration.getQueryTypeName().split(":");
if (parts.length > 1) {
queryTypeQName = new QName(cswSourceConfiguration.getQueryTypeNamespace(), parts[1], parts[0]);
} else {
queryTypeQName = new QName(cswSourceConfiguration.getQueryTypeNamespace(), cswSourceConfiguration.getQueryTypeName());
}
}
} catch (IllegalArgumentException e) {
LOGGER.debug("Unable to parse query type QName of {}. Defaulting to CSW Record", cswSourceConfiguration.getQueryTypeName());
}
if (queryTypeQName == null) {
queryTypeQName = new QName(CswConstants.CSW_OUTPUT_SCHEMA, CswConstants.CSW_RECORD_LOCAL_NAME, CswConstants.CSW_NAMESPACE_PREFIX);
}
queryType.setTypeNames(Arrays.asList(queryTypeQName));
if (null != elementSetType) {
queryType.setElementSetName(createElementSetName(elementSetType));
} else if (!CollectionUtils.isEmpty(elementNames)) {
queryType.setElementName(elementNames);
} else {
queryType.setElementSetName(createElementSetName(ElementSetType.FULL));
}
SortByType sortBy = createSortBy(query);
if (sortBy != null) {
queryType.setSortBy(sortBy);
}
QueryConstraintType constraint = createQueryConstraint(query);
if (null != constraint) {
queryType.setConstraint(constraint);
}
ObjectFactory objectFactory = new ObjectFactory();
return objectFactory.createQuery(queryType);
}
use of biblemulticonverter.schema.usx3.ObjectFactory in project Payara by payara.
the class Jaxb1MarshallingTestServlet method service.
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/html;charset=UTF-8");
PrintWriter out = resp.getWriter();
out.println("jaxb1 marshalling test: ");
try {
JAXBContext jc = JAXBContext.newInstance("jaxb1");
Marshaller m = jc.createMarshaller();
ObjectFactory of = new ObjectFactory();
Catalog c = of.createCatalog();
c.setSection("jaxb1 section");
StringWriter sw = new StringWriter();
m.marshal(c, sw);
String s = sw.toString();
if (s.contains("<catalog section=\"jaxb1 section\"/>"))
out.println("marshalled OK");
else {
out.println("jaxb1 marshalling failed");
System.err.println("Error in Jaxb1MarshallingTestServlet. Marshalling result: " + s);
}
} catch (JAXBException e) {
out.println("jaxb1 marshalling failed: " + e.getMessage());
e.printStackTrace();
}
}
Aggregations