public void parseLogToThingWorx(File file) { DaiCollectionParser parser = new DaiCollectionParser(); Map<String, String> fileMeta = new HashMap<String, String>(); List<DaiMeterCollection> collections = null; DateTime time = new DateTime(); String timezone = time.getZone().toString(); fileMeta.put("olson_timezone_id", timezone); fileMeta.put("current_system_time", String.valueOf(System.currentTimeMillis())); String fileCreated = ""; BasicFileAttributes attributes = null; try { attributes = Files.readAttributes(file.toPath(), BasicFileAttributes.class); fileCreated = String.valueOf(attributes.creationTime().toMillis()); } catch (IOException e) { logger.warn("Unable to get File Create Time: ", e.getMessage()); } fileMeta.put("file_create_time", fileCreated); try { collections = parser.parse(file, fileMeta); } catch (Exception e) { logger.warn("Failed to parse file: ", e.getMessage()); } sendToThingWorx(collections); }
public static void main(String args[]) { try { aServer asr = new aServer(); // file channel. FileInputStream is = new FileInputStream(""); is.read(); FileChannel cha = is.getChannel(); ByteBuffer bf = ByteBuffer.allocate(1024); bf.flip(); cha.read(bf); // Path Paths Path pth = Paths.get("", ""); // Files some static operation. Files.newByteChannel(pth); Files.copy(pth, pth); // file attribute, other different class for dos and posix system. BasicFileAttributes bas = Files.readAttributes(pth, BasicFileAttributes.class); bas.size(); } catch (Exception e) { System.err.println(e); } System.out.println("hello "); }
private ZonedDateTime getLastModifiedDate(Path resourcePath) { if (!Files.isReadable(resourcePath)) { throw new ResourceNotFoundException( "Static resource file '" + resourcePath + "' is not readable."); } BasicFileAttributes fileAttributes; try { fileAttributes = Files.readAttributes(resourcePath, BasicFileAttributes.class); } catch (NoSuchFileException | FileNotFoundException e) { // This shouldn't be happening because we checked the file's readability before. But just in // case. throw new ResourceNotFoundException( "Static resource file '" + resourcePath + "' does not exists.", e); } catch (Exception e) { // UnsupportedOperationException, IOException or any other Exception that might occur. throw new FileOperationException( "Cannot read file attributes from static resource file '" + resourcePath + "'.", e); } if (fileAttributes.isRegularFile()) { return ZonedDateTime.ofInstant(fileAttributes.lastModifiedTime().toInstant(), GMT_TIME_ZONE); } else { /* * From book "OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide" page 478: * Java defines a regular file as one that contains content, as opposed to a symbolic link, * directory, resource (e.g. port, pipe), or other non-regular files that may be present in some * operating systems. [...] It is possible for isRegularFile() to return true for a symbolic link, * as long as the link resolves to a regular file. * Hence, checking 'isRegularFile' of a file is enough to determine its existence and not being a directory. */ throw new ResourceNotFoundException( "Static resource file '" + resourcePath + "' is not a regular file."); } }
public static synchronized void deleteExpired() { Date expiryDate; long freeSpace = getFreeUserSpace(); if (freeSpace < Globals.DISK_FREE_THRESHOLD) expiryDate = new Date(new Date().getTime() - Globals.FILE_KEEP_IN_CACHE_DURATION_MS_MINIMAL); else expiryDate = new Date(new Date().getTime() - Globals.FILE_KEEP_IN_CACHE_DURATION_MS); Log.warn( "running Delete Expired job", "expiryDate=" + expiryDate.toString() + " , freeSpace=" + freeSpace); File folder = new File(Config.cachePath); for (final File file : folder.listFiles()) { if (file.isFile() && file.getName().endsWith(Globals.FILE_EXT_DATA)) { BasicFileAttributes attrs; try { attrs = Files.readAttributes(file.toPath(), BasicFileAttributes.class); Date fileLastAccessTime = new Date(attrs.lastAccessTime().toMillis()); if (fileLastAccessTime.before(expiryDate)) deleteDataAndHeaderFiles(file); } catch (Exception e) { Log.error("Cannot read file attributes", e.getCause() + " : " + e.getMessage()); e.printStackTrace(); } } } }
MetaDataFileInfo(String fileName, MetaDataDedupFile mf) { this.fileName = fileName; this.mf = mf; this.isDirectory = mf.isDirectory(); fileIndex = getNextFileIndex(); Path file = Paths.get(mf.getPath()); try { DosFileAttributes attr = Files.readAttributes(file, DosFileAttributes.class); if (attr.isArchive()) fileAttribute |= FileAttributeFlags.FILE_ATTRIBUTE_ARCHIVE.getValue(); if (attr.isDirectory()) fileAttribute |= FileAttributeFlags.FILE_ATTRIBUTE_DIRECTORY.getValue(); if (attr.isHidden()) fileAttribute |= FileAttributeFlags.FILE_ATTRIBUTE_HIDDEN.getValue(); if (attr.isReadOnly()) fileAttribute |= FileAttributeFlags.FILE_ATTRIBUTE_READONLY.getValue(); if (attr.isRegularFile()) fileAttribute |= FileAttributeFlags.FILE_ATTRIBUTE_NORMAL.getValue(); if (attr.isSymbolicLink()) fileAttribute |= FileAttributeFlags.FILE_ATTRIBUTE_REPARSE_POINT.getValue(); if (attr.isSystem()) fileAttribute |= FileAttributeFlags.FILE_ATTRIBUTE_SYSTEM.getValue(); } catch (IOException | UnsupportedOperationException x) { SDFSLogger.getLog().error("attributes could not be created for " + this.fileName, x); } creationTime = FileTimeUtils.toFileTime(new Date(0)); lastAccessTime = FileTimeUtils.toFileTime(new Date(mf.getLastAccessed())); lastWriteTime = FileTimeUtils.toFileTime(new Date(mf.lastModified())); fileSize = mf.length(); SDFSLogger.getLog().debug("created file info for " + fileName); }
public final FileTime lastModified() throws IOException { if (exists()) { BasicFileAttributes attrs = Files.readAttributes(getPath(), BasicFileAttributes.class, options); return attrs.lastModifiedTime(); } else { return null; } }
@Override public void initialize(URL location, ResourceBundle resources) { // TODO Auto-generated method stub this.tbViewColData.setCellValueFactory(cellData -> cellData.getValue().DataProperty()); this.tbViewColArquivo.setCellValueFactory(cellData -> cellData.getValue().FileNameProperty()); File file = new File("./relatorios/"); if (file.exists()) { File[] m = file.listFiles(); for (File f : m) { Path path = FileSystems.getDefault().getPath("./relatorios"); BasicFileAttributes attributes; try { attributes = Files.readAttributes(path, BasicFileAttributes.class); FileTime creationTime = attributes.creationTime(); data.add(new TableHistoricoData(creationTime.toString(), f.getPath())); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } this.tbViewHistorico.getItems().addAll(data); } this.tbViewHistorico.setRowFactory( tv -> { TableRow<TableHistoricoData> row = new TableRow<>(); row.setOnMouseClicked( event -> { if (event.getClickCount() == 2 && (!row.isEmpty())) { TableHistoricoData rowData = row.getItem(); try { Thread t = new Thread() { public void run() { if (Desktop.isDesktopSupported()) if (Desktop.getDesktop().isSupported(Action.OPEN)) { Desktop op = Desktop.getDesktop(); if (new File(rowData.getFileName()).exists()) { try { op.open(new File(rowData.getFileName())); } catch (IOException e) { e.printStackTrace(); } } } } }; t.start(); } catch (Exception e) { e.printStackTrace(); } } }); return row; }); }
public FsDir(String aMountPoint, File aFile) { super(aMountPoint, aFile); try { BasicFileAttributes attr = Files.readAttributes(aFile.toPath(), BasicFileAttributes.class); creationDate = attr.creationTime(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
private boolean isCacheEntryExpired(Path cacheEntryPath, long durationToExpireMs) throws IOException { BasicFileAttributes attr = Files.readAttributes(cacheEntryPath, BasicFileAttributes.class); long modTime = attr.lastModifiedTime().toMillis(); long age = System.currentTimeMillis() - modTime; if (age > durationToExpireMs) { return true; } return false; }
public FileAttrs getAttrs() throws IOException { FileAttrs result; BasicFileAttributes attr; DosFileAttributes dosAttr; PosixFileAttributes posixAttr; result = new FileAttrs(); attr = Files.readAttributes(this.path.toPath(), BasicFileAttributes.class); result.setCtime(attr.creationTime().toMillis()); result.setMtime(attr.lastModifiedTime().toMillis()); // result.append("symlink", attr.isSymbolicLink()); //Redundant result.setSize(attr.size()); if (System.getProperty("os.name").startsWith("Windows")) { dosAttr = Files.readAttributes(this.path.toPath(), DosFileAttributes.class); result.setDosArchive(dosAttr.isArchive()); result.setDosHidden(dosAttr.isHidden()); result.setDosReadonly(dosAttr.isReadOnly()); result.setDosSystem(dosAttr.isSystem()); } else { posixAttr = Files.readAttributes(this.path.toPath(), PosixFileAttributes.class); result.setPosixSymlink(this.isSymlink()); if (result.getPosixSymlink()) { result.setLinkTo(Files.readSymbolicLink(this.path.toPath()).toString()); } result.setPosixOwner(posixAttr.owner().getName()); result.setPosixGroup(posixAttr.group().getName()); result.setPosixPermission(PosixFilePermissions.toString(posixAttr.permissions())); } return result; }
public final void update(File[] xml) { if (xml != null || xml.length != 0) { data = new String[xml.length][columnNames.length]; try { for (int i = 0; i < xml.length; i++) { if (xml[i].isFile()) { BasicFileAttributes attrs = Files.readAttributes(xml[i].toPath(), BasicFileAttributes.class); data[i][0] = xml[i].getName(); data[i][1] = String.format("%d B", attrs.size()); data[i][2] = String.format("%1$tY/%1$tm/%1$td", new Date(attrs.creationTime().toMillis())); data[i][3] = String.format("%1$tY/%1$tm/%1$td", new Date(attrs.lastModifiedTime().toMillis())); } } rows = xml.length; fireTableStructureChanged(); } catch (IOException ex) { System.err.println(ex.getMessage()); } } else JOptionPane.showMessageDialog(null, "No existen facturas de consumidor final"); }
public static String getFileKey(Path filePath) { if (!Files.exists(filePath)) { return ""; } try { if (OSDetector.isWindows()) { UserDefinedFileAttributeView userDefinedFileAttributeView = Files.getFileAttributeView(filePath, UserDefinedFileAttributeView.class); List<String> list = userDefinedFileAttributeView.list(); if (!list.contains("fileKey")) { return ""; } ByteBuffer byteBuffer = ByteBuffer.allocate(userDefinedFileAttributeView.size("fileKey")); userDefinedFileAttributeView.read("fileKey", byteBuffer); CharBuffer charBuffer = _CHARSET.decode((ByteBuffer) byteBuffer.flip()); return charBuffer.toString(); } else { BasicFileAttributes basicFileAttributes = Files.readAttributes(filePath, BasicFileAttributes.class); Object fileKey = basicFileAttributes.fileKey(); return fileKey.toString(); } } catch (Exception e) { _logger.error(e.getMessage(), e); return ""; } }
public static synchronized FileInfo getFileInfo(String name) { int version = getCurrentVersion(name, null); Path dataFilePath = Paths.get(Config.cachePath, getDataFileName(name, version)); Path headerFilePath = Paths.get(Config.cachePath, getHeadersFileName(name, version)); Date fileLastModifiedTime; BasicFileAttributes attrs; try { attrs = Files.readAttributes(dataFilePath, BasicFileAttributes.class); fileLastModifiedTime = new Date(attrs.lastModifiedTime().toMillis()); } catch (Exception e) { Log.error("Cannot read file attributes", e.getCause() + ": " + e.getMessage()); e.printStackTrace(); return null; } // read headers ArrayList<String> headers = loadHeaders(headerFilePath.toFile()); String url = null; String etag = null; for (String header : headers) { if (header.startsWith(HttpConstants.HEADER_FILE_URL + ":")) { url = header.split(":", 2)[1].trim(); } else if (header.startsWith(HttpConstants.HEADER_ETAG + ":")) { etag = header.split(":", 2)[1].trim(); } } if (url != null) return new FileInfo(url, fileLastModifiedTime, etag); else return null; }
private void compute(Set<SipPreview> sipPreviews) { for (SipPreview sip : sipPreviews) { representations += sip.getRepresentations().size(); Set<Path> paths = new HashSet<>(); for (SipRepresentation rep : sip.getRepresentations()) { for (TreeNode tn : rep.getFiles()) { paths.add(tn.getPath()); paths.addAll(tn.getFullTreePathsAsPaths()); } } try { for (Path p : paths) { if (Files.isDirectory(p)) { folders++; } else { files++; size += Files.readAttributes(p, BasicFileAttributes.class).size(); } } } catch (IOException e) { LOGGER.warn("Error reading attributes of file/folder", e); } } }
void assertPlugin(String name, Path original, Environment env) throws IOException { Path got = env.pluginsFile().resolve(name); assertTrue("dir " + name + " exists", Files.exists(got)); if (isPosix) { Set<PosixFilePermission> perms = Files.getPosixFilePermissions(got); assertThat( perms, containsInAnyOrder( PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.GROUP_READ, PosixFilePermission.GROUP_EXECUTE, PosixFilePermission.OTHERS_READ, PosixFilePermission.OTHERS_EXECUTE)); } assertTrue("jar was copied", Files.exists(got.resolve("plugin.jar"))); assertFalse("bin was not copied", Files.exists(got.resolve("bin"))); assertFalse("config was not copied", Files.exists(got.resolve("config"))); if (Files.exists(original.resolve("bin"))) { Path binDir = env.binFile().resolve(name); assertTrue("bin dir exists", Files.exists(binDir)); assertTrue("bin is a dir", Files.isDirectory(binDir)); PosixFileAttributes binAttributes = null; if (isPosix) { binAttributes = Files.readAttributes(env.binFile(), PosixFileAttributes.class); } try (DirectoryStream<Path> stream = Files.newDirectoryStream(binDir)) { for (Path file : stream) { assertFalse("not a dir", Files.isDirectory(file)); if (isPosix) { PosixFileAttributes attributes = Files.readAttributes(file, PosixFileAttributes.class); assertEquals(InstallPluginCommand.BIN_FILES_PERMS, attributes.permissions()); } } } } if (Files.exists(original.resolve("config"))) { Path configDir = env.configFile().resolve(name); assertTrue("config dir exists", Files.exists(configDir)); assertTrue("config is a dir", Files.isDirectory(configDir)); UserPrincipal user = null; GroupPrincipal group = null; if (isPosix) { PosixFileAttributes configAttributes = Files.getFileAttributeView(env.configFile(), PosixFileAttributeView.class) .readAttributes(); user = configAttributes.owner(); group = configAttributes.group(); PosixFileAttributes attributes = Files.getFileAttributeView(configDir, PosixFileAttributeView.class).readAttributes(); assertThat(attributes.owner(), equalTo(user)); assertThat(attributes.group(), equalTo(group)); } try (DirectoryStream<Path> stream = Files.newDirectoryStream(configDir)) { for (Path file : stream) { assertFalse("not a dir", Files.isDirectory(file)); if (isPosix) { PosixFileAttributes attributes = Files.readAttributes(file, PosixFileAttributes.class); if (user != null) { assertThat(attributes.owner(), equalTo(user)); } if (group != null) { assertThat(attributes.group(), equalTo(group)); } } } } } assertInstallCleaned(env); }
protected List<PluginInfo<T>> scan( LogSource logger, String hosterpath, final List<? extends LazyPlugin<T>> pluginCache, final AtomicLong lastFolderModification) throws Exception { DirectoryStream<Path> stream = null; final ArrayList<PluginInfo<T>> ret = new ArrayList<PluginInfo<T>>(); final long timeStamp = System.currentTimeMillis(); try { long lastModified = lastFolderModification != null ? lastFolderModification.get() : -1; final Path folder = Application.getRootByClass(jd.SecondLevelLaunch.class, hosterpath).toPath(); final long lastFolderModified = Files.readAttributes(folder, BasicFileAttributes.class).lastModifiedTime().toMillis(); if (lastModified > 0 && lastFolderModified == lastModified && pluginCache != null && pluginCache.size() > 0) { for (final LazyPlugin<T> lazyPlugin : pluginCache) { final PluginInfo<T> pluginInfo = new PluginInfo<T>(lazyPlugin.getLazyPluginClass(), null); pluginInfo.setLazyPlugin(lazyPlugin); ret.add(pluginInfo); } return ret; } PluginClassLoaderChild cl = null; MessageDigest md = null; final String pkg = hosterpath.replace("/", "."); final byte[] mdCache = new byte[32767]; final HashMap<String, List<LazyPlugin<T>>> lazyPluginClassMap; if (pluginCache != null && pluginCache.size() > 0) { lazyPluginClassMap = new HashMap<String, List<LazyPlugin<T>>>(); for (final LazyPlugin<T> lazyPlugin : pluginCache) { List<LazyPlugin<T>> list = lazyPluginClassMap.get(lazyPlugin.getLazyPluginClass().getClassName()); if (list == null) { list = new ArrayList<LazyPlugin<T>>(); lazyPluginClassMap.put(lazyPlugin.getLazyPluginClass().getClassName(), list); } list.add(lazyPlugin); } } else { lazyPluginClassMap = null; } if (lastFolderModification != null) { lastFolderModification.set(lastFolderModified); } stream = Files.newDirectoryStream(folder, "*.class"); for (final Path path : stream) { try { final String pathFileName = path.getFileName().toString(); final String className = pathFileName.substring(0, pathFileName.length() - 6); if (className.indexOf("$") < 0 && !PluginController.IGNORELIST.contains(className)) { byte[] sha256 = null; final BasicFileAttributes pathAttr = Files.readAttributes(path, BasicFileAttributes.class); if (lazyPluginClassMap != null) { final List<LazyPlugin<T>> lazyPlugins = lazyPluginClassMap.get(className); if (lazyPlugins != null && lazyPlugins.size() > 0) { final LazyPluginClass lazyPluginClass = lazyPlugins.get(0).getLazyPluginClass(); if (lazyPluginClass != null && (lazyPluginClass.getLastModified() == pathAttr.lastModifiedTime().toMillis() || ((md = MessageDigest.getInstance("SHA-256")) != null && (sha256 = PluginController.getFileHashBytes(path.toFile(), md, mdCache)) != null && Arrays.equals(sha256, lazyPluginClass.getSha256())))) { for (final LazyPlugin<T> lazyPlugin : lazyPlugins) { // logger.finer("Cached: " + className + "|" + lazyPlugin.getDisplayName() + "|" // + // lazyPluginClass.getRevision()); final PluginInfo<T> pluginInfo = new PluginInfo<T>(lazyPluginClass, null); pluginInfo.setLazyPlugin(lazyPlugin); ret.add(pluginInfo); } continue; } } } Class<T> pluginClass = null; long[] infos = null; try { if (cl == null) { cl = PluginClassLoader.getInstance().getChild(); } if (md == null) { md = MessageDigest.getInstance("SHA-256"); } pluginClass = (Class<T>) cl.loadClass(pkg + "." + className); if (!Modifier.isAbstract(pluginClass.getModifiers()) && Plugin.class.isAssignableFrom(pluginClass)) { infos = getPluginController().getInfos(pluginClass); if (infos == null) { continue; } } else { continue; } } catch (final Throwable e) { logger.finer("Failed: " + className); logger.log(e); continue; } if (sha256 == null) { sha256 = PluginController.getFileHashBytes(path.toFile(), md, mdCache); } // final LazyPluginClass lazyPluginClass = new LazyPluginClass( className, sha256, pathAttr.lastModifiedTime().toMillis(), (int) infos[0], infos[1]); final PluginInfo<T> pluginInfo = new PluginInfo<T>(lazyPluginClass, pluginClass); // logger.finer("Scaned: " + className + "|" + lazyPluginClass.getRevision()); ret.add(pluginInfo); } } catch (Throwable e) { logger.finer("Failed: " + path); logger.log(e); } } return ret; } finally { logger.info( "@PluginController(NIO): scan took " + (System.currentTimeMillis() - timeStamp) + "ms for " + ret.size()); if (stream != null) { stream.close(); } } }
public static void main(String[] args) throws Exception { Path listing = Paths.get("c:/Users/adharmad/bin/gzip.exe"); System.out.println(Files.readAttributes(listing, "*")); }
/** * Read the account requests from the .xml files that are stored in the * LdapProperty.getProperty(LdapConstants.OUTPUT_FOLDER) and stored those requests into * this.requests * * <p>1). read each .xml file 2). get the responsible staff for that request from Support Tracker * DB 3). create a HashMap object to store this request 4). add this request (HashMap object) into * the list that response by this staff 5). add responsileStaff as the key of the requests object * and the list of the requests that this staff responsible as the value of the requests object * * @return a map object, where: + its key is the name of the staff that responsible for the * requests + its value is the list of the request that this staff responsible for => each * request in this list is the Map object, where key is the attribute of the user, and value * is the value of that attribute @Note: if you want to see, how requests object look like, * please uncomment the print lines in this method. * @throws IOException if it failed to create DocumentBuilder object or failed to parse the * DocumentBuilder contents into a DOM object or failed to read the account requests from the * account requests storage folder */ private void extractRequests() throws IOException { logger.debug( "About to read the request *.xml file from the file system: " + LdapProperty.getProperty(LdapConstants.OUTPUT_FOLDER)); requests = new TreeMap<String, List<Map<String, String>>>(); try { // building DocumentBuilder DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); File outFolder = new File(LdapProperty.getProperty(LdapConstants.OUTPUT_FOLDER)); // outFolder doesn't exist because of the incorrect configured in ldap.properties // or it failed to read from that folder if (!outFolder.exists()) { String foldername = LdapProperty.getProperty(LdapConstants.OUTPUT_FOLDER); logger.error(ErrorConstants.FAIL_READING_ACCT_REQUEST + foldername); throw new IOException(ErrorConstants.FAIL_READING_ACCT_REQUEST + foldername); } // we need to order the request based on the date it created. // thats why, we convert the array of files to TreeSet object. TreeSet<File> xmlFiles = new TreeSet<File>(Arrays.asList(outFolder.listFiles())); // ADDITIONAL CODE - SPT-446 // Handle null case by creating empty array if (xmlFiles == null) { xmlFiles = new TreeSet<File>(); } for (File file : xmlFiles) { // read xml file, put the content into DocumentBuilder object // File file = xmlFiles[i]; if (file.getName().endsWith(".xml")) { // parse docBuilder contents into a DOM object (doc) Document doc = docBuilder.parse(file); NodeList fields = doc.getElementsByTagName("field"); logger.debug("Reading a file called: " + file.getName()); // get the data from DOM and store into HashMap String responsibleStaff = null; HashMap<String, String> maps = new HashMap<String, String>(); for (int j = 0; j < fields.getLength(); j++) { String key = fields.item(j).getAttributes().item(0).getTextContent(); maps.put(key, fields.item(j).getTextContent()); // looking for the company field // get the company name from the company field // find the staff who responsible for this request if (key.equalsIgnoreCase("company")) { try { responsibleStaff = SupportTrackerJDBC.getResponsibleStaff(fields.item(j).getTextContent()); } catch (SQLException e) { responsibleStaff = null; } } logger.debug( fields.item(j).getAttributes().item(0).getTextContent() + "|" + fields.item(j).getTextContent()); } String createdDate = null; try { createdDate = file.getName().replace(".xml", ""); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); Date date = sdf.parse(createdDate); sdf = new SimpleDateFormat("yyyy-MM-dd"); createdDate = sdf.format(date); } catch (Exception e) { BasicFileAttributes attrs = Files.readAttributes(Paths.get(file.getPath()), BasicFileAttributes.class); createdDate = attrs.creationTime().toString(); createdDate = createdDate.substring(0, createdDate.indexOf('T')); } maps.put("createdDate", createdDate); maps.put("filename", file.getName()); String countryCode = maps.get("c"); if (!countryCode.equals("") && countryCode != null) { maps.put("co", CountryCode.getCountryByCode(countryCode)); } // if there's no resposibleStaff stored in support tracker DB (when // responsibleStaff==null) // set responsibleStaff as "Others" if (responsibleStaff == null) responsibleStaff = "Others"; // add this request into its corresponding list ArrayList<Map<String, String>> requestResponsibleByThisStaff = null; if (requests.containsKey(responsibleStaff)) { requestResponsibleByThisStaff = (ArrayList<Map<String, String>>) requests.get(responsibleStaff); } else { requestResponsibleByThisStaff = new ArrayList<Map<String, String>>(); } requestResponsibleByThisStaff.add(maps); requests.put(responsibleStaff, requestResponsibleByThisStaff); } } // Note: if you want to see, how requests object look like, pls uncomment these lines // for(Map.Entry<String, List<Map<String, String>>> rqls : requests.entrySet()){ // String responsibleStaff = rqls.getKey(); // System.out.println(responsibleStaff); // List<Map<String, String>> requestList = rqls.getValue(); // int i = 1; // for(Map<String, String> request : requestList){ // System.out.println("\t" + i++ + ")."); // for(Map.Entry<String, String> attr_value : request.entrySet()){ // System.out.println("\t" + attr_value.getKey() + " : " + attr_value.getValue()); // } // } // } logger.debug("Finished reading the request *.xml."); } catch (ParserConfigurationException e) { String foldername = LdapProperty.getProperty(LdapConstants.OUTPUT_FOLDER); logger.error("Failed to create DocumentBuilder", e); new IOException(ErrorConstants.FAIL_READING_ACCT_REQUEST + foldername); } catch (SAXException e) { String foldername = LdapProperty.getProperty(LdapConstants.OUTPUT_FOLDER); logger.error("Failed to parse docBuilder contents into DOM object", e); new IOException(ErrorConstants.FAIL_READING_ACCT_REQUEST + foldername); } catch (IOException e) { String foldername = LdapProperty.getProperty(LdapConstants.OUTPUT_FOLDER); logger.error("Failed to parse docBuilder contents into DOM object", e); new IOException(ErrorConstants.FAIL_READING_ACCT_REQUEST + foldername); } }
public <A extends BasicFileAttributes> A readAttributes( Path pathRelativeToProjectRoot, Class<A> type, LinkOption... options) throws IOException { return Files.readAttributes(getPathForRelativePath(pathRelativeToProjectRoot), type, options); }
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Path relFilePath = m_srcRoot.relativize(file); if (isSrcIgnored(relFilePath)) { m_progress.reportProgress(CloneProgressReporter.EventType.FILE_SKIP_IGNORE, file, null, null); return FileVisitResult.CONTINUE; } Path newPathCandidate = m_destRoot.resolve(relFilePath); Iterator<FileHandler> it = m_fileHandlers.iterator(); while (it.hasNext()) { FileHandler handler = it.next(); try { Path newPath = handler.canHandleFile(file, attrs, newPathCandidate); if (newPath != null) { // record the visited file even if we don't process it recordVisitedFile(file, newPath); // does the new path exist if (Files.exists(newPath, LinkOption.NOFOLLOW_LINKS)) { // if it's the same file, then skip if (Files.isSameFile(file, newPath)) { m_progress.reportProgress( CloneProgressReporter.EventType.FILE_SKIP_SAME, file, newPath, null); } else { // process file BasicFileAttributes targetAttrs = Files.readAttributes( newPath, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS); if (targetAttrs.lastModifiedTime().compareTo(attrs.lastModifiedTime()) < 0) { m_progress.reportProgress( CloneProgressReporter.EventType.FILE_UPDATE_EXISTING_BEGIN, file, newPath, null); handler.processFile(file, attrs, newPathCandidate, m_runType); m_progress.reportProgress( CloneProgressReporter.EventType.FILE_UPDATE_EXISTING_END, file, newPath, null); } else { m_progress.reportProgress( CloneProgressReporter.EventType.FILE_SKIP_NEWER, file, newPath, null); } } } else { // otherwise process it m_progress.reportProgress( CloneProgressReporter.EventType.FILE_CREATE_NEW_BEGIN, file, newPath, null); handler.processFile(file, attrs, newPathCandidate, m_runType); m_progress.reportProgress( CloneProgressReporter.EventType.FILE_CREATE_NEW_END, file, newPath, null); } // file has been handled break; } } catch (FileCloningError e) { m_progress.reportProgress(CloneProgressReporter.EventType.ERROR, file, null, e); // TODO: should we continue and try next handler in list? } } return FileVisitResult.CONTINUE; }