private String generatePathForAttachment(Resource child, Resource parent) throws EndpointNotFoundException { Attachment attachment=parent.findAttachment(child.id()); if(attachment==null) { return null; } Endpoint endpoint=getResourceEndpoint(parent.id()); ResourceTemplate parentTemplate=this.templateManagementService.templateOfId(parent.id().templateId()); AttachedTemplate attachedTemplate = parentTemplate.attachedTemplate(attachment.id()); return PathBuilder. create(). addSegment(endpoint.path()). addSegment(attachedTemplate.path()). addSegment(attachment.version()>0?attachment.version():null). build(); }