public void saveMedia(String agent, String mediaLocation) { try { SecurityService.pushAdvisor( new SecurityAdvisor() { public SecurityAdvice isAllowed(String userId, String function, String reference) { return SecurityAdvice.ALLOWED; } }); File media = new File(mediaLocation); byte[] mediaByte = getMediaStream(mediaLocation); String mimeType = MimeTypesLocator.getInstance().getContentType(media); String fullname = media.getName().trim(); String collectionId = getPrivateCollection(); currentItem.setImageMapSrc("/access/content" + collectionId + fullname); ResourcePropertiesEdit resourceProperties = AssessmentService.getContentHostingService().newResourceProperties(); resourceProperties.addProperty(ResourceProperties.PROP_DISPLAY_NAME, fullname); AssessmentService.getContentHostingService() .addResource( collectionId + fullname, mimeType, mediaByte, resourceProperties, NotificationService.NOTI_NONE); } catch (Exception e) { log.warn(e); } finally { SecurityService.popAdvisor(); } }
/** remove recent add SecurityAdvisor from stack */ protected void disableSecurityAdvisor() { SecurityService.popAdvisor(); }
/** Remove our security advisor. */ public void popAdvisor() { SecurityService.popAdvisor(); }