List of usage examples for java.io FilenameFilter FilenameFilter
FilenameFilter
From source file:hu.ppke.itk.nlpg.purepos.cli.PurePos.java
/** * Loads the latest Humor jar file and create an analyzer instance * //www .j a v a 2s . c o m * @return analyzer instance */ protected static IMorphologicalAnalyzer loadHumor() throws InstantiationException, IllegalAccessException, ClassNotFoundException, MalformedURLException { String humorPath = System.getProperty("humor.path"); if (humorPath == null) throw new ClassNotFoundException("Humor jar file is not present"); File dir = new File(humorPath); File[] candidates = dir.listFiles(new FilenameFilter() { public boolean accept(File dir, String filename) { return filename.endsWith(".jar") && filename.startsWith("humor-"); } }); Arrays.sort(candidates); @SuppressWarnings("deprecation") URL humorURL = candidates[candidates.length - 1].toURL(); URLClassLoader myLoader = new URLClassLoader(new URL[] { humorURL }, PurePos.class.getClassLoader()); Class<?> humorClass = Class.forName("hu.ppke.itk.nlpg.purepos.morphology.HumorAnalyzer", true, myLoader); return (IMorphologicalAnalyzer) humorClass.newInstance(); }
From source file:io.fabric8.maven.enricher.fabric8.IconEnricher.java
private File copyIconToFolder(String iconRef, File appBuildDir) throws IOException { if (StringUtils.isNotBlank(iconRef)) { File[] icons = appBuildDir.listFiles(new FilenameFilter() { @Override//from w ww.j a va 2 s .c o m public boolean accept(File dir, String name) { if (name == null) { return false; } String lower = name.toLowerCase(); if (lower.startsWith("icon.")) { for (String ext : ICON_EXTENSIONS) { if (lower.endsWith(ext)) { return true; } } } return false; } }); if (icons == null || icons.length == 0) { // lets copy the iconRef InputStream in = loadPluginResource(iconRef); if (in == null) { // maybe it dont have extension so try to find it for (String ext : ICON_EXTENSIONS) { String name = iconRef + ext; in = loadPluginResource(name); if (in != null) { iconRef = name; break; } } } if (in != null) { String fileName = "icon." + Files.getFileExtension(iconRef); File outFile = new File(appBuildDir, fileName); FileUtils.copyInputStreamToFile(in, outFile); log.info("Generated icon file " + outFile + " from icon reference: " + iconRef); return outFile; } } } return null; }
From source file:com.lxht.emos.data.cache.intf.HessianUtil.java
/** * ??,?,?????./*from ww w .j a va 2s . c om*/ * * @param objectFileDirectory ? * @param fileName ??????? * @return boolean ??, true:?,false:. */ public static boolean removeSerializeLikeFile(String objectFileDirectory, final String fileName) { if (StringUtils.isBlank(objectFileDirectory) || StringUtils.isBlank(fileName)) { return false; } // ?File. File objDirFile = getObjectFileDir(objectFileDirectory); // ???? File[] objFiles = objDirFile.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { if (StringUtils.isBlank(name)) { return false; } /** * ??. */ return StringUtils.startsWith(name, fileName); } }); if (ArrayUtils.isEmpty(objFiles)) { return false; } // ?. for (File file : objFiles) { boolean isDelSuc = file.delete(); if (!isDelSuc) { file.deleteOnExit(); logger.warn("removeSerializeLikeFile(),Delete the local cache file failed.[File:" + file + "]"); continue; } } return true; }
From source file:info.varden.anatychia.Main.java
public static MaterialDataList materialList(SaveData save, ProgressUpdater pu, MaterialData[] filters) { Random random = new Random(); boolean filtersNull = filters == null; pu.updated(0, 1);/*from ww w . j a va 2 s.c o m*/ pu.updated(-3, 1); MaterialDataList mdl = new MaterialDataList(); File saveDir = save.getLocation(); File[] regionFolders = listRegionContainers(saveDir); int depth = Integer.MAX_VALUE; File shallowest = null; for (File f : regionFolders) { String path = f.getAbsolutePath(); Pattern p = Pattern.compile(Pattern.quote(File.separator)); Matcher m = p.matcher(path); int count = 0; while (m.find()) { count++; } if (count < depth) { depth = count; if (shallowest == null || f.getName().equalsIgnoreCase("region")) { shallowest = f; } } } pu.updated(-1, 1); ArrayList<File> regions = new ArrayList<File>(); int tfs = 0; for (File f : regionFolders) { String dimName = f.getParentFile().getName(); boolean deleted = false; if (f.equals(shallowest)) { dimName = "DIM0"; } if (!filtersNull) { for (MaterialData type : filters) { if (type.getType() == MaterialType.DIMENSION && type.getName().equals(dimName)) { System.out.println("Deleting: " + dimName); deleted = recursiveDelete(f); } } } if (deleted) continue; mdl.increment(new MaterialData(MaterialType.DIMENSION, dimName, 1L)); File[] r = f.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".mca"); } }); int max = r.length; int cur = 0; for (File valid : r) { cur++; try { BufferedInputStream bis = new BufferedInputStream(new FileInputStream(valid)); byte[] offsetHeader = new byte[4096]; bis.read(offsetHeader, 0, 4096); bis.close(); ByteBuffer bb = ByteBuffer.wrap(offsetHeader); IntBuffer ib = bb.asIntBuffer(); while (ib.remaining() > 0) { if (ib.get() != 0) { tfs++; } } bb = null; ib = null; } catch (IOException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } // tfs += Math.floor(valid.length() / 1000D); pu.updated(cur, max); } regions.addAll(Arrays.asList(r)); } if (regions.size() <= 0) { pu.updated(1, 1); return mdl; } pu.updated(-2, 1); int fc = 0; int fs = 0; for (File region : regions) { fc++; //fs += Math.floor(region.length() / 1000D); try { RegionFile anvil = new RegionFile(region); for (int x = 0; x < 32; x++) { for (int z = 0; z < 32; z++) { InputStream is = anvil.getChunkDataInputStream(x, z); if (is == null) continue; NBTInputStream nbti = new NBTInputStream(is, CompressionMode.NONE); CompoundTag root = (CompoundTag) nbti.readTag(); String rootName = root.getName(); CompoundTag level = (CompoundTag) root.getValue().get("Level"); Map<String, Tag> levelTags = level.getValue(); ListTag sectionTag = (ListTag) levelTags.get("Sections"); ArrayList<Tag> sections = new ArrayList<Tag>(sectionTag.getValue()); for (int i = 0; i < sections.size(); i++) { mdl.setSectorsRelative(1); CompoundTag sect = (CompoundTag) sections.get(i); Map<String, Tag> sectTags = sect.getValue(); ByteArrayTag blockArray = (ByteArrayTag) sectTags.get("Blocks"); byte[] add = new byte[0]; boolean hasAdd = false; if (sectTags.containsKey("Add")) { hasAdd = true; ByteArrayTag addArray = (ByteArrayTag) sectTags.get("Add"); add = addArray.getValue(); } byte[] blocks = blockArray.getValue(); for (int j = 0; j < blocks.length; j++) { short id; byte aid = (byte) 0; if (hasAdd) { aid = ChunkFormat.Nibble4(add, j); id = (short) ((blocks[j] & 0xFF) + (aid << 8)); } else { id = (short) (blocks[j] & 0xFF); } if (!filtersNull) { for (MaterialData type : filters) { if (type.getType() == MaterialType.BLOCK && type.getName().equals(String.valueOf(blocks[j] & 0xFF)) && (type.getRemovalChance() == 1D || random.nextDouble() < type.getRemovalChance())) { blocks[j] = (byte) 0; if (aid != 0) { add[j / 2] = (byte) (add[j / 2] & (j % 2 == 0 ? 0xF0 : 0x0F)); } id = (short) 0; } } } mdl.increment(new MaterialData(MaterialType.BLOCK, String.valueOf(id), 1L)); } if (!filtersNull) { HashMap<String, Tag> rSectTags = new HashMap<String, Tag>(); rSectTags.putAll(sectTags); ByteArrayTag bat = new ByteArrayTag("Blocks", blocks); rSectTags.put("Blocks", bat); if (hasAdd) { ByteArrayTag adt = new ByteArrayTag("Add", add); rSectTags.put("Add", adt); } CompoundTag rSect = new CompoundTag(sect.getName(), rSectTags); sections.set(i, rSect); } } ListTag entitiesTag = (ListTag) levelTags.get("Entities"); ArrayList<Tag> entities = new ArrayList<Tag>(entitiesTag.getValue()); for (int i = entities.size() - 1; i >= 0; i--) { CompoundTag entity = (CompoundTag) entities.get(i); Map<String, Tag> entityTags = entity.getValue(); if (entityTags.containsKey("id")) { StringTag idTag = (StringTag) entityTags.get("id"); String id = idTag.getValue(); boolean removed = false; if (!filtersNull) { for (MaterialData type : filters) { if (type.getType() == MaterialType.ENTITY && (type.getName().equals(id) || type.getName().equals("")) && (type.getRemovalChance() == 1D || random.nextDouble() < type.getRemovalChance())) { if (type.fulfillsRequirements(entity)) { entities.remove(i); removed = true; } } } } if (!removed) { mdl.increment(new MaterialData(MaterialType.ENTITY, id, 1L)); } } } nbti.close(); is.close(); if (!filtersNull) { HashMap<String, Tag> rLevelTags = new HashMap<String, Tag>(); rLevelTags.putAll(levelTags); ListTag rSectionTag = new ListTag("Sections", CompoundTag.class, sections); rLevelTags.put("Sections", rSectionTag); ListTag rEntityTag = new ListTag("Entities", CompoundTag.class, entities); rLevelTags.put("Entities", rEntityTag); final CompoundTag rLevel = new CompoundTag("Level", rLevelTags); HashMap<String, Tag> rRootTags = new HashMap<String, Tag>() { { put("Level", rLevel); } }; CompoundTag rRoot = new CompoundTag(rootName, rRootTags); OutputStream os = anvil.getChunkDataOutputStream(x, z); NBTOutputStream nbto = new NBTOutputStream(os, CompressionMode.NONE); nbto.writeTag(rRoot); nbto.close(); } fs++; pu.updated(fs, tfs); } } anvil.close(); } catch (Exception ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } } MaterialData[] data = mdl.toArray(); System.out.println("FILES SCANNED: " + fc); for (MaterialData d : data) { System.out.println(d.getType().getName() + ": " + d.getName() + " (" + d.getQuantity() + ")"); } return mdl; }
From source file:com.kegare.caveworld.world.WorldProviderCaveworld.java
public static void regenerate(final boolean backup) { final File dir = getDimDir(); final String name = dir.getName().substring(4); final MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); Set<EntityPlayerMP> target = Sets.newHashSet(); for (Object obj : server.getConfigurationManager().playerEntityList.toArray()) { if (obj != null && ((EntityPlayerMP) obj).dimension == CaveworldAPI.getDimension()) { target.add(CaveUtils.respawnPlayer((EntityPlayerMP) obj, 0)); }// w ww . j a v a2s . com } boolean result = new ForkJoinPool().invoke(new RecursiveTask<Boolean>() { @Override protected Boolean compute() { IChatComponent component; try { component = new ChatComponentText( StatCollector.translateToLocalFormatted("caveworld.regenerate.regenerating", name)); component.getChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(true); server.getConfigurationManager().sendChatMsg(component); if (server.isSinglePlayer()) { Caveworld.network.sendToAll(new RegenerateMessage(backup)); } Caveworld.network.sendToAll(new RegenerateMessage.ProgressNotify(0)); CaveBlocks.caveworld_portal.portalDisabled = true; int dim = CaveworldAPI.getDimension(); WorldServer world = DimensionManager.getWorld(dim); if (world != null) { world.saveAllChunks(true, null); world.flush(); MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(world)); DimensionManager.setWorld(dim, null); } if (dir != null) { if (backup) { File parent = dir.getParentFile(); final Pattern pattern = Pattern.compile("^" + dir.getName() + "_bak-..*\\.zip$"); File[] files = parent.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return pattern.matcher(name).matches(); } }); if (files != null && files.length >= 5) { Arrays.sort(files, new Comparator<File>() { @Override public int compare(File o1, File o2) { int i = CaveUtils.compareWithNull(o1, o2); if (i == 0 && o1 != null && o2 != null) { try { i = Files.getLastModifiedTime(o1.toPath()) .compareTo(Files.getLastModifiedTime(o2.toPath())); } catch (IOException e) { } } return i; } }); FileUtils.forceDelete(files[0]); } Calendar calendar = Calendar.getInstance(); String year = Integer.toString(calendar.get(Calendar.YEAR)); String month = String.format("%02d", calendar.get(Calendar.MONTH) + 1); String day = String.format("%02d", calendar.get(Calendar.DATE)); String hour = String.format("%02d", calendar.get(Calendar.HOUR_OF_DAY)); String minute = String.format("%02d", calendar.get(Calendar.MINUTE)); String second = String.format("%02d", calendar.get(Calendar.SECOND)); File bak = new File(parent, dir.getName() + "_bak-" + Joiner.on("").join(year, month, day) + "-" + Joiner.on("").join(hour, minute, second) + ".zip"); if (bak.exists()) { FileUtils.deleteQuietly(bak); } component = new ChatComponentText(StatCollector .translateToLocalFormatted("caveworld.regenerate.backingup", name)); component.getChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(true); server.getConfigurationManager().sendChatMsg(component); Caveworld.network.sendToAll(new RegenerateMessage.ProgressNotify(1)); if (CaveUtils.archiveDirZip(dir, bak)) { ClickEvent click = new ClickEvent(ClickEvent.Action.OPEN_FILE, FilenameUtils.normalize(bak.getParentFile().getPath())); component = new ChatComponentText(StatCollector .translateToLocalFormatted("caveworld.regenerate.backedup", name)); component.getChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(true) .setChatClickEvent(click); server.getConfigurationManager().sendChatMsg(component); } else { component = new ChatComponentText(StatCollector .translateToLocalFormatted("caveworld.regenerate.backup.failed", name)); component.getChatStyle().setColor(EnumChatFormatting.RED).setItalic(true); server.getConfigurationManager().sendChatMsg(component); } } FileUtils.deleteDirectory(dir); } if (DimensionManager.shouldLoadSpawn(dim)) { DimensionManager.initDimension(dim); world = DimensionManager.getWorld(dim); if (world != null) { world.saveAllChunks(true, null); world.flush(); } } CaveBlocks.caveworld_portal.portalDisabled = false; component = new ChatComponentText( StatCollector.translateToLocalFormatted("caveworld.regenerate.regenerated", name)); component.getChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(true); server.getConfigurationManager().sendChatMsg(component); Caveworld.network.sendToAll(new RegenerateMessage.ProgressNotify(2)); return true; } catch (Exception e) { component = new ChatComponentText( StatCollector.translateToLocalFormatted("caveworld.regenerate.failed", name)); component.getChatStyle().setColor(EnumChatFormatting.RED).setItalic(true); server.getConfigurationManager().sendChatMsg(component); Caveworld.network.sendToAll(new RegenerateMessage.ProgressNotify(3)); CaveLog.log(Level.ERROR, e, component.getUnformattedText()); } return false; } }); if (result && (Config.hardcore || Config.caveborn)) { for (EntityPlayerMP player : target) { if (!CaveworldAPI.isEntityInCaveworld(player)) { CaveUtils.forceTeleport(player, CaveworldAPI.getDimension()); } } } }
From source file:io.github.lucaseasedup.logit.profile.ProfileManager.java
private File[] listProfiles() { return path.listFiles(new FilenameFilter() { @Override// w w w.ja va2 s.c o m public boolean accept(File dir, String name) { return name.endsWith(".yml"); } }); }
From source file:com.meltmedia.cadmium.core.FileSystemManager.java
public static void copyAllContent(final String source, final String target, final boolean ignoreHidden) throws Exception { File sourceFile = new File(source); File targetFile = new File(target); if (!targetFile.exists()) { targetFile.mkdirs();//from w ww. ja v a2 s. c o m } if (sourceFile.exists() && sourceFile.canRead() && sourceFile.isDirectory() && targetFile.exists() && targetFile.canWrite() && targetFile.isDirectory()) { List<File> copyList = new ArrayList<File>(); FilenameFilter filter = new FilenameFilter() { @Override public boolean accept(File file, String name) { return !ignoreHidden || !name.startsWith("."); } }; File files[] = sourceFile.listFiles(filter); if (files.length > 0) { copyList.addAll(Arrays.asList(files)); } for (int index = 0; index < copyList.size(); index++) { File aFile = copyList.get(index); String relativePath = aFile.getAbsoluteFile().getAbsolutePath() .replaceFirst(sourceFile.getAbsoluteFile().getAbsolutePath(), ""); if (aFile.isDirectory()) { File newDir = new File(target, relativePath); if (newDir.mkdir()) { newDir.setExecutable(aFile.canExecute(), false); newDir.setReadable(aFile.canRead(), false); newDir.setWritable(aFile.canWrite(), false); newDir.setLastModified(aFile.lastModified()); files = aFile.listFiles(filter); if (files.length > 0) { copyList.addAll(index + 1, Arrays.asList(files)); } } else { log.warn("Failed to create new subdirectory \"{}\" in the target path \"{}\".", relativePath, target); } } else { File newFile = new File(target, relativePath); if (newFile.createNewFile()) { FileInputStream inStream = null; FileOutputStream outStream = null; try { inStream = new FileInputStream(aFile); outStream = new FileOutputStream(newFile); streamCopy(inStream, outStream); } finally { if (inStream != null) { try { inStream.close(); } catch (Exception e) { } } if (outStream != null) { try { outStream.flush(); } catch (Exception e) { } try { outStream.close(); } catch (Exception e) { } } } newFile.setExecutable(aFile.canExecute(), false); newFile.setReadable(aFile.canRead(), false); newFile.setWritable(aFile.canWrite(), false); newFile.setLastModified(aFile.lastModified()); } } } } }
From source file:net.morphbank.mbsvc3.webservices.RestfulService.java
public String[] getReqFileNames() { File dir = new File(filepath); // It is also possible to filter the list of returned files. // This example does not return any files that start with `.'. FilenameFilter filter = new FilenameFilter() { public boolean accept(File dir, String name) { return name.startsWith(FILE_PREFIX); }/*from w ww . j ava 2s. c o m*/ }; String[] children = dir.list(filter); return children; }
From source file:com.morty.podcast.writer.PodCastGenerator.java
private List processMainDirectory() throws Exception { m_logger.info("Processing directories"); List returnList = new ArrayList(); //Process the directory File directory = new File(m_directoryToTraverse); if (m_validator != null) { m_logger.info("Starting validation"); m_validator.setExcludedFolders(m_excludedFolders); m_validator.setFolderToProcess(directory); m_validator.setFailOnError(m_failOnValidation); m_validator.process();// w ww . ja va 2 s . c o m m_logger.info("Finished validation"); } //Allow folder exclusion File[] modules = directory.listFiles(new FilenameFilter() { public boolean accept(File file, String fileToCheck) { m_logger.debug("Checking module [" + fileToCheck + "]"); //if not in list, then accept. If in list, then reject the folder if (m_excludedFolders == null || m_excludedFolders.isEmpty()) return true; else if (m_excludedFolders.contains(fileToCheck)) { m_logger.debug("Skipping excluded folder [" + fileToCheck + "]"); //Put these files in the list with an excluded reason m_ignoredFiles.put(file.getAbsolutePath() + File.separator + fileToCheck, PodCastConstants.FILE_EXCLUDED); return false; } else return true; } }); for (int i = 0; i < modules.length; i++) { if (modules[i].isDirectory()) { String category = modules[i].getName(); m_logger.info("Processing module [" + category + "]"); File categoryDirectory = new File(modules[i].getAbsolutePath()); File[] originalFiles = categoryDirectory.listFiles(); PodCastFile[] podcastFiles = new PodCastFile[originalFiles.length]; Map parentDirectoryProperties = processInfoFile(categoryDirectory); //Convert all the files to PodCastFiles in the array. for (int counter = 0; counter < podcastFiles.length; counter++) { //Create a podcast file with a construct of file path (preconverted to UTF8). //That way all files should exist, even if they have weird characters and every getName will //also contain the right characters! podcastFiles[counter] = new PodCastFile( PodCastUtils.convertToUTF8(originalFiles[counter].getAbsolutePath())); podcastFiles[counter].setParentProperties(parentDirectoryProperties); fileResolver.formatFile(podcastFiles[counter]); } for (int p = 0; p < podcastFiles.length; p++) { if (!podcastFiles[p].isValid()) { m_logger.warn( "Ignoring hidden/unresolved or info file [" + podcastFiles[p].getName() + "]"); m_ignoredFiles.put(podcastFiles[p].getAbsolutePath(), podcastFiles[p].getProperty(PodCastFileProperties.INVALID_REASON)); } else returnList.add(processFile(podcastFiles[p], category, parentDirectoryProperties)); } } else m_logger.info("Skipping Loose File [" + modules[i] + "]"); } return returnList; }
From source file:com.appeligo.search.actions.ProgramAction.java
public String execute() throws Exception { if (programId != null && programId.length() > 0) { StringBuilder sb = getCookieValue(); sb.append("|query="); String query = getQuery(); query = query == null ? query : query.replace("|", "\\|"); sb.append(query);//w ww . jav a 2 s.co m sb.append("|programId="); sb.append(programId); queryLog.info(sb.toString()); SearchResults results = (SearchResults) getSession().get(CaptionSearchAction.KEY); //I'm doing the seach again in case the session expired, but they book marked the page. //This way it should still work, unless program falls on a different page. //TODO: Think about how to fix that! if (results != null) { searchResult = results.getSearchResult(programId); if (searchResult != null) { fragments = searchResult.getDoc().getFragments(); } } else { log.debug( "SearchResults were not in the session. Either an old session or it is not coming from a search page"); } Configuration config = ConfigUtils.getSystemConfig(); EPGProvider epgProvider = DefaultEpg.getInstance(); String lineup = getLineup(); //Pull the data for the program from the EPG. programInfo = epgProvider.getProgram(programId); if (!fromPath) { return REDIRECT; } nextAiring = epgProvider.getNextShowing(lineup, programId, false, true); lastAiring = epgProvider.getLastShowing(lineup, programId); if (programInfo.isSports()) { awayTeam = epgProvider.getProgramForTeam(programInfo.getSportName(), programInfo.getAwayTeamName()); homeTeam = epgProvider.getProgramForTeam(programInfo.getSportName(), programInfo.getHomeTeamName()); } if (getUser() != null) { if (programInfo.isEpisode() || programInfo.isSports()) { episodeAlerts = ProgramAlert.getByProgramId(getUser(), programId); Collections.sort(episodeAlerts, PROGRAM_ALERT_COMPARATOR); } if (programInfo.isSports()) { teamAlerts = new LinkedList<ProgramAlert>( ProgramAlert.getByProgramId(getUser(), awayTeam.getProgramId())); teamAlerts.addAll(ProgramAlert.getByProgramId(getUser(), homeTeam.getProgramId())); Collections.sort(teamAlerts, PROGRAM_ALERT_COMPARATOR); } else { seriesAlerts = ProgramAlert.getByProgramId(getUser(), programInfo.getShowId()); Collections.sort(seriesAlerts, PROGRAM_ALERT_COMPARATOR); } } String previewUrlRoot = "/previews"; String documentRoot = config.getString("documentRoot"); String urlPath = EpgUtils.getPreviewDir(previewUrlRoot, programInfo); String directory = documentRoot + urlPath; String titleFileName = directory + "/" + programInfo.getProgramId() + ".title"; /* log.warn("previewUrlRoot="+previewUrlRoot); log.warn("urlPath="+urlPath); log.warn("documentRoot="+documentRoot); log.warn("directory="+directory); log.warn("previewUrlPrefix="+previewUrlPrefix); log.warn("previewFilePrefix="+previewFilePrefix); */ File titleFile = new File(titleFileName); if (titleFile.exists()) { File dirFile = new File(directory); String[] filenames = dirFile.list(new FilenameFilter() { public boolean accept(File dir, String name) { if (name.startsWith(programInfo.getProgramId()) && name.endsWith(".flv")) { return true; } return false; } }); if (filenames.length > 0) { Arrays.sort(filenames); previewURLs = new ArrayList<String>(); for (int i = 0; i < filenames.length; i++) { previewURLs.add(urlPath + "/" + filenames[i]); } } else { previewURLs = null; } } if (programInfo != null) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, 14); List<ScheduledProgram> schedule; schedule = epgProvider.getNextShowings(lineup, programInfo.getShowId(), false, true); programGuide = new ProgramGuide(getUser(), getTimeZone(), schedule); if (schedule.size() > 0) { nextShowAiring = schedule.get(0); } } else { log.debug("Unable to find Program in EPG for :" + programId + " SearchResult was found, i.e. it came from search: " + (searchResult != null)); //This happens when we have data in the lucene index that is not in the epg. //This typically means the epg database got broken somehow, or a restore did //Not happen. It is unlikely, but catch it and report an error instead. return PROGRAM_NOT_FOUND; } } User user = getUser(); if (user != null) { int alertMinutes = user.getAlertMinutesDefault(); if (alertMinutes < 120) { setPrewarn(alertMinutes); setPrewarnUnits("Minutes"); } else if (alertMinutes < 48 * 60) { setPrewarn(alertMinutes / 60); setPrewarnUnits("Hours"); } else { setPrewarn(alertMinutes / 24 * 60); setPrewarnUnits("Days"); } setUsingPrimaryEmail(user.isUsingPrimaryEmailDefault()); setUsingSMS(user.isUsingSMSDefault()); } else { setPrewarn(15); setPrewarnUnits("Minutes"); setUsingPrimaryEmail(true); } if (user != null) { if (programInfo.isEpisode()) { favoriteEpisode = Favorite.findFavoriteProgram(user, programInfo.getProgramId()); episodeRating = Rating.findProgramRating(user, programInfo.getProgramId()); } favoriteShow = Favorite.findFavoriteProgram(user, programInfo.getShowId()); showRating = Rating.findProgramRating(user, programInfo.getShowId()); } return SUCCESS; }