【发布时间】:2014-08-18 21:51:53
【问题描述】:
我们的老板想要使用 OpenNTF 中的 FileExplorer 小部件,以便他们可以将电子邮件拖到文件系统以便与他人共享。他们已经在不同的系统中拥有此类消息的宝库,因此使用共享的 Notes 邮件文件被确定为不可接受的解决方案。他们喜欢 FileExplorer,但对使用主题行命名的电子邮件感到失望。他们已经要求一个 mod 在文件名前加上 FROM 和 DATE 值。
我已经编写了一个修改以在 CopyFileJob.java 文件中使用,并认为 CopyFilesJob 类的复制方法中的以下行将处理重命名。
if (source.isFile()) {
// only check about modifying filename if it's a file to copy
final File dest = new File(fDest.getAbsolutePath() + File.separator + modifyEmailFilename(source.getName()));
...
它调用的代码比较简单,因为电子邮件文件是格式化的文本。
public static String modifyEmailFilename( String filename ) {
try {
int extensionCheck = filename.indexOf(".eml");
if ( extensionCheck >= 0 ) {
String fromResult = "";
String dateResult = "";
String fromString = "From:";
String dateString = "Date:";
Scanner sc = new Scanner (new File (filename));
while (sc.hasNextLine()) {
String nextLine = sc.nextLine();
int searchIndex = nextLine.indexOf(fromString);
if ( searchIndex == 0 ) {
int startIndex = nextLine.indexOf(":") + 2;
int endIndex = nextLine.indexOf("@");
fromResult = nextLine.toString().substring(startIndex,endIndex);
}
searchIndex = nextLine.indexOf(dateString);
if ( searchIndex == 0 ) {
int startIndex = nextLine.indexOf(",") + 2;
int endIndex = nextLine.lastIndexOf(" ");
dateResult = nextLine.toString().substring(startIndex,endIndex).replace(" ","_").replace(":","");
}
}
return fromResult + "_" + dateResult + "_" + filename;
}
// when eml is not in the filename, just return the filename
return filename;
} catch (Exception e) {
System.out.println("Error: " + e.getMessage() );
return "Error";
}
return "Finished";
}
我不知道如何重新编译它以实现我的自定义代码并部署它。当然,我没能就地测试它,因为当 OpenNTF 项目有很多组件时,我无法弄清楚编译它的步骤。
【问题讨论】:
标签: java eclipse plugins eclipse-plugin lotus-notes