public Attachment getAttachment() { if (null == attachment) attachment = attachmentManager.getAttachment(getContentEntityObject(), attachmentName); return attachment; }
private boolean isPathPointingToPageAttachment(String[] resourcePathTokens) { if (resourcePathTokens.length >= 5 && (StringUtils.equals(GlobalSpacesResourceImpl.DISPLAY_NAME, resourcePathTokens[1]) || StringUtils.equals(PersonalSpacesResourceImpl.DISPLAY_NAME, resourcePathTokens[1]))) { String spaceKey = resourcePathTokens[2]; Space space = spaceManager.getSpace(spaceKey); Page page = pageManager.getPage(spaceKey, resourcePathTokens[resourcePathTokens.length - 2]); return null != space && !hasAliasInTokens(resourcePathTokens, 3) && null != page && null != attachmentManager.getAttachment(page, resourcePathTokens[resourcePathTokens.length - 1]); } return false; }
private boolean isPathPointingSpaceAttachment(String[] resourcePathTokens) { if (resourcePathTokens.length == 4 && !StringUtils.equals(resourcePathTokens[resourcePathTokens.length - 1], BlogPostsResourceImpl.DISPLAY_NAME)) { Space space = spaceManager.getSpace(resourcePathTokens[2]); return null != space && null == pageManager.getPage(space.getKey(), resourcePathTokens[3]) && null != attachmentManager.getAttachment(space.getDescription(), resourcePathTokens[3]); } return false; } }
ConfluenceEntityObject page = findEntityForWikiLink( spaceKey, pageTitle, addPart( processed, LinkPart.ATTACHMENT_NAME ) ); if ( page instanceof ContentEntityObject ) { content = attachmentManager.getAttachment( (ContentEntityObject) page, attachmentName );
public void execute() throws Exception { Page page = pageManager.getPage(getContainingPageId()); if (null != page) { Attachment attachment = attachmentManager.getAttachment(page, getFileName()); if (null != attachment) attachmentManager.removeAttachmentFromServer(attachment); } }
public static void addOrUpdateAttachment(AttachmentManager attachmentManager, ContentEntityObject ceo, String fileName, InputContext inputContext) throws IOException, CloneNotSupportedException { Attachment attachment = attachmentManager.getAttachment(ceo, fileName); Attachment previousVersionOfAttachment = null; File inputContentFile = null;
private DataHandler createAvatarDataHandler(User user) throws MessagingException, IOException { PropertySet propertySet = userAccessor.getPropertySet(user); if (propertySet == null) return createWebResourceDataHandler(ProfilePictureInfo.DEFAULT_PROFILE_PATH); String profilePicture = propertySet.getString(UserPreferencesKeys.PROPERTY_USER_PROFILE_PICTURE); if (profilePicture == null) { return createWebResourceDataHandler(ProfilePictureInfo.DEFAULT_PROFILE_PATH); } if (profilePicture.startsWith(UserAccessor.PROFILE_PICTURE_BUILTIN_PATH)) { return createWebResourceDataHandler(profilePicture); } PersonalInformation personalInformation = personalInformationManager.getPersonalInformation(user); if (personalInformation == null) return createWebResourceDataHandler(ProfilePictureInfo.DEFAULT_PROFILE_PATH); Attachment a = attachmentManager.getAttachment(personalInformation, profilePicture); if (a != null) { return new DataHandler(new ProfileImageDataSource(new ByteArrayDataSource(a.getContentsAsStream(), a.getContentType()))); } return null; }
resourceStates.unhideAttachment(attachmentManager.getAttachment(thisPage, resourceName)); } else { throw new DavException(HttpServletResponse.SC_FORBIDDEN, "Attachment creation denied. File name contains invalid characters ['&', '+', '?', '|', '=']: " + resourceName);
public void removeMember(DavResource davResource) throws DavException { String[] pathComponents = StringUtils.split(davResource.getResourcePath(), '/'); String resourceName = pathComponents[pathComponents.length - 1]; Space thisSpace = getSpace(); User user = AuthenticatedUserThreadLocal.getUser(); if (isResourceSpaceDescription(thisSpace, resourceName)) { if (permissionManager.hasPermission(user, Permission.EDIT, thisSpace)) ((ConfluenceDavSession) getSession()).getResourceStates().hideSpaceDescription(thisSpace); else throw new DavException(HttpServletResponse.SC_FORBIDDEN, "No permission to edit " + thisSpace); } else { Page pageToRemove = pageManager.getPage(thisSpace.getKey(), resourceName); if (null == pageToRemove) { ContentEntityObject spaceDesc = getSpace().getDescription(); Attachment attachmentToRemove = attachmentManager.getAttachment(spaceDesc, resourceName); if (null != attachmentToRemove) { attachmentManager.removeAttachmentFromServer(attachmentToRemove); } } else { if (permissionManager.hasPermission( AuthenticatedUserThreadLocal.getUser(), Permission.REMOVE, pageToRemove)) { pageManager.trashPage(pageToRemove); } else { throw new DavException(HttpServletResponse.SC_FORBIDDEN, "Forbidden to delete " + pageToRemove); } } } }