List of usage examples for org.springframework.data.mapping MappingException MappingException
public MappingException(@Nullable String s, @Nullable Throwable throwable)
From source file:com._4dconcept.springframework.data.marklogic.core.MarklogicTemplate.java
private Content createSupportedContentObject(String uri, Object objectToSave) { try {//from ww w . jav a2 s . c om if (objectToSave instanceof Document) { return ContentFactory.newContent(uri, (Document) objectToSave, ContentCreateOptions.newXmlInstance()); } else if (objectToSave instanceof Node) { return ContentFactory.newContent(uri, (Node) objectToSave, ContentCreateOptions.newXmlInstance()); } else if (objectToSave instanceof JsonNode) { return ContentFactory.newJsonContent(uri, (JsonNode) objectToSave, ContentCreateOptions.newJsonInstance()); } else if (objectToSave instanceof XdmNode) { return ContentFactory.newContent(uri, (XdmNode) objectToSave, ContentCreateOptions.newXmlInstance()); } else if (objectToSave instanceof File) { return ContentFactory.newContent(uri, (File) objectToSave, new ContentCreateOptions()); // How to determine Content Type ? } else if (objectToSave instanceof RandomAccessFile) { return ContentFactory.newContent(uri, (RandomAccessFile) objectToSave, new ContentCreateOptions()); // How to determine Content Type ? } else if (objectToSave instanceof URL) { return ContentFactory.newContent(uri, (URL) objectToSave, new ContentCreateOptions()); // How to determine Content Type ? } else if (objectToSave instanceof URI) { return ContentFactory.newContent(uri, (URI) objectToSave, new ContentCreateOptions()); // How to determine Content Type ? } else if (objectToSave instanceof String) { return ContentFactory.newContent(uri, (String) objectToSave, new ContentCreateOptions()); // How to determine Content Type ? } else if (objectToSave instanceof byte[]) { return ContentFactory.newContent(uri, (byte[]) objectToSave, new ContentCreateOptions()); // How to determine Content Type ? } else if (objectToSave instanceof InputStream) { return ContentFactory.newContent(uri, (InputStream) objectToSave, new ContentCreateOptions()); // How to determine Content Type ? } } catch (IOException ioe) { throw new MappingException("Unable to access resource!", ioe); } throw new MappingException("Unexpected content type " + objectToSave.getClass()); }