@Test public final void testSubmitToArchive() throws Exception { String targetInstanceOid = "12345"; String SIP = ""; Map xAttributes = null; ArrayList<ArchiveFile> fileList = new ArrayList<ArchiveFile>(); for (File f : getLogFiles()) { fileList.add(new ArchiveFile(f, LOG_FILE)); } for (File f : getReportFiles()) { if (f.getName().endsWith("order.xml")) { fileList.add(new ArchiveFile(f, ROOT_FILE)); } else { fileList.add(new ArchiveFile(f, REPORT_FILE)); } } for (File f : getARCFiles()) { fileList.add(new ArchiveFile(f, ARC_FILE)); } String archiveIID = testInstance.submitToArchive(targetInstanceOid, SIP, xAttributes, fileList); assertEquals(archiveIID, targetInstanceOid); checkReportFiles(); checkLogFiles(); checkArcFiles(); checkBaseFiles(); }
public String submitToArchive(String targetInstanceOID, String SIP, Map xAttributes, List<ArchiveFile> files) throws FileArchiveException{ if(targetInstanceOID != null){ File archiveRoot = null; try { archiveRoot = new File(archiveRepository,targetInstanceOID); for(ArchiveFile f : files){ File fileArchiveDirectory = archiveRoot; switch(f.getType()){ case LOG_FILE: fileArchiveDirectory = new File(archiveRoot,archiveLogDirectory);break; case REPORT_FILE: fileArchiveDirectory = new File(archiveRoot,archiveReportDirectory);break; case ARC_FILE: fileArchiveDirectory = new File(archiveRoot,archiveArcDirectory);break; } f.setMd5(FileUtil.moveFile(f.getFile(),fileArchiveDirectory,true)); } String finalSIP = getFinalSIP(SIP, targetInstanceOID, files); String metsFileName = "METS-"+targetInstanceOID+".xml"; archiveRoot = new File(archiveRepository,targetInstanceOID); File metsFile = new File(archiveRoot,metsFileName); BufferedWriter bw = new BufferedWriter(new FileWriter(metsFile)); bw.write(finalSIP); bw.close(); } catch (Exception e) { log.error("Archiving error",e); deleteCascade(archiveRoot); throw new FileArchiveException(e); } } return targetInstanceOID; }
FileArchive extends BaseArchive { public String submitToArchive(String targetInstanceOID, String SIP, Map xAttributes, List<ArchiveFile> files) throws FileArchiveException{ if(targetInstanceOID != null){ File archiveRoot = null; try { archiveRoot = new File(archiveRepository,targetInstanceOID); for(ArchiveFile f : files){ File fileArchiveDirectory = archiveRoot; switch(f.getType()){ case LOG_FILE: fileArchiveDirectory = new File(archiveRoot,archiveLogDirectory);break; case REPORT_FILE: fileArchiveDirectory = new File(archiveRoot,archiveReportDirectory);break; case ARC_FILE: fileArchiveDirectory = new File(archiveRoot,archiveArcDirectory);break; } f.setMd5(FileUtil.moveFile(f.getFile(),fileArchiveDirectory,true)); } String finalSIP = getFinalSIP(SIP, targetInstanceOID, files); String metsFileName = "METS-"+targetInstanceOID+".xml"; archiveRoot = new File(archiveRepository,targetInstanceOID); File metsFile = new File(archiveRoot,metsFileName); BufferedWriter bw = new BufferedWriter(new FileWriter(metsFile)); bw.write(finalSIP); bw.close(); } catch (Exception e) { log.error("Archiving error",e); deleteCascade(archiveRoot); throw new FileArchiveException(e); } } return targetInstanceOID; } }
FileArchive extends BaseArchive { public String submitToArchive(String targetInstanceOID, String SIP, Map xAttributes, List<ArchiveFile> files) throws FileArchiveException{ if(targetInstanceOID != null){ File archiveRoot = null; try { archiveRoot = new File(archiveRepository,targetInstanceOID); for(ArchiveFile f : files){ File fileArchiveDirectory = archiveRoot; switch(f.getType()){ case LOG_FILE: fileArchiveDirectory = new File(archiveRoot,archiveLogDirectory);break; case REPORT_FILE: fileArchiveDirectory = new File(archiveRoot,archiveReportDirectory);break; case ARC_FILE: fileArchiveDirectory = new File(archiveRoot,archiveArcDirectory);break; } f.setMd5(FileUtil.moveFile(f.getFile(),fileArchiveDirectory,true)); } String finalSIP = getFinalSIP(SIP, targetInstanceOID, files); String metsFileName = "METS-"+targetInstanceOID+".xml"; archiveRoot = new File(archiveRepository,targetInstanceOID); File metsFile = new File(archiveRoot,metsFileName); BufferedWriter bw = new BufferedWriter(new FileWriter(metsFile)); bw.write(finalSIP); bw.close(); } catch (Exception e) { log.error("Archiving error",e); deleteCascade(archiveRoot); throw new FileArchiveException(e); } } return targetInstanceOID; }  }
FileArchive extends BaseArchive { public String submitToArchive(String targetInstanceOID, String SIP, Map xAttributes, List<ArchiveFile> files) throws FileArchiveException{ if(targetInstanceOID != null){ File archiveRoot = null; try { archiveRoot = new File(archiveRepository,targetInstanceOID); for(ArchiveFile f : files){ File fileArchiveDirectory = archiveRoot; switch(f.getType()){ case LOG_FILE: fileArchiveDirectory = new File(archiveRoot,archiveLogDirectory);break; case REPORT_FILE: fileArchiveDirectory = new File(archiveRoot,archiveReportDirectory);break; case ARC_FILE: fileArchiveDirectory = new File(archiveRoot,archiveArcDirectory);break; } f.setMd5(FileUtil.moveFile(f.getFile(),fileArchiveDirectory,true)); } String finalSIP = getFinalSIP(SIP, targetInstanceOID, files); String metsFileName = "METS-"+targetInstanceOID+".xml"; archiveRoot = new File(archiveRepository,targetInstanceOID); File metsFile = new File(archiveRoot,metsFileName); BufferedWriter bw = new BufferedWriter(new FileWriter(metsFile)); bw.write(finalSIP); bw.close(); } catch (Exception e) { log.error("Archiving error",e); deleteCascade(archiveRoot); throw new FileArchiveException(e); } } return targetInstanceOID; }  String submitToArchive(String targetInstanceOID, String SIP, Map xAttributes, List<ArchiveFile> files); CustomDepositFormResultDTO getCustomDepositFormDetails(CustomDepositFormCriteriaDTO criteria); void setArchiveArcDirectory(String archiveArcDirectory); void setArchiveLogDirectory(String archiveLogDirectory); void setArchiveReportDirectory(String archiveReportDirectory); void setArchiveRepository(String archiveRepository); String getArchiveRepository(); String getArchiveArcDirectory(); }
FileArchive extends BaseArchive { public String submitToArchive(String targetInstanceOID, String SIP, Map xAttributes, List<ArchiveFile> files) throws FileArchiveException{ if(targetInstanceOID != null){ File archiveRoot = null; try { archiveRoot = new File(archiveRepository,targetInstanceOID); for(ArchiveFile f : files){ File fileArchiveDirectory = archiveRoot; switch(f.getType()){ case LOG_FILE: fileArchiveDirectory = new File(archiveRoot,archiveLogDirectory);break; case REPORT_FILE: fileArchiveDirectory = new File(archiveRoot,archiveReportDirectory);break; case ARC_FILE: fileArchiveDirectory = new File(archiveRoot,archiveArcDirectory);break; } f.setMd5(FileUtil.moveFile(f.getFile(),fileArchiveDirectory,true)); } String finalSIP = getFinalSIP(SIP, targetInstanceOID, files); String metsFileName = "METS-"+targetInstanceOID+".xml"; archiveRoot = new File(archiveRepository,targetInstanceOID); File metsFile = new File(archiveRoot,metsFileName); BufferedWriter bw = new BufferedWriter(new FileWriter(metsFile)); bw.write(finalSIP); bw.close(); } catch (Exception e) { log.error("Archiving error",e); deleteCascade(archiveRoot); throw new FileArchiveException(e); } } return targetInstanceOID; }  String submitToArchive(String targetInstanceOID, String SIP, Map xAttributes, List<ArchiveFile> files); CustomDepositFormResultDTO getCustomDepositFormDetails(CustomDepositFormCriteriaDTO criteria); void setArchiveArcDirectory(String archiveArcDirectory); void setArchiveLogDirectory(String archiveLogDirectory); void setArchiveReportDirectory(String archiveReportDirectory); void setArchiveRepository(String archiveRepository); String getArchiveRepository(); String getArchiveArcDirectory();  }