From d4dc1ec93c57d459d65e072db89b2053cc3dfba2 Mon Sep 17 00:00:00 2001 From: georgweiss Date: Mon, 27 Apr 2026 13:37:16 +0200 Subject: [PATCH 1/2] Fix missin screenshots from log created from OPIs --- .../java/org/phoebus/elog/api/ElogClient.java | 541 +++++++++--------- .../olog/ui/menu/SendLogbookAction.java | 12 +- .../org/phoebus/logbook/AttachmentImpl.java | 42 +- 3 files changed, 292 insertions(+), 303 deletions(-) diff --git a/app/logbook/elog/src/main/java/org/phoebus/elog/api/ElogClient.java b/app/logbook/elog/src/main/java/org/phoebus/elog/api/ElogClient.java index 22c0595146..601f458b8c 100644 --- a/app/logbook/elog/src/main/java/org/phoebus/elog/api/ElogClient.java +++ b/app/logbook/elog/src/main/java/org/phoebus/elog/api/ElogClient.java @@ -1,11 +1,20 @@ package org.phoebus.elog.api; -import org.phoebus.logbook.*; +import org.phoebus.logbook.Attachment; +import org.phoebus.logbook.AttachmentImpl; +import org.phoebus.logbook.LogClient; +import org.phoebus.logbook.LogEntry; +import org.phoebus.logbook.LogEntryImpl; import org.phoebus.logbook.LogEntryImpl.LogEntryBuilder; +import org.phoebus.logbook.Logbook; +import org.phoebus.logbook.LogbookException; +import org.phoebus.logbook.LogbookImpl; +import org.phoebus.logbook.SearchResult; +import org.phoebus.logbook.Tag; +import org.phoebus.logbook.TagImpl; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.InputStream; import java.net.FileNameMap; import java.net.URI; @@ -15,7 +24,12 @@ import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; import java.util.logging.Logger; /** @@ -25,7 +39,7 @@ * @author kingspride * */ -public class ElogClient implements LogClient{ +public class ElogClient implements LogClient { private final ElogApi service; private final Collection categories; private final Collection types; @@ -47,7 +61,7 @@ public static class ElogClientBuilder { private final ElogProperties properties = new ElogProperties(); private ElogClientBuilder() { - this.elogURI = URI.create( this.properties.getPreferenceValue("elog_url") ); + this.elogURI = URI.create(this.properties.getPreferenceValue("elog_url")); } /** @@ -82,13 +96,13 @@ public ElogClientBuilder password(String password) { for (int i = 0; i < password.length(); i++) { ch[i] = password.charAt(i); } - this.password = Sha256.sha256( ch, 5000 ); + this.password = Sha256.sha256(ch, 5000); return this; } /** * Create new instance of ElogClient - * + * * @return {@link ElogClient} */ public ElogClient create() { @@ -97,23 +111,23 @@ public ElogClient create() { List types = null; String types_prop = this.properties.getPreferenceValue("types"); - if( !types_prop.isEmpty() ) { + if (!types_prop.isEmpty()) { types = new ArrayList<>(); - for( String s: types_prop.split("\\s*,\\s*") ){ - types.add( LogbookImpl.of( s ) ); + for (String s : types_prop.split("\\s*,\\s*")) { + types.add(LogbookImpl.of(s)); } } List categories = null; String categories_prop = this.properties.getPreferenceValue("categories"); - if( !categories_prop.isEmpty() ) { + if (!categories_prop.isEmpty()) { categories = new ArrayList<>(); - for( String s: categories_prop.split("\\s*,\\s*") ){ - categories.add( TagImpl.of( s ) ); + for (String s : categories_prop.split("\\s*,\\s*")) { + categories.add(TagImpl.of(s)); } } - ElogApi service = new ElogApi( this.elogURI, this.username, this.password ); - return new ElogClient( service, categories, types ); + ElogApi service = new ElogApi(this.elogURI, this.username, this.password); + return new ElogClient(service, categories, types); } @@ -127,27 +141,27 @@ private String ifNullReturnPreferenceValue(String value, String key) { } - private ElogClient( ElogApi service, Collection categories, Collection types ) { + private ElogClient(ElogApi service, Collection categories, Collection types) { this.service = service; - if( types == null ) { + if (types == null) { this.types = new ArrayList<>(); try { - for( String t : service.getTypes() ) { - this.types.add( LogbookImpl.of( t )); + for (String t : service.getTypes()) { + this.types.add(LogbookImpl.of(t)); } - } catch(LogbookException e){ + } catch (LogbookException e) { e.printStackTrace(); } } else { this.types = types; } - if( categories == null ) { + if (categories == null) { this.categories = new ArrayList<>(); try { - for( String c : service.getCategories() ) { - this.categories.add( TagImpl.of( c )); + for (String c : service.getCategories()) { + this.categories.add(TagImpl.of(c)); } - } catch(LogbookException e){ + } catch (LogbookException e) { e.printStackTrace(); } } else { @@ -160,38 +174,38 @@ private ElogClient( ElogApi service, Collection categories, Collection attributes = new HashMap<>(); - for( Logbook l: log.getLogbooks() ) { - if( !l.getName().isEmpty() ) { - attributes.put( "Type", l.getName() ); + for (Logbook l : log.getLogbooks()) { + if (!l.getName().isEmpty()) { + attributes.put("Type", l.getName()); break; } } - if( !attributes.containsKey("Type") ) { - Logger.getLogger( ElogClient.class.getPackageName()).severe( "No valid type selected. Cannot submit log entry" ); + if (!attributes.containsKey("Type")) { + Logger.getLogger(ElogClient.class.getPackageName()).severe("No valid type selected. Cannot submit log entry"); return null; } - for( Tag t: log.getTags() ) { - if( !t.getName().isEmpty() ) { - attributes.put( "Category", t.getName() ); + for (Tag t : log.getTags()) { + if (!t.getName().isEmpty()) { + attributes.put("Category", t.getName()); break; } } - attributes.put( "Subject", log.getTitle() ); - attributes.put( "Text", log.getDescription() ); + attributes.put("Subject", log.getTitle()); + attributes.put("Text", log.getDescription()); List files = new ArrayList<>(); - for( Attachment att: log.getAttachments() ) { - files.add( att.getFile() ); + for (Attachment att : log.getAttachments()) { + files.add(att.getFile()); } - long msgId = service.post( attributes, files ); + long msgId = service.post(attributes, files); - LogEntryBuilder logBuilder = LogEntryImpl.LogEntryBuilder.log( log ); - logBuilder.id( msgId ); - logBuilder.createdDate( Instant.now() ); - logBuilder.modifiedDate( Instant.now() ); + LogEntryBuilder logBuilder = LogEntryImpl.LogEntryBuilder.log(log); + logBuilder.id(msgId); + logBuilder.createdDate(Instant.now()); + logBuilder.modifiedDate(Instant.now()); return logBuilder.build(); } @@ -199,43 +213,43 @@ public LogEntry set(LogEntry log) throws LogbookException { @Override public LogEntry getLog(Long logId) { ElogEntry entry = null; - try{ - entry = service.read( logId ); - } catch(LogbookException e){ + try { + entry = service.read(logId); + } catch (LogbookException e) { e.printStackTrace(); } LogEntryBuilder logBuilder = LogEntryImpl.LogEntryBuilder.log(); - logBuilder.id( logId ); - logBuilder.description( entry.getAttribute("Text") ); - logBuilder.title( entry.getAttribute("Subject") ); + logBuilder.id(logId); + logBuilder.description(entry.getAttribute("Text")); + logBuilder.title(entry.getAttribute("Subject")); try { LocalDateTime date = LocalDateTime.parse(entry.getAttribute("Date"), formatter); - logBuilder.createdDate( date.atZone(ZoneId.systemDefault()).toInstant() ); - logBuilder.modifiedDate( date.atZone(ZoneId.systemDefault()).toInstant() ); + logBuilder.createdDate(date.atZone(ZoneId.systemDefault()).toInstant()); + logBuilder.modifiedDate(date.atZone(ZoneId.systemDefault()).toInstant()); } catch (DateTimeParseException e) { e.printStackTrace(); return null; } - logBuilder.appendTag( TagImpl.of( entry.getAttribute("Category") )); - logBuilder.appendToLogbook( LogbookImpl.of( entry.getAttribute("Type") )); + logBuilder.appendTag(TagImpl.of(entry.getAttribute("Category"))); + logBuilder.appendToLogbook(LogbookImpl.of(entry.getAttribute("Type"))); - try{ - for( String s : entry.getAttachments() ) { + try { + for (String s : entry.getAttachments()) { String mimeType = fileNameMap.getContentTypeFor(s); - if( mimeType == null ) { - if( s.endsWith(".py") ){ - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), "text/x-python", false )); - } else if( s.endsWith(".pyc") ){ - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), "application/x-python-code", false )); + if (mimeType == null) { + if (s.endsWith(".py")) { + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), "text/x-python", false)); + } else if (s.endsWith(".pyc")) { + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), "application/x-python-code", false)); } else { - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), "unknown", false )); + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), "unknown", false)); } } else { - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), mimeType, false )); + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), mimeType, false)); } } - } catch(LogbookException | FileNotFoundException e){ + } catch (LogbookException e) { e.printStackTrace(); } @@ -246,23 +260,23 @@ public LogEntry getLog(Long logId) { @Override public Collection listAttachments(Long logId) { List attlist = new ArrayList<>(); - try{ - ElogEntry entry = service.read( logId ); - for( String s : entry.getAttachments() ) { + try { + ElogEntry entry = service.read(logId); + for (String s : entry.getAttachments()) { String mimeType = fileNameMap.getContentTypeFor(s); - if( mimeType == null ) { - if( s.endsWith(".py") ){ - attlist.add( AttachmentImpl.of( service.getAttachment(s), "text/x-python", false )); - } else if( s.endsWith(".pyc") ){ - attlist.add( AttachmentImpl.of( service.getAttachment(s), "application/x-python-code", false )); + if (mimeType == null) { + if (s.endsWith(".py")) { + attlist.add(AttachmentImpl.of(service.getAttachment(s), "text/x-python", false)); + } else if (s.endsWith(".pyc")) { + attlist.add(AttachmentImpl.of(service.getAttachment(s), "application/x-python-code", false)); } else { - attlist.add( AttachmentImpl.of( service.getAttachment(s), "unknown", false )); + attlist.add(AttachmentImpl.of(service.getAttachment(s), "unknown", false)); } } else { - attlist.add( AttachmentImpl.of( service.getAttachment(s), mimeType, false )); + attlist.add(AttachmentImpl.of(service.getAttachment(s), mimeType, false)); } } - } catch(LogbookException | FileNotFoundException e){ + } catch (LogbookException e) { e.printStackTrace(); } return attlist; @@ -279,58 +293,58 @@ public SearchResult findLogsWithPagination(Map map) { Map query = new HashMap<>(map); DateTimeFormatter simple_datetime_formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS", Locale.ENGLISH); - if( query.containsKey( "start" ) ) { + if (query.containsKey("start")) { try { - LocalDateTime date = LocalDateTime.parse(map.get( "start" ), simple_datetime_formatter); - query.put("ma", String.valueOf( date.getMonthValue() )); + LocalDateTime date = LocalDateTime.parse(map.get("start"), simple_datetime_formatter); + query.put("ma", String.valueOf(date.getMonthValue())); query.put("da", String.valueOf(date.getDayOfMonth())); - query.put("ya", String.valueOf( date.getYear() )); - query.put("ha", String.valueOf( date.getHour() )); - query.put("na", String.valueOf( date.getMinute() )); - query.put("ca", String.valueOf( date.getSecond() )); + query.put("ya", String.valueOf(date.getYear())); + query.put("ha", String.valueOf(date.getHour())); + query.put("na", String.valueOf(date.getMinute())); + query.put("ca", String.valueOf(date.getSecond())); } catch (DateTimeParseException e) { e.printStackTrace(); return null; } query.remove("start"); } - if( query.containsKey( "end" ) ) { + if (query.containsKey("end")) { try { - LocalDateTime date = LocalDateTime.parse(map.get( "end" ), simple_datetime_formatter); - query.put("mb", String.valueOf( date.getMonthValue() )); + LocalDateTime date = LocalDateTime.parse(map.get("end"), simple_datetime_formatter); + query.put("mb", String.valueOf(date.getMonthValue())); query.put("db", String.valueOf(date.getDayOfMonth())); - query.put("yb", String.valueOf( date.getYear() )); - query.put("hb", String.valueOf( date.getHour() )); - query.put("nb", String.valueOf( date.getMinute() )); - query.put("cb", String.valueOf( date.getSecond() )); + query.put("yb", String.valueOf(date.getYear())); + query.put("hb", String.valueOf(date.getHour())); + query.put("nb", String.valueOf(date.getMinute())); + query.put("cb", String.valueOf(date.getSecond())); } catch (DateTimeParseException e) { e.printStackTrace(); return null; } query.remove("end"); } - if( query.containsKey( "desc" ) ) { - String subtext = map.get( "desc" ); - if( !subtext.equals("*") ) { - query.put("subtext", subtext ); + if (query.containsKey("desc")) { + String subtext = map.get("desc"); + if (!subtext.equals("*")) { + query.put("subtext", subtext); } query.remove("desc"); } - if( query.containsKey( "logbook" ) ) { - String type = map.get( "logbook" ); - if( type.contains(",") ) { - query.put("Type", type.substring( 0, type.indexOf(",") ) ); + if (query.containsKey("logbook")) { + String type = map.get("logbook"); + if (type.contains(",")) { + query.put("Type", type.substring(0, type.indexOf(","))); } else { - query.put("Type", type ); + query.put("Type", type); } query.remove("logbook"); } - if( query.containsKey( "tag" ) ) { - String category = map.get( "tag" ); - if( category.contains(",") ) { - query.put("Category", category.substring( 0, category.indexOf(",") ) ); + if (query.containsKey("tag")) { + String category = map.get("tag"); + if (category.contains(",")) { + query.put("Category", category.substring(0, category.indexOf(","))); } else { - query.put("Category", category ); + query.put("Category", category); } query.remove("tag"); } @@ -338,7 +352,7 @@ public SearchResult findLogsWithPagination(Map map) { Integer from = null; Integer size = null; - if(map.containsKey("from")) { + if (map.containsKey("from")) { try { from = Integer.parseInt(map.get("from")); } catch (NumberFormatException e) { @@ -346,7 +360,7 @@ public SearchResult findLogsWithPagination(Map map) { } } - if(map.containsKey("size")) { + if (map.containsKey("size")) { try { size = Integer.parseInt(map.get("size")); } catch (NumberFormatException e) { @@ -357,45 +371,40 @@ public SearchResult findLogsWithPagination(Map map) { List entries = new ArrayList<>(); ElogSearchResult result = null; try { - result = service.search( query, from, size ); - for( ElogEntry entry : result.getLogs() ) { + result = service.search(query, from, size); + for (ElogEntry entry : result.getLogs()) { LogEntryBuilder logBuilder = LogEntryImpl.LogEntryBuilder.log(); - logBuilder.id( Long.valueOf( entry.getAttribute("$@MID@$") )); - logBuilder.description( entry.getAttribute("Text") ); - logBuilder.title( entry.getAttribute("Subject") ); + logBuilder.id(Long.valueOf(entry.getAttribute("$@MID@$"))); + logBuilder.description(entry.getAttribute("Text")); + logBuilder.title(entry.getAttribute("Subject")); try { LocalDateTime date = LocalDateTime.parse(entry.getAttribute("Date"), formatter); - logBuilder.createdDate( date.atZone(ZoneId.systemDefault()).toInstant() ); - logBuilder.modifiedDate( date.atZone(ZoneId.systemDefault()).toInstant() ); + logBuilder.createdDate(date.atZone(ZoneId.systemDefault()).toInstant()); + logBuilder.modifiedDate(date.atZone(ZoneId.systemDefault()).toInstant()); } catch (DateTimeParseException e) { e.printStackTrace(); return null; } - logBuilder.appendTag( TagImpl.of( entry.getAttribute("Category") )); - logBuilder.appendToLogbook( LogbookImpl.of( entry.getAttribute("Type") )); - - try { - for( String s : entry.getAttachments() ) { - String mimeType = fileNameMap.getContentTypeFor(s); - if( mimeType == null ) { - if( s.endsWith(".py") ){ - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), "text/x-python", false )); - } else if( s.endsWith(".pyc") ){ - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), "application/x-python-code", false )); - } else { - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), "unknown", false )); - } + logBuilder.appendTag(TagImpl.of(entry.getAttribute("Category"))); + logBuilder.appendToLogbook(LogbookImpl.of(entry.getAttribute("Type"))); + + for (String s : entry.getAttachments()) { + String mimeType = fileNameMap.getContentTypeFor(s); + if (mimeType == null) { + if (s.endsWith(".py")) { + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), "text/x-python", false)); + } else if (s.endsWith(".pyc")) { + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), "application/x-python-code", false)); } else { - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), mimeType, false )); + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), "unknown", false)); } + } else { + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), mimeType, false)); } - } catch(FileNotFoundException e){ - e.printStackTrace(); } - - entries.add( logBuilder.build() ); + entries.add(logBuilder.build()); } - } catch(LogbookException e){ + } catch (LogbookException e) { e.printStackTrace(); } return SearchResult.of(entries, result.getHitCount()); @@ -404,46 +413,41 @@ public SearchResult findLogsWithPagination(Map map) { @Override public Collection listLogs() { - List entries = new ArrayList<>(); - try{ - for( ElogEntry entry : service.getMessages() ) { + List entries = new ArrayList<>(); + try { + for (ElogEntry entry : service.getMessages()) { LogEntryBuilder logBuilder = LogEntryImpl.LogEntryBuilder.log(); - logBuilder.id( Long.valueOf( entry.getAttribute("$@MID@$") )); - logBuilder.description( entry.getAttribute("Text") ); - logBuilder.title( entry.getAttribute("Subject") ); + logBuilder.id(Long.valueOf(entry.getAttribute("$@MID@$"))); + logBuilder.description(entry.getAttribute("Text")); + logBuilder.title(entry.getAttribute("Subject")); try { LocalDateTime date = LocalDateTime.parse(entry.getAttribute("Date"), formatter); - logBuilder.createdDate( date.atZone(ZoneId.systemDefault()).toInstant() ); - logBuilder.modifiedDate( date.atZone(ZoneId.systemDefault()).toInstant() ); + logBuilder.createdDate(date.atZone(ZoneId.systemDefault()).toInstant()); + logBuilder.modifiedDate(date.atZone(ZoneId.systemDefault()).toInstant()); } catch (DateTimeParseException e) { e.printStackTrace(); return null; } - logBuilder.appendTag( TagImpl.of( entry.getAttribute("Category") )); - logBuilder.appendToLogbook( LogbookImpl.of( entry.getAttribute("Type") )); - - try{ - for( String s : entry.getAttachments() ) { - String mimeType = fileNameMap.getContentTypeFor(s); - if( mimeType == null ) { - if( s.endsWith(".py") ){ - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), "text/x-python", false )); - } else if( s.endsWith(".pyc") ){ - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), "application/x-python-code", false )); - } else { - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), "unknown", false )); - } + logBuilder.appendTag(TagImpl.of(entry.getAttribute("Category"))); + logBuilder.appendToLogbook(LogbookImpl.of(entry.getAttribute("Type"))); + + for (String s : entry.getAttachments()) { + String mimeType = fileNameMap.getContentTypeFor(s); + if (mimeType == null) { + if (s.endsWith(".py")) { + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), "text/x-python", false)); + } else if (s.endsWith(".pyc")) { + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), "application/x-python-code", false)); } else { - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), mimeType, false )); + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), "unknown", false)); } + } else { + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), mimeType, false)); } - } catch(FileNotFoundException e){ - e.printStackTrace(); } - - entries.add( logBuilder.build() ); + entries.add(logBuilder.build()); } - } catch(LogbookException e){ + } catch (LogbookException e) { e.printStackTrace(); } return entries; @@ -464,32 +468,32 @@ public Collection listTags() { @Override public InputStream getAttachment(Long logId, Attachment attachment) throws LogbookException { - return getAttachment( logId, attachment.getName() ); + return getAttachment(logId, attachment.getName()); } @Override public InputStream getAttachment(Long logId, String attachmentName) throws LogbookException { - ElogEntry entry = service.read( logId ); + ElogEntry entry = service.read(logId); try { - for( String s : entry.getAttachments() ) { - if( s.equals( attachmentName ) ) { - return new FileInputStream( service.getAttachment(s) ); + for (String s : entry.getAttachments()) { + if (s.equals(attachmentName)) { + return new FileInputStream(service.getAttachment(s)); } } - } catch( java.io.FileNotFoundException e ) { - throw new LogbookException( e.getMessage() ); + } catch (java.io.FileNotFoundException e) { + throw new LogbookException(e.getMessage()); } - throw new LogbookException( "Message " + logId + " has no matching attachment" ); + throw new LogbookException("Message " + logId + " has no matching attachment"); } @Override - public Tag set(Tag tag){ + public Tag set(Tag tag) { // there is no HTTP request to add new Categories to the Elog. // This can only be done by posting a new entry with a new Category value // This only works if "Extendable Options = Category" is set in Elog config - this.categories.add( tag ); + this.categories.add(tag); return tag; } @@ -499,7 +503,7 @@ public Logbook set(Logbook Logbook) { // there is no HTTP request to add new Types to the Elog. // This can only be done by posting a new entry with a new Type value // This only works if "Extendable Options = Type" is set in Elog config - this.types.add( Logbook ); + this.types.add(Logbook); return Logbook; } @@ -508,44 +512,44 @@ public Logbook set(Logbook Logbook) { public LogEntry update(LogEntry log) throws LogbookException { Map attributes = new HashMap<>(); - for( Logbook l: log.getLogbooks() ) { - if( !l.getName().isEmpty() ) { - attributes.put( "Type", l.getName() ); + for (Logbook l : log.getLogbooks()) { + if (!l.getName().isEmpty()) { + attributes.put("Type", l.getName()); break; } } - if( !attributes.containsKey("Type") ) { - Logger.getLogger( ElogClient.class.getPackageName()).severe( "No valid type selected. Cannot submit log entry" ); + if (!attributes.containsKey("Type")) { + Logger.getLogger(ElogClient.class.getPackageName()).severe("No valid type selected. Cannot submit log entry"); return null; } - for( Tag t: log.getTags() ) { - if( !t.getName().isEmpty() ) { - attributes.put( "Category", t.getName() ); + for (Tag t : log.getTags()) { + if (!t.getName().isEmpty()) { + attributes.put("Category", t.getName()); break; } } - attributes.put( "Subject", log.getTitle() ); - attributes.put( "Text", log.getDescription() ); + attributes.put("Subject", log.getTitle()); + attributes.put("Text", log.getDescription()); List files = new ArrayList<>(); - for( Attachment att: log.getAttachments() ) { - files.add( att.getFile() ); + for (Attachment att : log.getAttachments()) { + files.add(att.getFile()); } - long msgId = service.post( attributes, files, log.getId() ); + long msgId = service.post(attributes, files, log.getId()); - LogEntryBuilder logBuilder = LogEntryImpl.LogEntryBuilder.log( log ); - logBuilder.modifiedDate( Instant.now() ); + LogEntryBuilder logBuilder = LogEntryImpl.LogEntryBuilder.log(log); + logBuilder.modifiedDate(Instant.now()); return logBuilder.build(); } @Override public Collection update(Collection logs) throws LogbookException { List entries = new ArrayList<>(); - for( LogEntry entry : logs ) { - entries.add( this.update( entry )); + for (LogEntry entry : logs) { + entries.add(this.update(entry)); } return entries; } @@ -553,50 +557,46 @@ public Collection update(Collection logs) throws LogbookExce @Override public List findLogsBySearch(String pattern) { Map query = new HashMap<>(); - query.put( "subtext", pattern ); - query.put( "sall", "1" ); + query.put("subtext", pattern); + query.put("sall", "1"); List entries = new ArrayList<>(); - try{ - ElogSearchResult result = service.search( query, null, null ); - for( ElogEntry entry : result.getLogs() ) { + try { + ElogSearchResult result = service.search(query, null, null); + for (ElogEntry entry : result.getLogs()) { LogEntryBuilder logBuilder = LogEntryImpl.LogEntryBuilder.log(); - logBuilder.id( Long.valueOf( entry.getAttribute("$@MID@$") )); - logBuilder.description( entry.getAttribute("Text") ); - logBuilder.title( entry.getAttribute("Subject") ); + logBuilder.id(Long.valueOf(entry.getAttribute("$@MID@$"))); + logBuilder.description(entry.getAttribute("Text")); + logBuilder.title(entry.getAttribute("Subject")); try { LocalDateTime date = LocalDateTime.parse(entry.getAttribute("Date"), formatter); - logBuilder.createdDate( date.atZone(ZoneId.systemDefault()).toInstant() ); - logBuilder.modifiedDate( date.atZone(ZoneId.systemDefault()).toInstant() ); + logBuilder.createdDate(date.atZone(ZoneId.systemDefault()).toInstant()); + logBuilder.modifiedDate(date.atZone(ZoneId.systemDefault()).toInstant()); } catch (DateTimeParseException e) { e.printStackTrace(); return null; } - logBuilder.appendTag( TagImpl.of( entry.getAttribute("Category") )); - logBuilder.appendToLogbook( LogbookImpl.of( entry.getAttribute("Type") )); - - try{ - for( String s : entry.getAttachments() ) { - String mimeType = fileNameMap.getContentTypeFor(s); - if( mimeType == null ) { - if( s.endsWith(".py") ){ - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), "text/x-python", false )); - } else if( s.endsWith(".pyc") ){ - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), "application/x-python-code", false )); - } else { - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), "unknown", false )); - } + logBuilder.appendTag(TagImpl.of(entry.getAttribute("Category"))); + logBuilder.appendToLogbook(LogbookImpl.of(entry.getAttribute("Type"))); + + for (String s : entry.getAttachments()) { + String mimeType = fileNameMap.getContentTypeFor(s); + if (mimeType == null) { + if (s.endsWith(".py")) { + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), "text/x-python", false)); + } else if (s.endsWith(".pyc")) { + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), "application/x-python-code", false)); } else { - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), mimeType, false )); + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), "unknown", false)); } + } else { + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), mimeType, false)); } - } catch(FileNotFoundException e){ - e.printStackTrace(); } - entries.add( logBuilder.build() ); + entries.add(logBuilder.build()); } - } catch(LogbookException e){ + } catch (LogbookException e) { e.printStackTrace(); } return entries; @@ -606,49 +606,44 @@ public List findLogsBySearch(String pattern) { @Override public List findLogsByTag(String pattern) { Map query = new HashMap<>(); - query.put( "Category", pattern ); + query.put("Category", pattern); List entries = new ArrayList<>(); - try{ - ElogSearchResult result = service.search( query, null, null ); - for( ElogEntry entry : result.getLogs() ) { + try { + ElogSearchResult result = service.search(query, null, null); + for (ElogEntry entry : result.getLogs()) { LogEntryBuilder logBuilder = LogEntryImpl.LogEntryBuilder.log(); - logBuilder.id( Long.valueOf( entry.getAttribute("$@MID@$") )); - logBuilder.description( entry.getAttribute("Text") ); - logBuilder.title( entry.getAttribute("Subject") ); + logBuilder.id(Long.valueOf(entry.getAttribute("$@MID@$"))); + logBuilder.description(entry.getAttribute("Text")); + logBuilder.title(entry.getAttribute("Subject")); try { LocalDateTime date = LocalDateTime.parse(entry.getAttribute("Date"), formatter); - logBuilder.createdDate( date.atZone(ZoneId.systemDefault()).toInstant() ); - logBuilder.modifiedDate( date.atZone(ZoneId.systemDefault()).toInstant() ); + logBuilder.createdDate(date.atZone(ZoneId.systemDefault()).toInstant()); + logBuilder.modifiedDate(date.atZone(ZoneId.systemDefault()).toInstant()); } catch (DateTimeParseException e) { e.printStackTrace(); return null; } - logBuilder.appendTag( TagImpl.of( entry.getAttribute("Category") )); - logBuilder.appendToLogbook( LogbookImpl.of( entry.getAttribute("Type") )); - - try{ - for( String s : entry.getAttachments() ) { - String mimeType = fileNameMap.getContentTypeFor(s); - if( mimeType == null ) { - if( s.endsWith(".py") ){ - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), "text/x-python", false )); - } else if( s.endsWith(".pyc") ){ - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), "application/x-python-code", false )); - } else { - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), "unknown", false )); - } + logBuilder.appendTag(TagImpl.of(entry.getAttribute("Category"))); + logBuilder.appendToLogbook(LogbookImpl.of(entry.getAttribute("Type"))); + + for (String s : entry.getAttachments()) { + String mimeType = fileNameMap.getContentTypeFor(s); + if (mimeType == null) { + if (s.endsWith(".py")) { + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), "text/x-python", false)); + } else if (s.endsWith(".pyc")) { + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), "application/x-python-code", false)); } else { - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), mimeType, false )); + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), "unknown", false)); } + } else { + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), mimeType, false)); } - } catch(FileNotFoundException e){ - e.printStackTrace(); } - - entries.add( logBuilder.build() ); + entries.add(logBuilder.build()); } - } catch(LogbookException e){ + } catch (LogbookException e) { e.printStackTrace(); } return entries; @@ -658,49 +653,45 @@ public List findLogsByTag(String pattern) { @Override public List findLogsByLogbook(String logbook) { Map query = new HashMap<>(); - query.put( "Type", logbook ); + query.put("Type", logbook); List entries = new ArrayList<>(); - try{ - ElogSearchResult result = service.search( query, null, null ); - for( ElogEntry entry : result.getLogs() ) { + try { + ElogSearchResult result = service.search(query, null, null); + for (ElogEntry entry : result.getLogs()) { LogEntryBuilder logBuilder = LogEntryImpl.LogEntryBuilder.log(); - logBuilder.id( Long.valueOf( entry.getAttribute("$@MID@$") )); - logBuilder.description( entry.getAttribute("Text") ); - logBuilder.title( entry.getAttribute("Subject") ); + logBuilder.id(Long.valueOf(entry.getAttribute("$@MID@$"))); + logBuilder.description(entry.getAttribute("Text")); + logBuilder.title(entry.getAttribute("Subject")); try { LocalDateTime date = LocalDateTime.parse(entry.getAttribute("Date"), formatter); - logBuilder.createdDate( date.atZone(ZoneId.systemDefault()).toInstant() ); - logBuilder.modifiedDate( date.atZone(ZoneId.systemDefault()).toInstant() ); + logBuilder.createdDate(date.atZone(ZoneId.systemDefault()).toInstant()); + logBuilder.modifiedDate(date.atZone(ZoneId.systemDefault()).toInstant()); } catch (DateTimeParseException e) { e.printStackTrace(); return null; } - logBuilder.appendTag( TagImpl.of( entry.getAttribute("Category") )); - logBuilder.appendToLogbook( LogbookImpl.of( entry.getAttribute("Type") )); - - try{ - for( String s : entry.getAttachments() ) { - String mimeType = fileNameMap.getContentTypeFor(s); - if( mimeType == null ) { - if( s.endsWith(".py") ){ - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), "text/x-python", false )); - } else if( s.endsWith(".pyc") ){ - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), "application/x-python-code", false )); - } else { - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), "unknown", false )); - } + logBuilder.appendTag(TagImpl.of(entry.getAttribute("Category"))); + logBuilder.appendToLogbook(LogbookImpl.of(entry.getAttribute("Type"))); + + for (String s : entry.getAttachments()) { + String mimeType = fileNameMap.getContentTypeFor(s); + if (mimeType == null) { + if (s.endsWith(".py")) { + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), "text/x-python", false)); + } else if (s.endsWith(".pyc")) { + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), "application/x-python-code", false)); } else { - logBuilder.attach( AttachmentImpl.of( service.getAttachment(s), mimeType, false )); + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), "unknown", false)); } + } else { + logBuilder.attach(AttachmentImpl.of(service.getAttachment(s), mimeType, false)); } - } catch(FileNotFoundException e){ - e.printStackTrace(); } - entries.add( logBuilder.build() ); + entries.add(logBuilder.build()); } - } catch(LogbookException e){ + } catch (LogbookException e) { e.printStackTrace(); } return entries; @@ -709,20 +700,20 @@ public List findLogsByLogbook(String logbook) { @Override public void delete(LogEntry log) throws LogbookException { - service.delete( log.getId() ); + service.delete(log.getId()); } @Override public void delete(Long logId) throws LogbookException { - service.delete( logId ); + service.delete(logId); } @Override public void delete(Collection logIds) throws LogbookException { - for( LogEntry entry : logIds ) { - service.delete( entry.getId() ); + for (LogEntry entry : logIds) { + service.delete(entry.getId()); } } diff --git a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/menu/SendLogbookAction.java b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/menu/SendLogbookAction.java index 92fe06fa35..98818193b8 100644 --- a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/menu/SendLogbookAction.java +++ b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/menu/SendLogbookAction.java @@ -78,14 +78,10 @@ private void submitLogEntry(final String title, final String body, final File im ologLog.setDescription(body != null ? body : ""); if (image_file != null) { - try { - final Attachment attachment = AttachmentImpl.of(image_file, "image", false); - List attachments = new ArrayList<>(); - attachments.add(attachment); - ologLog.setAttachments(attachments); - } catch (FileNotFoundException ex) { - logger.log(Level.WARNING, "Cannot attach " + image_file, ex); - } + final Attachment attachment = AttachmentImpl.of(image_file, "image", false); + List attachments = new ArrayList<>(); + attachments.add(attachment); + ologLog.setAttachments(attachments); } new LogEntryEditorStage(ologLog).show(); } diff --git a/core/logbook/src/main/java/org/phoebus/logbook/AttachmentImpl.java b/core/logbook/src/main/java/org/phoebus/logbook/AttachmentImpl.java index a41f10bd91..cf2c090a86 100644 --- a/core/logbook/src/main/java/org/phoebus/logbook/AttachmentImpl.java +++ b/core/logbook/src/main/java/org/phoebus/logbook/AttachmentImpl.java @@ -1,13 +1,12 @@ package org.phoebus.logbook; import java.io.File; -import java.io.FileNotFoundException; import java.net.FileNameMap; import java.net.URLConnection; - /** * A default implementation of {@link Attachment} + * * @author Kunal Shroff * */ @@ -17,10 +16,9 @@ public class AttachmentImpl implements Attachment { private final Boolean thumbnail; private String id; - private static FileNameMap fileNameMap = URLConnection.getFileNameMap(); + private static final FileNameMap fileNameMap = URLConnection.getFileNameMap(); private AttachmentImpl(File file, String contentType, Boolean thumbnail) { - super(); this.file = file; this.contentType = contentType; this.thumbnail = thumbnail; @@ -47,51 +45,55 @@ public String getName() { } @Override - public String getId(){ + public String getId() { return id; } @Override - public void setId(String id){ + public void setId(String id) { this.id = id; } + @Override + public String getUniqueFilename() { + return getName(); + } + /** * Create a new instance of a default implementation of the {@link Attachment} interface using the given file + * * @param file - the attachment file * @return a {@link Attachment} based on the given file - * @throws FileNotFoundException */ - public static Attachment of(File file) throws FileNotFoundException { + public static Attachment of(File file) { String mimeType = fileNameMap.getContentTypeFor(file.getName()); return new AttachmentImpl(file, mimeType, null); } - + /** * Create a new instance of a default implementation of the {@link Attachment} interface using the given file - * @param file - the attachment file + * + * @param file - the attachment file * @param contentType - the type of the attached content ("image", "file", etc...) - * @param thumbnail - Whether the attachment has a thumbnail. + * @param thumbnail - Whether the attachment has a thumbnail. * @return a {@link Attachment} based on the given file - * @throws FileNotFoundException */ - public static Attachment of(File file, String contentType, boolean thumbnail) throws FileNotFoundException { + public static Attachment of(File file, String contentType, boolean thumbnail) { return new AttachmentImpl(file, contentType, thumbnail); } /** * Create a new instance of a default implementation of the {@link Attachment} interface using the given file - * @param id A unique id - * @param file - the attachment file + * + * @param id A unique id + * @param file - the attachment file * @param contentType - the type of the attached content ("image", "file", etc...) - * @param thumbnail - Whether the attachment has a thumbnail. + * @param thumbnail - Whether the attachment has a thumbnail. * @return a {@link Attachment} based on the given file - * @throws FileNotFoundException */ - public static Attachment of(String id, File file, String contentType, boolean thumbnail) throws FileNotFoundException { + public static Attachment of(String id, File file, String contentType, boolean thumbnail) { AttachmentImpl attachment = new AttachmentImpl(file, contentType, thumbnail); attachment.setId(id); - return attachment; + return attachment; } - } From e496ca74204d2d2e89386fd4a57666fa2486259c Mon Sep 17 00:00:00 2001 From: georgweiss Date: Mon, 27 Apr 2026 14:06:22 +0200 Subject: [PATCH 2/2] FIx build issues due to removed throws clause --- .../phoebus/logbook/olog/ui/LogEntryCalenderDemo.java | 6 +----- .../org/phoebus/logbook/olog/ui/LogEntryCellDemo.java | 6 +----- .../phoebus/logbook/olog/ui/LogEntrySearchDemo.java | 6 +----- .../phoebus/logbook/olog/ui/LogEntryTableDemo.java | 6 +----- .../phoebus/logbook/ui/menu/SendLogbookAction.java | 11 ++--------- .../org/phoebus/logbook/ui/LogEntryCalenderDemo.java | 6 +----- .../org/phoebus/logbook/ui/LogEntryDisplayDemo.java | 6 +----- .../org/phoebus/logbook/ui/LogEntrySearchDemo.java | 6 +----- .../org/phoebus/logbook/ui/LogEntryTableDemo.java | 6 +----- 9 files changed, 10 insertions(+), 49 deletions(-) diff --git a/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/LogEntryCalenderDemo.java b/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/LogEntryCalenderDemo.java index bd4200e0d4..7c54848daf 100644 --- a/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/LogEntryCalenderDemo.java +++ b/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/LogEntryCalenderDemo.java @@ -99,11 +99,7 @@ else if(clazz.isAssignableFrom(AdvancedSearchViewController.class)){ } lb.appendDescription(sb.toString()); listOfFiles.forEach(file -> { - try { - lb.attach(AttachmentImpl.of(file)); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } + lb.attach(AttachmentImpl.of(file)); }); logs.add(lb.build()); } diff --git a/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/LogEntryCellDemo.java b/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/LogEntryCellDemo.java index c15924074c..053f0dddcb 100644 --- a/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/LogEntryCellDemo.java +++ b/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/LogEntryCellDemo.java @@ -119,11 +119,7 @@ public void start(Stage primaryStage) throws Exception { .inLogbooks(new HashSet(Arrays.asList(LogbookImpl.of("Operations", "active"), LogbookImpl.of("Electrical", "active")))) .owner("nsls2-user"); listOfFiles.forEach(file -> { - try { - lb.attach(AttachmentImpl.of(file)); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } + lb.attach(AttachmentImpl.of(file)); }); controller.setLogEntry(new TableViewListItem(lb.build(), true)); }); diff --git a/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/LogEntrySearchDemo.java b/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/LogEntrySearchDemo.java index 0c2ff379a0..3f892c5948 100644 --- a/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/LogEntrySearchDemo.java +++ b/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/LogEntrySearchDemo.java @@ -117,11 +117,7 @@ public void start(Stage primaryStage) throws Exception { } lb.appendDescription(sb.toString()); listOfFiles.forEach(file -> { - try { - lb.attach(AttachmentImpl.of(file)); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } + lb.attach(AttachmentImpl.of(file)); }); logs.add(lb.build()); } diff --git a/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/LogEntryTableDemo.java b/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/LogEntryTableDemo.java index c502af8314..7f04f9bed9 100644 --- a/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/LogEntryTableDemo.java +++ b/app/logbook/olog/ui/src/test/java/org/phoebus/logbook/olog/ui/LogEntryTableDemo.java @@ -135,11 +135,7 @@ public void start(Stage primaryStage) throws Exception { lb.appendDescription(sb.toString()); if (i % 2 != 0) { listOfFiles.forEach(file -> { - try { - lb.attach(AttachmentImpl.of(file)); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } + lb.attach(AttachmentImpl.of(file)); }); lb.appendProperty(experimentProperty); lb.appendProperty(track); diff --git a/app/logbook/ui/src/main/java/org/phoebus/logbook/ui/menu/SendLogbookAction.java b/app/logbook/ui/src/main/java/org/phoebus/logbook/ui/menu/SendLogbookAction.java index 1e225a84c6..6d7f5bd5df 100644 --- a/app/logbook/ui/src/main/java/org/phoebus/logbook/ui/menu/SendLogbookAction.java +++ b/app/logbook/ui/src/main/java/org/phoebus/logbook/ui/menu/SendLogbookAction.java @@ -95,15 +95,8 @@ private void submitLogEntry(final Node parent, final String title, final String if (image_file != null) { - try - { - final Attachment attachment = AttachmentImpl.of(image_file, "image", false); - logEntryBuilder.attach(attachment); - } - catch (FileNotFoundException ex) - { - logger.log(Level.WARNING, "Cannot attach " + image_file, ex); - } + final Attachment attachment = AttachmentImpl.of(image_file, "image", false); + logEntryBuilder.attach(attachment); } final LogEntryModel model = new LogEntryModel(logEntryBuilder.createdDate(Instant.now()).build()); diff --git a/app/logbook/ui/src/test/java/org/phoebus/logbook/ui/LogEntryCalenderDemo.java b/app/logbook/ui/src/test/java/org/phoebus/logbook/ui/LogEntryCalenderDemo.java index f6248da44d..a5087b1ba8 100644 --- a/app/logbook/ui/src/test/java/org/phoebus/logbook/ui/LogEntryCalenderDemo.java +++ b/app/logbook/ui/src/test/java/org/phoebus/logbook/ui/LogEntryCalenderDemo.java @@ -92,11 +92,7 @@ else if(clazz.isAssignableFrom(AdvancedSearchViewController.class)){ } lb.appendDescription(sb.toString()); listOfFiles.forEach(file -> { - try { - lb.attach(AttachmentImpl.of(file)); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } + lb.attach(AttachmentImpl.of(file)); }); logs.add(lb.build()); } diff --git a/app/logbook/ui/src/test/java/org/phoebus/logbook/ui/LogEntryDisplayDemo.java b/app/logbook/ui/src/test/java/org/phoebus/logbook/ui/LogEntryDisplayDemo.java index 8d426d98d3..70725051e5 100644 --- a/app/logbook/ui/src/test/java/org/phoebus/logbook/ui/LogEntryDisplayDemo.java +++ b/app/logbook/ui/src/test/java/org/phoebus/logbook/ui/LogEntryDisplayDemo.java @@ -98,11 +98,7 @@ public void start(Stage primaryStage) throws Exception { .withTags(new HashSet(Arrays.asList(TagImpl.of("Orbit", "active"), TagImpl.of("Studies", "active")))) .inLogbooks(new HashSet(Arrays.asList(LogbookImpl.of("Operations", "active")))); listOfFiles.forEach(file -> { - try { - lb.attach(AttachmentImpl.of(file)); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } + lb.attach(AttachmentImpl.of(file)); }); controller.setLogEntry(lb.build()); }); diff --git a/app/logbook/ui/src/test/java/org/phoebus/logbook/ui/LogEntrySearchDemo.java b/app/logbook/ui/src/test/java/org/phoebus/logbook/ui/LogEntrySearchDemo.java index 46b6e7c4e4..eff4b886f0 100644 --- a/app/logbook/ui/src/test/java/org/phoebus/logbook/ui/LogEntrySearchDemo.java +++ b/app/logbook/ui/src/test/java/org/phoebus/logbook/ui/LogEntrySearchDemo.java @@ -92,11 +92,7 @@ else if(clazz.isAssignableFrom(AdvancedSearchViewController.class)){ } lb.appendDescription(sb.toString()); listOfFiles.forEach(file -> { - try { - lb.attach(AttachmentImpl.of(file)); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } + lb.attach(AttachmentImpl.of(file)); }); logs.add(lb.build()); } diff --git a/app/logbook/ui/src/test/java/org/phoebus/logbook/ui/LogEntryTableDemo.java b/app/logbook/ui/src/test/java/org/phoebus/logbook/ui/LogEntryTableDemo.java index cbe7f4bd48..da9ac13cbf 100644 --- a/app/logbook/ui/src/test/java/org/phoebus/logbook/ui/LogEntryTableDemo.java +++ b/app/logbook/ui/src/test/java/org/phoebus/logbook/ui/LogEntryTableDemo.java @@ -93,11 +93,7 @@ else if(clazz.isAssignableFrom(AdvancedSearchViewController.class)){ } lb.appendDescription(sb.toString()); listOfFiles.forEach(file -> { - try { - lb.attach(AttachmentImpl.of(file)); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } + lb.attach(AttachmentImpl.of(file)); }); logs.add(lb.build());