protected boolean checkMediaCollection(String id) { SecurityAdvisor resourceAdvisor = pushAdvisor(); try { contentHostingService.checkCollection(id); } catch (IdUnusedException | TypeException | PermissionException e) { return false; } finally { popAdvisor(resourceAdvisor); } return true; }
protected boolean checkMediaCollection(String id) { SecurityAdvisor resourceAdvisor = pushAdvisor(); try { contentHostingService.checkCollection(id); } catch (IdUnusedException | TypeException | PermissionException e) { return false; } finally { popAdvisor(resourceAdvisor); } return true; }
protected boolean ensureMediaCollection(String id) { SecurityAdvisor resourceAdvisor = pushAdvisor(); try { ContentCollection coll = contentHostingService.getCollection(id); } catch (IdUnusedException ie) { log.debug("Creating collection: " + id); String name = id; if (name.endsWith("/")) { name = id.substring(0, id.length() - 1); } name = name.substring(name.lastIndexOf('/') + 1); try { ContentCollectionEdit edit = contentHostingService.addCollection(id); ResourcePropertiesEdit props = edit.getPropertiesEdit(); props.addProperty(ResourceProperties.PROP_DISPLAY_NAME, name); contentHostingService.commitCollection(edit); } catch (IdUsedException | IdInvalidException | PermissionException | InconsistentException collex) { log.warn("[Samigo Media Attachments] Exception while creating collection (" + id + "): " + collex.toString()); return false; } } catch (TypeException | PermissionException e) { log.warn("[Samigo Media Attachments] General exception while ensuring collection: " + e.toString()); } finally { popAdvisor(resourceAdvisor); } return true; }
protected boolean ensureMediaCollection(String id) { SecurityAdvisor resourceAdvisor = pushAdvisor(); try { ContentCollection coll = contentHostingService.getCollection(id); } catch (IdUnusedException ie) { log.debug("Creating collection: " + id); String name = id; if (name.endsWith("/")) { name = id.substring(0, id.length() - 1); } name = name.substring(name.lastIndexOf('/') + 1); try { ContentCollectionEdit edit = contentHostingService.addCollection(id); ResourcePropertiesEdit props = edit.getPropertiesEdit(); props.addProperty(ResourceProperties.PROP_DISPLAY_NAME, name); contentHostingService.commitCollection(edit); } catch (IdUsedException | IdInvalidException | PermissionException | InconsistentException collex) { log.warn("[Samigo Media Attachments] Exception while creating collection (" + id + "): " + collex.toString()); return false; } } catch (TypeException | PermissionException e) { log.warn("[Samigo Media Attachments] General exception while ensuring collection: " + e.toString()); } finally { popAdvisor(resourceAdvisor); } return true; }
protected ContentResource getMediaContentResource(MediaData mediaData) { if (mediaData.getContentResource() != null) { return mediaData.getContentResource(); } String id = getMediaPath(mediaData); log.debug("=====> Reading media: " + id); if (id != null) { SecurityAdvisor resourceAdvisor = pushAdvisor(); try { ContentResource res = contentHostingService.getResource(id); return res; } catch (IdUnusedException ie) { log.info("Nonexistent resource when trying to load media (id: " + mediaData.getMediaId() + "): " + id); } catch (PermissionException | TypeException e) { log.debug("Exception while reading media from content (" + mediaData.getMediaId() + "):" + e.toString()); } finally { popAdvisor(resourceAdvisor); } } return null; }
protected ContentResource getMediaContentResource(MediaData mediaData) { if (mediaData.getContentResource() != null) { return mediaData.getContentResource(); } String id = getMediaPath(mediaData); log.debug("=====> Reading media: " + id); if (id != null) { SecurityAdvisor resourceAdvisor = pushAdvisor(); try { ContentResource res = contentHostingService.getResource(id); return res; } catch (IdUnusedException ie) { log.info("Nonexistent resource when trying to load media (id: " + mediaData.getMediaId() + "): " + id); } catch (PermissionException | TypeException e) { log.debug("Exception while reading media from content (" + mediaData.getMediaId() + "):" + e.toString()); } finally { popAdvisor(resourceAdvisor); } } return null; }
if (mediaData.getMedia() != null && ensureMediaPath(mediaPath)) { log.debug("=====> Saving media: " + mediaPath); SecurityAdvisor resourceAdvisor = pushAdvisor(); boolean newResource = true;
if (mediaData.getMedia() != null && ensureMediaPath(mediaPath)) { log.debug("=====> Saving media: " + mediaPath); SecurityAdvisor resourceAdvisor = pushAdvisor(); boolean newResource = true;