@Test public void allowsDownloadingVcfAttachmentsWhenHasEditAccess() throws ComponentLookupException { when(this.request.getRequestURI()).thenReturn("/bin/download/data/P0000001/file.vcf"); when(this.access.hasAccessLevel(this.edit)).thenReturn(true); this.mocker.getComponentUnderTest().onEvent(this.event, this.doc, this.context); Assert.assertFalse(this.event.isCanceled()); }
@Override public void onEvent(Event event, Object source, Object data) { XWikiContext context = (XWikiContext) data; XWikiRequest request = context.getRequest(); String path = request.getRequestURI(); String filename; try { filename = URLDecoder.decode(getFileName(path), "UTF-8"); } catch (UnsupportedEncodingException e) { return; } if (StringUtils.endsWithIgnoreCase(filename, ".vcf")) { XWikiDocument doc = context.getDoc(); PrimaryEntity primaryEntity = this.resolver.resolveEntity(doc.getDocumentReference().toString()); EntityAccess access = this.permissions.getEntityAccess(primaryEntity); if (!access.hasAccessLevel(this.edit)) { ((CancelableEvent) event).cancel(); } } }
VCFAccessRestrictionEventListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { XWikiContext context = (XWikiContext) data; XWikiRequest request = context.getRequest(); String path = request.getRequestURI(); String filename; try { filename = URLDecoder.decode(getFileName(path), "UTF-8"); } catch (UnsupportedEncodingException e) { return; } if (StringUtils.endsWithIgnoreCase(filename, ".vcf")) { XWikiDocument doc = context.getDoc(); PrimaryEntity primaryEntity = this.resolver.resolveEntity(doc.getDocumentReference().toString()); EntityAccess access = this.permissions.getEntityAccess(primaryEntity); if (!access.hasAccessLevel(this.edit)) { ((CancelableEvent) event).cancel(); } } } }
VCFAccessRestrictionEventListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { XWikiContext context = (XWikiContext) data; XWikiRequest request = context.getRequest(); String path = request.getRequestURI(); String filename; try { filename = URLDecoder.decode(getFileName(path), "UTF-8"); } catch (UnsupportedEncodingException e) { return; } if (StringUtils.endsWithIgnoreCase(filename, ".vcf")) { XWikiDocument doc = context.getDoc(); PrimaryEntity primaryEntity = this.resolver.resolveEntity(doc.getDocumentReference().toString()); EntityAccess access = this.permissions.getEntityAccess(primaryEntity); if (!access.hasAccessLevel(this.edit)) { ((CancelableEvent) event).cancel(); } } } VCFAccessRestrictionEventListener(); }
VCFAccessRestrictionEventListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { XWikiContext context = (XWikiContext) data; XWikiRequest request = context.getRequest(); String path = request.getRequestURI(); String filename; try { filename = URLDecoder.decode(getFileName(path), "UTF-8"); } catch (UnsupportedEncodingException e) { return; } if (StringUtils.endsWithIgnoreCase(filename, ".vcf")) { XWikiDocument doc = context.getDoc(); PrimaryEntity primaryEntity = this.resolver.resolveEntity(doc.getDocumentReference().toString()); EntityAccess access = this.permissions.getEntityAccess(primaryEntity); if (!access.hasAccessLevel(this.edit)) { ((CancelableEvent) event).cancel(); } } } VCFAccessRestrictionEventListener(); @Override void onEvent(Event event, Object source, Object data); }
VCFAccessRestrictionEventListener extends AbstractEventListener { @Override public void onEvent(Event event, Object source, Object data) { XWikiContext context = (XWikiContext) data; XWikiRequest request = context.getRequest(); String path = request.getRequestURI(); String filename; try { filename = URLDecoder.decode(getFileName(path), "UTF-8"); } catch (UnsupportedEncodingException e) { return; } if (StringUtils.endsWithIgnoreCase(filename, ".vcf")) { XWikiDocument doc = context.getDoc(); PrimaryEntity primaryEntity = this.resolver.resolveEntity(doc.getDocumentReference().toString()); EntityAccess access = this.permissions.getEntityAccess(primaryEntity); if (!access.hasAccessLevel(this.edit)) { ((CancelableEvent) event).cancel(); } } } VCFAccessRestrictionEventListener(); @Override void onEvent(Event event, Object source, Object data);  }