diff --git a/.gitignore b/.gitignore index b446737..d944002 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ designer/org.openntf.xrest.designer.updatesite/artifacts.jar designer/org.openntf.xrest.designer.updatesite/content.jar designer/org.openntf.xrest.designer.updatesite/features/ designer/org.openntf.xrest.designer.updatesite/plugins/ +designer/target/ server/org.openntf.xrest.xsp.p2/.project server/org.openntf.xrest.xsp.p2/.settings/ server/org.openntf.xrest.xsp.p2/target/category.xml diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c5f3f6b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "interactive" +} \ No newline at end of file diff --git a/assembly/pom.xml b/assembly/pom.xml index 94b1a46..e48ae79 100644 --- a/assembly/pom.xml +++ b/assembly/pom.xml @@ -4,7 +4,7 @@ org.openntf.xrest xrest.parent - 1.0.0-SNAPSHOT + 10.0.1-SNAPSHOT xrest.assembly pom diff --git a/designer/org.openntf.xrest.designer.feature/feature.xml b/designer/org.openntf.xrest.designer.feature/feature.xml index f0450ef..8a16c71 100644 --- a/designer/org.openntf.xrest.designer.feature/feature.xml +++ b/designer/org.openntf.xrest.designer.feature/feature.xml @@ -2,7 +2,7 @@ + version="10.0.1.qualifier"> Transform your own NSF to a Microservice! diff --git a/designer/org.openntf.xrest.designer.feature/pom.xml b/designer/org.openntf.xrest.designer.feature/pom.xml index 5e72167..dbb8451 100644 --- a/designer/org.openntf.xrest.designer.feature/pom.xml +++ b/designer/org.openntf.xrest.designer.feature/pom.xml @@ -3,7 +3,7 @@ org.openntf.xrest xrest.designer.parent - 1.0.0-SNAPSHOT + 10.0.1-SNAPSHOT org.openntf.xrest.designer.feature eclipse-feature diff --git a/designer/org.openntf.xrest.designer.updatesite/pom.xml b/designer/org.openntf.xrest.designer.updatesite/pom.xml index 0e6d25b..be21f2c 100644 --- a/designer/org.openntf.xrest.designer.updatesite/pom.xml +++ b/designer/org.openntf.xrest.designer.updatesite/pom.xml @@ -3,7 +3,7 @@ org.openntf.xrest xrest.designer.parent - 1.0.0-SNAPSHOT + 10.0.1-SNAPSHOT org.openntf.xrest.designer.updatesite eclipse-update-site diff --git a/designer/org.openntf.xrest.designer.updatesite/site.xml b/designer/org.openntf.xrest.designer.updatesite/site.xml index abb049e..804d1e8 100644 --- a/designer/org.openntf.xrest.designer.updatesite/site.xml +++ b/designer/org.openntf.xrest.designer.updatesite/site.xml @@ -1,6 +1,6 @@ - + diff --git a/designer/org.openntf.xrest.designer/.classpath b/designer/org.openntf.xrest.designer/.classpath index ad32c83..f5b7b95 100644 --- a/designer/org.openntf.xrest.designer/.classpath +++ b/designer/org.openntf.xrest.designer/.classpath @@ -1,7 +1,11 @@ - + + + + + - - + + diff --git a/designer/org.openntf.xrest.designer/META-INF/MANIFEST.MF b/designer/org.openntf.xrest.designer/META-INF/MANIFEST.MF index 086afa2..293faa6 100644 --- a/designer/org.openntf.xrest.designer/META-INF/MANIFEST.MF +++ b/designer/org.openntf.xrest.designer/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: XREST API Designer Bundle-SymbolicName: org.openntf.xrest.designer;singleton:=true -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 10.0.1.qualifier Bundle-Activator: org.openntf.xrest.designer.XRestUIActivator Bundle-Vendor: WebGate Consulting AG Require-Bundle: org.eclipse.ui, diff --git a/designer/org.openntf.xrest.designer/pom.xml b/designer/org.openntf.xrest.designer/pom.xml index 93db327..28ef404 100644 --- a/designer/org.openntf.xrest.designer/pom.xml +++ b/designer/org.openntf.xrest.designer/pom.xml @@ -3,7 +3,7 @@ org.openntf.xrest xrest.designer.parent - 1.0.0-SNAPSHOT + 10.0.1-SNAPSHOT org.openntf.xrest.designer XRest Designer Plugin diff --git a/designer/org.openntf.xrestapi.designer.testsuite/.classpath b/designer/org.openntf.xrestapi.designer.testsuite/.classpath index b9afa1e..507d284 100644 --- a/designer/org.openntf.xrestapi.designer.testsuite/.classpath +++ b/designer/org.openntf.xrestapi.designer.testsuite/.classpath @@ -1,11 +1,15 @@ + + + + + + - - - - + + diff --git a/designer/org.openntf.xrestapi.designer.testsuite/META-INF/MANIFEST.MF b/designer/org.openntf.xrestapi.designer.testsuite/META-INF/MANIFEST.MF index 6560c29..ea11326 100644 --- a/designer/org.openntf.xrestapi.designer.testsuite/META-INF/MANIFEST.MF +++ b/designer/org.openntf.xrestapi.designer.testsuite/META-INF/MANIFEST.MF @@ -2,8 +2,8 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Testsuite Bundle-SymbolicName: org.openntf.xrestapi.designer.testsuite;singleton:=true -Bundle-Version: 1.0.0.qualifier -Fragment-Host: org.openntf.xrest.designer;bundle-version="1.0.0" +Bundle-Version: 10.0.1.qualifier +Fragment-Host: org.openntf.xrest.designer;bundle-version="10.0.1" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Require-Bundle: org.junit;bundle-version="4.11.0", com.ibm.notes.java.api, diff --git a/designer/org.openntf.xrestapi.designer.testsuite/pom.xml b/designer/org.openntf.xrestapi.designer.testsuite/pom.xml index 6068479..70fcd2e 100644 --- a/designer/org.openntf.xrestapi.designer.testsuite/pom.xml +++ b/designer/org.openntf.xrestapi.designer.testsuite/pom.xml @@ -3,7 +3,7 @@ org.openntf.xrest xrest.designer.parent - 1.0.0-SNAPSHOT + 10.0.1-SNAPSHOT org.openntf.xrestapi.designer.testsuite eclipse-test-plugin diff --git a/designer/pom.xml b/designer/pom.xml index 326991c..1ccd2cc 100644 --- a/designer/pom.xml +++ b/designer/pom.xml @@ -5,7 +5,7 @@ org.openntf.xrest xrest.parent - 1.0.0-SNAPSHOT + 10.0.1-SNAPSHOT xrest.designer.parent pom diff --git a/designer/target/.gitignore b/designer/target/.gitignore deleted file mode 100644 index 8d25b15..0000000 --- a/designer/target/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/jacoco.exec diff --git a/pom.xml b/pom.xml index 53f3212..3b76495 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 org.openntf.xrest xrest.parent - 1.0.0-SNAPSHOT + 10.0.1-SNAPSHOT pom ${project.basedir} diff --git a/server/org.openntf.xrest.libraries/META-INF/MANIFEST.MF b/server/org.openntf.xrest.libraries/META-INF/MANIFEST.MF index 95248e3..02c8837 100644 --- a/server/org.openntf.xrest.libraries/META-INF/MANIFEST.MF +++ b/server/org.openntf.xrest.libraries/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: XRest API Libraries Bundle-SymbolicName: org.openntf.xrest.libraries;singleton:=true -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 10.0.1.qualifier Bundle-Vendor: WebGate Consulting AG Bundle-ActivationPolicy: lazy Require-Bundle: org.eclipse.core.runtime;resolution:=optional diff --git a/server/org.openntf.xrest.libraries/pom.xml b/server/org.openntf.xrest.libraries/pom.xml index af889d8..3242e92 100644 --- a/server/org.openntf.xrest.libraries/pom.xml +++ b/server/org.openntf.xrest.libraries/pom.xml @@ -4,7 +4,7 @@ org.openntf.xrest xrest.xsp.parent - 1.0.0-SNAPSHOT + 10.0.1-SNAPSHOT org.openntf.xrest.libraries diff --git a/server/org.openntf.xrest.xsp.feature.source/feature.xml b/server/org.openntf.xrest.xsp.feature.source/feature.xml index 601a43a..2501618 100644 --- a/server/org.openntf.xrest.xsp.feature.source/feature.xml +++ b/server/org.openntf.xrest.xsp.feature.source/feature.xml @@ -2,7 +2,7 @@ diff --git a/server/org.openntf.xrest.xsp.feature.source/pom.xml b/server/org.openntf.xrest.xsp.feature.source/pom.xml index 61fdc49..9cf7166 100644 --- a/server/org.openntf.xrest.xsp.feature.source/pom.xml +++ b/server/org.openntf.xrest.xsp.feature.source/pom.xml @@ -3,7 +3,7 @@ org.openntf.xrest xrest.xsp.parent - 1.0.0-SNAPSHOT + 10.0.1-SNAPSHOT org.openntf.xrest.xsp.feature.source eclipse-feature diff --git a/server/org.openntf.xrest.xsp.feature/feature.xml b/server/org.openntf.xrest.xsp.feature/feature.xml index 1d1d2e6..3c91e8e 100644 --- a/server/org.openntf.xrest.xsp.feature/feature.xml +++ b/server/org.openntf.xrest.xsp.feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/server/org.openntf.xrest.xsp.feature/pom.xml b/server/org.openntf.xrest.xsp.feature/pom.xml index 38f972e..c629e74 100644 --- a/server/org.openntf.xrest.xsp.feature/pom.xml +++ b/server/org.openntf.xrest.xsp.feature/pom.xml @@ -6,7 +6,7 @@ org.openntf.xrest xrest.xsp.parent - 1.0.0-SNAPSHOT + 10.0.1-SNAPSHOT diff --git a/server/org.openntf.xrest.xsp.p2/category.xml b/server/org.openntf.xrest.xsp.p2/category.xml index 7f2c6f8..b42ba7a 100644 --- a/server/org.openntf.xrest.xsp.p2/category.xml +++ b/server/org.openntf.xrest.xsp.p2/category.xml @@ -1,8 +1,8 @@ - + - + diff --git a/server/org.openntf.xrest.xsp.p2/pom.xml b/server/org.openntf.xrest.xsp.p2/pom.xml index c0ba9d3..f70adc7 100644 --- a/server/org.openntf.xrest.xsp.p2/pom.xml +++ b/server/org.openntf.xrest.xsp.p2/pom.xml @@ -3,7 +3,7 @@ org.openntf.xrest xrest.xsp.parent - 1.0.0-SNAPSHOT + 10.0.1-SNAPSHOT org.openntf.xrest.xsp.p2 org.openntf.xrest.xsp.p2 diff --git a/server/org.openntf.xrest.xsp.swaggui/META-INF/MANIFEST.MF b/server/org.openntf.xrest.xsp.swaggui/META-INF/MANIFEST.MF index e231ca4..c65b7f7 100644 --- a/server/org.openntf.xrest.xsp.swaggui/META-INF/MANIFEST.MF +++ b/server/org.openntf.xrest.xsp.swaggui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: XRest Swagger UI Wrapper Bundle-SymbolicName: org.openntf.xrest.xsp.swaggui;singleton:=true -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 10.0.1.qualifier Bundle-Vendor: WebGate Consulting AG Bundle-ActivationPolicy: lazy Require-Bundle: org.eclipse.core.runtime;resolution:=optional, diff --git a/server/org.openntf.xrest.xsp.swaggui/pom.xml b/server/org.openntf.xrest.xsp.swaggui/pom.xml index b5ed578..258de9a 100644 --- a/server/org.openntf.xrest.xsp.swaggui/pom.xml +++ b/server/org.openntf.xrest.xsp.swaggui/pom.xml @@ -4,7 +4,7 @@ org.openntf.xrest xrest.xsp.parent - 1.0.0-SNAPSHOT + 10.0.1-SNAPSHOT org.openntf.xrest.xsp.swaggui org.openntf.xrest.xsp.swaggui diff --git a/server/org.openntf.xrest.xsp.testsuite/META-INF/MANIFEST.MF b/server/org.openntf.xrest.xsp.testsuite/META-INF/MANIFEST.MF index e11679e..16dba18 100644 --- a/server/org.openntf.xrest.xsp.testsuite/META-INF/MANIFEST.MF +++ b/server/org.openntf.xrest.xsp.testsuite/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: XREST API Plugin Bundle-SymbolicName: org.openntf.xrest.xsp.testsuite -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 10.0.1.qualifier Bundle-Vendor: WebGate Consulting AG Fragment-Host: org.openntf.xrest.xsp Require-Bundle: org.junit;bundle-version="4.11.0" diff --git a/server/org.openntf.xrest.xsp.testsuite/pom.xml b/server/org.openntf.xrest.xsp.testsuite/pom.xml index 993dfae..73bbe12 100644 --- a/server/org.openntf.xrest.xsp.testsuite/pom.xml +++ b/server/org.openntf.xrest.xsp.testsuite/pom.xml @@ -4,7 +4,7 @@ org.openntf.xrest xrest.xsp.parent - 1.0.0-SNAPSHOT + 10.0.1-SNAPSHOT org.openntf.xrest.xsp.testsuite eclipse-test-plugin diff --git a/server/org.openntf.xrest.xsp.updatesite/pom.xml b/server/org.openntf.xrest.xsp.updatesite/pom.xml index 2e51140..2407f43 100644 --- a/server/org.openntf.xrest.xsp.updatesite/pom.xml +++ b/server/org.openntf.xrest.xsp.updatesite/pom.xml @@ -6,7 +6,7 @@ org.openntf.xrest xrest.xsp.parent - 1.0.0-SNAPSHOT + 10.0.1-SNAPSHOT diff --git a/server/org.openntf.xrest.xsp.updatesite/site.xml b/server/org.openntf.xrest.xsp.updatesite/site.xml index 3312e72..80a243d 100644 --- a/server/org.openntf.xrest.xsp.updatesite/site.xml +++ b/server/org.openntf.xrest.xsp.updatesite/site.xml @@ -1,6 +1,6 @@ - + diff --git a/server/org.openntf.xrest.xsp/META-INF/MANIFEST.MF b/server/org.openntf.xrest.xsp/META-INF/MANIFEST.MF index 62838dd..0e200c7 100644 --- a/server/org.openntf.xrest.xsp/META-INF/MANIFEST.MF +++ b/server/org.openntf.xrest.xsp/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: XRest API Server Bundle-SymbolicName: org.openntf.xrest.xsp;singleton:=true -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 10.0.1.qualifier Bundle-Vendor: WebGate Consulting AG Bundle-ActivationPolicy: lazy Require-Bundle: org.eclipse.core.runtime;resolution:=optional, diff --git a/server/org.openntf.xrest.xsp/pom.xml b/server/org.openntf.xrest.xsp/pom.xml index f233ed2..b3e21b8 100644 --- a/server/org.openntf.xrest.xsp/pom.xml +++ b/server/org.openntf.xrest.xsp/pom.xml @@ -4,7 +4,7 @@ org.openntf.xrest xrest.xsp.parent - 1.0.0-SNAPSHOT + 10.0.1-SNAPSHOT org.openntf.xrest.xsp XRest Server Package XSP diff --git a/server/org.openntf.xrest.xsp/src/org/openntf/xrest/xsp/exec/convertor/datatypes/MimeMapJsonTypeProcessor.java b/server/org.openntf.xrest.xsp/src/org/openntf/xrest/xsp/exec/convertor/datatypes/MimeMapJsonTypeProcessor.java index d2f2e85..c154028 100644 --- a/server/org.openntf.xrest.xsp/src/org/openntf/xrest/xsp/exec/convertor/datatypes/MimeMapJsonTypeProcessor.java +++ b/server/org.openntf.xrest.xsp/src/org/openntf/xrest/xsp/exec/convertor/datatypes/MimeMapJsonTypeProcessor.java @@ -41,8 +41,9 @@ public class MimeMapJsonTypeProcessor extends AbstractMapJsonTypeProcessor { private static final String BINARY_HEADER_VALUE = "binary"; private static final String CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding"; private static final String CONTENT_DISPOSITION = "Content-Disposition"; + private static final String CONTENT_ID = "Content-ID"; protected static final String MULTIPART_MIXED = "multipart/mixed"; - protected static final String CONTENT_TYPE = "Content-Type"; + public static final String CONTENT_TYPE = "Content-Type"; private static final String TEXT_HTML_CHARSET_UTF_8 = "text/html;charset=UTF-8"; private static final String CHARSET_UTF_8 = "charset=UTF-8"; @@ -333,6 +334,17 @@ protected MIMEEntity findAttachment(final MIMEEntity entity, final String attach childCurrent.recycle(); } } + String contentId = getContentIDHeaderValue(entity); + if (!StringUtil.isEmpty(contentId)) { + String attachmentNameEnhanced = "<"+attachmentName.toLowerCase() +">"; + String attachmentNameCleaned = attachmentNameEnhanced.toLowerCase().replaceAll("[^\\w\\s]","").replace(" ", ""); + String contentIdCleaned = contentId.toLowerCase().replaceAll("[^\\w\\s]","").replace(" ", ""); + if (contentId.toLowerCase().equals(attachmentName.toLowerCase()) + || contentId.toLowerCase().equals(attachmentNameEnhanced) + || contentIdCleaned.equals(attachmentNameCleaned)) { + return entity; + } + } String dispositionValue = getContentDispositionHeaderValue(entity); if (!StringUtil.isEmpty(dispositionValue) && dispositionValue.startsWith(ATTACHMENT_HEADER_VALUE)) { // System.out.println(dispositionValue); @@ -353,6 +365,16 @@ protected String getContentDispositionHeaderValue(final MIMEEntity entity) throw return null; } + protected String getContentIDHeaderValue(final MIMEEntity entity) throws NotesException { + MIMEHeader mimeheader = entity.getNthHeader(CONTENT_ID); + if (mimeheader != null) { + String val = mimeheader.getHeaderValAndParams(false, true); + mimeheader.recycle(); + return val; + } + return null; + } + protected String getContentHeaderValue(final MIMEEntity entity) throws NotesException { MIMEHeader mimeHeader = entity.getNthHeader(CONTENT_TYPE); if (mimeHeader != null) { diff --git a/server/org.openntf.xrest.xsp/src/org/openntf/xrest/xsp/exec/impl/GETAttachmentRouteProcessorExecutor.java b/server/org.openntf.xrest.xsp/src/org/openntf/xrest/xsp/exec/impl/GETAttachmentRouteProcessorExecutor.java index 0dd1660..03afa7c 100644 --- a/server/org.openntf.xrest.xsp/src/org/openntf/xrest/xsp/exec/impl/GETAttachmentRouteProcessorExecutor.java +++ b/server/org.openntf.xrest.xsp/src/org/openntf/xrest/xsp/exec/impl/GETAttachmentRouteProcessorExecutor.java @@ -9,6 +9,7 @@ import org.openntf.xrest.xsp.exec.Context; import org.openntf.xrest.xsp.exec.ExecutorException; +import org.openntf.xrest.xsp.exec.convertor.datatypes.MimeMapJsonTypeProcessor; import org.openntf.xrest.xsp.exec.datacontainer.AttachmentDataContainer; import org.openntf.xrest.xsp.model.DataContainer; import org.openntf.xrest.xsp.model.RouteProcessor; @@ -19,7 +20,9 @@ import lotus.domino.EmbeddedObject; import lotus.domino.MIMEEntity; +import lotus.domino.MIMEHeader; import lotus.domino.NotesException; +import lotus.domino.Stream; public class GETAttachmentRouteProcessorExecutor extends AbstractRouteProcessorExecutor { @@ -32,16 +35,26 @@ protected void submitValues(Context context, RouteProcessor routeProcessor, Data HttpServletResponse response = context.getResponse(); AttachmentDataContainer adc = (AttachmentDataContainer) dataContainer; try { - String mimeType = URLConnection.guessContentTypeFromName( adc.getFileName()); - InputStream is = getInputStream(adc); - response.setContentType(StringUtil.isEmpty(mimeType) ?"application/octet-stream": mimeType); + String mimeType = GuessMimeType(adc); + response.setContentType(mimeType); response.addHeader("Content-Disposition", "attachment;filename=\"" + adc.getFileName() + "\""); OutputStream out = response.getOutputStream(); - StreamUtil.copyStream(is, out); - out.close(); - is.close(); + if (adc.isMime()) { + Stream outStream = context.getSession().createStream(); + MIMEEntity entity = (MIMEEntity) adc.getData(); + entity.getContentAsBytes(outStream, true); + outStream.getContents(out); + outStream.close(); + out.close(); + } else { + InputStream is = getInputStream(adc); + StreamUtil.copyStream(is, out); + out.close(); + is.close(); + + } } catch (Exception e) { - throw new ExecutorException(500, "Runtime Error: " + e.getMessage(), e, path, "presubmit"); + throw new ExecutorException(500, "Runtime Error: " + e.getMessage(), e, path, "submitValues"); } } @@ -60,4 +73,21 @@ private InputStream getInputStream(final AttachmentDataContainer adc) throws return ((EmbeddedObject) adc.getData()).getInputStream(); } } + private String GuessMimeType(AttachmentDataContainer adc) { + if (adc.isMime()) { + MIMEEntity entity = (MIMEEntity) adc.getData(); + try { + MIMEHeader mimeHeader = entity.getNthHeader(MimeMapJsonTypeProcessor.CONTENT_TYPE); + if (mimeHeader != null) { + String contenType = mimeHeader.getHeaderVal(); + mimeHeader.recycle(); + return contenType; + } + } catch(Exception e) { + e.printStackTrace(); + } + } + String fromUrl = URLConnection.guessContentTypeFromName( adc.getFileName()); + return StringUtil.isEmpty(fromUrl) ? "application/octet-stream": fromUrl; + } } diff --git a/server/pom.xml b/server/pom.xml index e9b629a..20eb538 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -5,7 +5,7 @@ org.openntf.xrest xrest.parent - 1.0.0-SNAPSHOT + 10.0.1-SNAPSHOT xrest.xsp.parent pom diff --git a/server/xrest.xsp.assembly/pom.xml b/server/xrest.xsp.assembly/pom.xml index 1aa0918..bf23aa3 100644 --- a/server/xrest.xsp.assembly/pom.xml +++ b/server/xrest.xsp.assembly/pom.xml @@ -4,7 +4,7 @@ org.openntf.xrest xrest.xsp.parent - 1.0.0-SNAPSHOT + 10.0.1-SNAPSHOT xrest.xsp.assembly pom