protected void initExtensions(ClassLoader extensionClassLoader) { /* We break the general rule that you shouldn't catch Throwable, because we don't want extensions to crash SoapUI. */ try { String extDir = System.getProperty("soapui.ext.listeners"); addExternalListeners( FilenameUtils.normalize( extDir != null ? extDir : root == null ? "listeners" : root + File.separatorChar + "listeners"), extensionClassLoader); } catch (Throwable e) { SoapUI.logError(e, "Couldn't load external listeners"); } try { String factoriesDir = System.getProperty("soapui.ext.factories"); addExternalFactories( FilenameUtils.normalize( factoriesDir != null ? factoriesDir : root == null ? "factories" : root + File.separatorChar + "factories"), extensionClassLoader); } catch (Throwable e) { SoapUI.logError(e, "Couldn't load external factories"); } }
public boolean isSame(final File baseFolder, final MMapURI file) { final File theFile = this.fileUri.asFile(baseFolder); final File thatFile = file.asFile(baseFolder); final String theFilePath = FilenameUtils.normalize(theFile.getAbsolutePath()); final String thatFilePath = FilenameUtils.normalize(thatFile.getAbsolutePath()); return theFilePath.equals(thatFilePath); }
/** Create a temporary file in {@link FsPlugin#getCacheDir()} to store the new shapefile in. */ public ShapefileGenerator(ILayer layer, IContentSite site) { File tmpDir = FsPlugin.getDefault().getCacheDir(); String basename = FilenameUtils.normalize(layer.getLabel()); String projectname = FilenameUtils.normalize(layer.getMap().getLabel()); String username = site.getUserName() != null ? site.getUserName() : "null"; File basedir = new File(tmpDir, username + "@" + projectname + "@" + basename); basedir.mkdirs(); this.newFile = new File(basedir, basename + ".shp"); }
/** * @param context in the form of /foo * @param parent in the form of /foo/bar/ or /foo/bar/dar.jss * @param scriptPath in the form of /foo/bar/mar.jss or bar/mar.jss * @return String[] with keys */ public static String[] getKeys(String context, String parent, String scriptPath) { String path; String normalizedScriptPath; context = context.equals("") ? "/" : context; normalizedScriptPath = scriptPath.startsWith("/") ? FilenameUtils.normalize(scriptPath, true) : FilenameUtils.normalize(FilenameUtils.getFullPath(parent) + scriptPath, true); path = FilenameUtils.getFullPath(normalizedScriptPath); // remove trailing "/" path = path.equals("/") ? path : path.substring(0, path.length() - 1); normalizedScriptPath = "/" + FilenameUtils.getName(normalizedScriptPath); return new String[] {context, path, normalizedScriptPath}; }
public boolean hasParent(final File baseFolder, final MMapURI folder) { final File theFile = this.fileUri.asFile(baseFolder); final File thatFile = folder.asFile(baseFolder); final String theFilePath = FilenameUtils.normalize(theFile.getAbsolutePath()); final String thatFilePath = ensureFolderPath(FilenameUtils.normalize(thatFile.getAbsolutePath())); if (!theFilePath.equals(thatFilePath) && theFilePath.startsWith(thatFilePath)) { final String diff = theFilePath.substring(thatFilePath.length() - 1); return diff.startsWith("\\") || diff.startsWith("/"); } else { return false; } }
/** * A method to set the output file name to a series of numbered files, using a pattern like: * * <p>fileName = String.format("%s_%03d.%s", fName, fNumber, ext); * * <p>When fName includes an extension, it is first removed and saved into ext. * * @param fName a file path + name (with or without an extension). */ private static void createOutputStream(String fName) throws Exception { fName = FilenameUtils.normalize(fName); String name = FilenameUtils.removeExtension(fName); String ext = FilenameUtils.getExtension(fName); if (oSerializeFormat.equals("turtle")) { ext = "ttl"; } else if (oSerializeFormat.equals("Ntriples")) { ext = "nt"; } else if (ext.equals("")) { ext = "txt"; } fName = String.format("%s_%03d.%s", name, ++oFileNumber, ext); oFile = new File(fName); try { oStream.close(); oStream = new PrintStream(new FileOutputStream(oFile)); if (oSerializeFormat.equals("turtle")) { oStream.println(SparqlPrefixes.ttlMappingPrefix()); oStream.println(); if (oFileNumber == 1) { oStream.println(loomInfo.ttlSignature()); oStream.println(); } } } catch (Exception e) { log.fatal("Cannot create output file stream: {}", oFile.getAbsolutePath()); throw e; } }
/** @return */ public static String getDefaultPathToWebLogicJar() { String envWlHome = System.getenv(WebLogicDeploymentPluginConstantes.WL_HOME_ENV_VAR_NAME); return FilenameUtils.normalize( envWlHome + WebLogicDeploymentPluginConstantes.WL_HOME_LIB_DIR + WebLogicDeploymentPluginConstantes.WL_WEBLOGIC_LIBRARY_NAME); }
protected TableDefinition getFicstarTableDefinition(DataFile dataFile) throws IOException { RetailerSite retailerSite = dataFile.getRetailerSite(); File schemaFile = this.getFicstarSchemaFile(); DataImportConfig dataImportConfig = applicationContext.getBean("dataImportConfig", DataImportConfig.class); dataImportConfig.setConfigFilePath(schemaFile.getAbsolutePath()); dataImportConfig.afterPropertiesSet(); // now the config is ready. Schema schema = dataImportConfig.getSchema(); TableDefinition tableDefinition = schema.getDefinitionByDestination(dataFile.getImportType()); Assert.notNull( tableDefinition, "cannot find tableDefinition for :=" + dataFile.getImportType() + " in schema :=" + schemaFile.getAbsolutePath()); String csvFilePath = FilenameUtils.normalize( configurationService.getFileSystem().getFileSystemAsString() + "/" + dataFile.getFilePath()); tableDefinition.setProperty("path", csvFilePath); tableDefinition.setProperty("relativePath", dataFile.getFilePath()); tableDefinition.setProperty("isPathAbsolute", "true"); // some feeds like google dont have siteName == RetailerSiteName tableDefinition.setProperty("columns.siteName.defaultValue", retailerSite.getSiteName()); return tableDefinition; }
public boolean isSameOrHasParent(final File baseFolder, final MMapURI file) { final File theFile = this.fileUri.asFile(baseFolder); final File thatFile = file.asFile(baseFolder); final String theFilePath = FilenameUtils.normalize(theFile.getAbsolutePath()); final String thatFilePath = FilenameUtils.normalize(thatFile.getAbsolutePath()); if (theFilePath.startsWith(thatFilePath)) { final String diff = theFilePath.substring(thatFilePath.length()); return diff.isEmpty() || diff.startsWith("\\") || diff.startsWith("/") || thatFilePath.endsWith("/") || thatFilePath.endsWith("\\"); } else { return false; } }
private String getResourceHref(String requestUrl) { String resourceHref = requestUrl.toString().substring(IMAGE_URL_PREFIX.length()); resourceHref = currentFolder + resourceHref; resourceHref = FilenameUtils.normalize(resourceHref); // normalize uses the SYSTEM_SEPARATOR, which on windows is a '\' // replace with '/' to make it href '/' resourceHref = resourceHref.replaceAll("\\\\", "/"); return resourceHref; }
// main with super GUI :-) public static void main(String... args) throws IOException { Options opt = new Options(); opt.addOption(getOption("h", false, false, "Print usage")); opt.addOption(getOption("in", true, true, "The log file to parse")); opt.addOption(getOption("out", true, true, "Output directory or file for a -list")); BasicParser parser = new BasicParser(); CommandLine cl; try { cl = parser.parse(opt, args); } catch (MissingOptionException e) { HelpFormatter f = new HelpFormatter(); f.printHelp(e.getMessage(), opt); System.exit(1); return; } catch (ParseException e) { throw new RuntimeException(e); } if (cl.hasOption('h')) { HelpFormatter f = new HelpFormatter(); f.printHelp("OptionsTip", opt); System.exit(0); return; } long begin = System.currentTimeMillis(); String inputFile = FilenameUtils.normalize(cl.getOptionValue("in")); String outputFile = FilenameUtils.normalize(cl.getOptionValue("out")); // here we work Cda2Graph cda2Graphviz = new Cda2Graph(); cda2Graphviz.makeGraph(inputFile, outputFile); // cda2Graphviz.makeiPhoneGraph(outputFile); cda2Graphviz.createNeo4jGraph(); long time = System.currentTimeMillis() - begin; System.out.println("Took : " + time + " ms to execute"); }
private String determineSuggestedDirectory(Project project) { String currentDirectory = StringUtils.hasContent(project.getResourceRoot()) ? project.getResourceRoot() : project.getPath(); if (!StringUtils.hasContent(currentDirectory)) { return System.getProperty("user.dir", "."); } else if (holder.getModelItem() instanceof AbstractWsdlModelItem) { String expandedPath = PathUtils.expandPath( currentDirectory, ((AbstractWsdlModelItem) (holder.getModelItem()))); return FilenameUtils.normalize(expandedPath); } else { return currentDirectory; } }
public ClazzpathUnit addClazzpathUnit(final File pFile, final String pId) throws IOException { if (pFile.isFile()) { return addClazzpathUnit(new FileInputStream(pFile), pId); } if (pFile.isDirectory()) { final String prefix = FilenameUtils.separatorsToUnix( FilenameUtils.normalize( new StringBuilder(pFile.getAbsolutePath()) .append(File.separatorChar) .toString())); final boolean recursive = true; @SuppressWarnings("unchecked") final Iterator<File> files = FileUtils.iterateFiles(pFile, new String[] {"class"}, recursive); return addClazzpathUnit( new Iterable<Resource>() { public Iterator<Resource> iterator() { return new Iterator<Clazzpath.Resource>() { public boolean hasNext() { return files.hasNext(); } public Resource next() { final File file = files.next(); return new Resource(file.getAbsolutePath().substring(prefix.length())) { @Override InputStream getInputStream() throws IOException { return new FileInputStream(file); } }; } public void remove() { throw new UnsupportedOperationException(); } }; } }, pId, true); } throw new IllegalArgumentException(); }
@Test public void addAndGetObject1() throws Exception { fs.addObject(newObject); FileSystemDigitalObject addedObject = (FileSystemDigitalObject) fs.getObject("oai:eprints.usq.edu.au:318"); Assert.assertEquals( FilenameUtils.normalize( tmpDir + "/_fs_test/d0b1c5bd0660ad67a16b7111aafc9389/" + "e2/92/e292378c5b38b0d5a4aba11fd40e7151"), addedObject.getPath().getAbsolutePath()); List<Payload> payloads = addedObject.getPayloadList(); Assert.assertEquals(1, payloads.size()); Payload payload = payloads.get(0); Assert.assertEquals("Dublin Core Metadata", payload.getLabel()); }
@Test public void addAndGetObject2() throws Exception { fs.addObject(fileObject); FileSystemDigitalObject addedObject = (FileSystemDigitalObject) fs.getObject("/Users/fascinator/Documents/sample.odt"); Assert.assertEquals( FilenameUtils.normalize( tmpDir + "/_fs_test/d0b1c5bd0660ad67a16b7111aafc9389/" + "11/b4/11b498d057256a0b602fa0e7c4073fc3"), addedObject.getPath().getAbsolutePath()); List<Payload> payloads = addedObject.getPayloadList(); Assert.assertEquals(2, payloads.size()); Payload payload1 = addedObject.getPayload("sample.odt"); Assert.assertEquals("ICE Sample Document", payload1.getLabel()); Payload payload2 = addedObject.getPayload("images/ice-services.png"); Assert.assertEquals("ICE Services Diagram", payload2.getLabel()); }
@SuppressWarnings("unchecked") protected void handleFile(File file, int depth, Collection results) { File f = new File(FilenameUtils.normalize(file.getAbsolutePath())); logger.debug(f.getAbsoluteFile()); try { HtmlCleaner cleaner = new HtmlCleaner(); cleaner.setTransformations(ct); CleanerProperties props = cleaner.getProperties(); props.setAdvancedXmlEscape(false); // props.setTranslateSpecialEntities(false); // props.setRecognizeUnicodeChars(false); TagNode node = cleaner.clean(f); TagNode tnBody = node.getAllElements(false)[1]; List l = tnBody.getChildren(); if (l != null && l.size() > 0) { // This is a hack to remove the <?xml in the beginning of body tnBody.removeChild(l.get(0)); } Document myJDom = new JDomSerializer(props, true).createJDom(node); // Format format = Format.getRawFormat(); Format format = new OutputFormat(); format.setEncoding("iso-8859-1"); XMLWriter outputter = new XMLWriter(format); OutputStream os = new FileOutputStream(f); // outputter.output(myJDom,os); output.setOutputStream(os); output.write(myJDom); // sbResult.append(outputter.outputString(myJDom)); results.add(f.getAbsoluteFile()); } catch (IOException e) { logger.error("", e); } }
/** * Both root and file are absolute paths to files. This constructor calculates the relative part * of the second argument based on the first. */ public RepoFile(File root, File file) { this.fs = new FsFile(file); this.root = FilenameUtils.normalize(root.getAbsolutePath()); this.rel = fs.path.substring((int) this.root.length()); this.absPath = new File(root, rel).getAbsolutePath(); }
FsFile(String path) { this.path = FilenameUtils.normalize(path); this.name = FilenameUtils.getName(this.path); }
public String getRoot() { if (root == null || root.length() == 0) { root = System.getProperty("soapui.home", new File(".").getAbsolutePath()); } return FilenameUtils.normalize(root); }
/** * @param ftpAuthRequest one of {@link org.apache.ftpserver.usermanager.AnonymousAuthentication} * or {@link org.apache.ftpserver.usermanager.UsernamePasswordAuthentication} * @throws AuthenticationFailedException if given an {@code AnonymousAuthentication}, or an * invalid/disabled user credentials * @see UserManager#authenticate(Authentication) */ public User authenticate(final Authentication ftpAuthRequest) throws AuthenticationFailedException { if (!(ftpAuthRequest instanceof UsernamePasswordAuthentication)) { throw new AuthenticationFailedException(); } final UsernamePasswordAuthentication upa = (UsernamePasswordAuthentication) ftpAuthRequest; final String principal = upa.getUsername(); final String credentials = upa.getPassword(); org.springframework.security.core.Authentication gsAuth = new UsernamePasswordAuthenticationToken(principal, credentials); try { gsAuth = authManager.authenticate(gsAuth); } catch (org.springframework.security.core.AuthenticationException authEx) { throw new AuthenticationFailedException(authEx); } try { // gather the user BaseUser user = getUserByName(principal); user.setPassword(credentials); // is the user enabled? if (!user.getEnabled()) { throw new AuthenticationFailedException(); } // scary message for admins if the username/password has not // been changed if (DEFAULT_USER.equals(user.getName()) && DEFAULT_PASSWORD.equals(credentials)) { LOGGER.log( Level.SEVERE, "The default admin/password combination has not been " + "modified, this makes the embedded FTP server an " + "open file host for everybody to use!!!"); } final File dataRoot = dataDir.findOrCreateDataRoot(); // enable only admins and non anonymous users boolean isGSAdmin = false; for (GrantedAuthority authority : gsAuth.getAuthorities()) { final String userRole = authority.getAuthority(); if (ADMIN_ROLE.equals(userRole)) { isGSAdmin = true; break; } } final File homeDirectory; if (isGSAdmin) { homeDirectory = dataRoot; } else { /* * This resolves the user's home directory to data/incoming/<user name> but does not * create the directory if it does not already exist. That is left to when the user * is authenticated, check the authenticate() method above. */ homeDirectory = new File(new File(dataRoot, "incoming"), user.getName()); } String normalizedPath = homeDirectory.getAbsolutePath(); normalizedPath = FilenameUtils.normalize(normalizedPath); user.setHomeDirectory(normalizedPath); if (!homeDirectory.exists()) { LOGGER.fine( "Creating FTP home directory for user " + user.getName() + " at " + normalizedPath); homeDirectory.mkdirs(); } return user; } catch (AuthenticationFailedException e) { throw e; } catch (Exception e) { LOGGER.log(Level.INFO, "FTP authentication failure", e); throw new AuthenticationFailedException(e); } }
public String getMessageFilesCacheUrl() { return FilenameUtils.separatorsToUnix(FilenameUtils.normalize(languagesCacheUrl)); }
FileLocation(File directory, File file) { this.directoryPath = FilenameUtils.normalize(directory.getAbsolutePath()); this.filePath = FilenameUtils.normalize(file.getAbsolutePath()); }
@SuppressWarnings("unchecked") protected void handleFile(File file, int depth, Collection results) { File f = new File(FilenameUtils.normalize(file.getAbsolutePath())); logger.debug(f.getAbsoluteFile()); try { HtmlCleaner cleaner = new HtmlCleaner(); cleaner.setTransformations(ct); CleanerProperties props = cleaner.getProperties(); // props.setAdvancedXmlEscape(false); props.setUseEmptyElementTags(false); // props.setTranslateSpecialEntities(false); // props.setRecognizeUnicodeChars(false); TagNode node = cleaner.clean(f); TagNode tnBody = node.getAllElements(false)[1]; List l = tnBody.getChildren(); if (l != null && l.size() > 0) { // This is a hack to remove the <?xml in the beginning of body tnBody.removeChild(l.get(0)); } for (int i = 1; i <= anzElements; i++) { String tag = config.getString("substitute[" + i + "]/@tag"); String att = config.getString("substitute[" + i + "]/@att"); String from = config.getString("substitute[" + i + "]/from"); String to = config.getString("substitute[" + i + "]/to"); to = subSpecial(to); TagNode[] imgs = node.getElementsByName(tag, true); for (TagNode tn : imgs) { String srcAtt = tn.getAttributeByName(att); int index = srcAtt.indexOf(from); if (index >= 0) { tn.addAttribute(att, to); } } } BrowserCompactXmlSerializer serializer = new BrowserCompactXmlSerializer(props); // PrettyXmlSerializer serializer = new PrettyXmlSerializer(props); String s = serializer.getXmlAsString(node, "ISO-8859-1"); Writer fw = null; try { fw = new FileWriter(f); fw.write(s); } catch (IOException e) { logger.error("", e); } finally { if (fw != null) try { fw.close(); } catch (IOException e) { } } results.add(f.getAbsoluteFile()); } catch (IOException e) { logger.error("", e); } }
public static int unpackFileToFolder( @Nonnull final Log logger, @Nullable final String folder, @Nonnull final File archiveFile, @Nonnull final File destinationFolder, final boolean makeAllExecutable) throws IOException { final String normalizedName = archiveFile.getName().toLowerCase(Locale.ENGLISH); final ArchEntryGetter entryGetter; boolean modeZipFile = false; final ZipFile theZipFile; final ArchiveInputStream archInputStream; if (normalizedName.endsWith(".zip")) { logger.debug("Detected ZIP archive"); modeZipFile = true; theZipFile = new ZipFile(archiveFile); archInputStream = null; entryGetter = new ArchEntryGetter() { private final Enumeration<ZipArchiveEntry> iterator = theZipFile.getEntries(); @Override @Nullable public ArchiveEntry getNextEntry() throws IOException { ArchiveEntry result = null; if (this.iterator.hasMoreElements()) { result = this.iterator.nextElement(); } return result; } }; } else { theZipFile = null; final InputStream in = new BufferedInputStream(new FileInputStream(archiveFile)); try { if (normalizedName.endsWith(".tar.gz")) { logger.debug("Detected TAR.GZ archive"); archInputStream = new TarArchiveInputStream(new GZIPInputStream(in)); entryGetter = new ArchEntryGetter() { @Override @Nullable public ArchiveEntry getNextEntry() throws IOException { return ((TarArchiveInputStream) archInputStream).getNextTarEntry(); } }; } else { logger.debug("Detected OTHER archive"); archInputStream = ARCHIVE_STREAM_FACTORY.createArchiveInputStream(in); logger.debug("Created archive stream : " + archInputStream.getClass().getName()); entryGetter = new ArchEntryGetter() { @Override @Nullable public ArchiveEntry getNextEntry() throws IOException { return archInputStream.getNextEntry(); } }; } } catch (ArchiveException ex) { IOUtils.closeQuietly(in); throw new IOException("Can't recognize or read archive file : " + archiveFile, ex); } catch (CantReadArchiveEntryException ex) { IOUtils.closeQuietly(in); throw new IOException("Can't read entry from archive file : " + archiveFile, ex); } } try { final String normalizedFolder = folder == null ? null : FilenameUtils.normalize(folder, true) + '/'; int unpackedFilesCounter = 0; while (true) { final ArchiveEntry entry = entryGetter.getNextEntry(); if (entry == null) { break; } final String normalizedPath = FilenameUtils.normalize(entry.getName(), true); logger.debug("Detected archive entry : " + normalizedPath); if (normalizedFolder == null || normalizedPath.startsWith(normalizedFolder)) { final File targetFile = new File( destinationFolder, normalizedFolder == null ? normalizedPath : normalizedPath.substring(normalizedFolder.length())); if (entry.isDirectory()) { logger.debug("Folder : " + normalizedPath); if (!targetFile.exists() && !targetFile.mkdirs()) { throw new IOException("Can't create folder " + targetFile); } } else { final File parent = targetFile.getParentFile(); if (parent != null && !parent.isDirectory() && !parent.mkdirs()) { throw new IOException("Can't create folder : " + parent); } final FileOutputStream fos = new FileOutputStream(targetFile); try { if (modeZipFile) { logger.debug("Unpacking ZIP entry : " + normalizedPath); final InputStream zipEntryInStream = theZipFile.getInputStream((ZipArchiveEntry) entry); try { if (IOUtils.copy(zipEntryInStream, fos) != entry.getSize()) { throw new IOException( "Can't unpack file, illegal unpacked length : " + entry.getName()); } } finally { IOUtils.closeQuietly(zipEntryInStream); } } else { logger.debug("Unpacking archive entry : " + normalizedPath); if (!archInputStream.canReadEntryData(entry)) { throw new IOException("Can't read archive entry data : " + normalizedPath); } if (IOUtils.copy(archInputStream, fos) != entry.getSize()) { throw new IOException( "Can't unpack file, illegal unpacked length : " + entry.getName()); } } } finally { fos.close(); } if (makeAllExecutable) { try { targetFile.setExecutable(true, true); } catch (SecurityException ex) { throw new IOException("Can't make file executable : " + targetFile, ex); } } unpackedFilesCounter++; } } else { logger.debug("Archive entry " + normalizedPath + " ignored"); } } return unpackedFilesCounter; } finally { IOUtils.closeQuietly(theZipFile); IOUtils.closeQuietly(archInputStream); } }
/** * Utility method used when viewing a topic. * * @param request The current servlet request object. * @param next The current Spring ModelAndView object. * @param pageInfo The current WikiPageInfo object, which contains information needed for * rendering the final JSP page. * @param pageTitle The title of the page being rendered. * @param topic The Topic object for the topic being displayed. * @param sectionEdit Set to <code>true</code> if edit links should be displayed for each section * of the topic. * @throws Exception Thrown if any error occurs during processing. */ protected static void viewTopic( HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo, WikiMessage pageTitle, Topic topic, boolean sectionEdit) throws Exception { // FIXME - what should the default be for topics that don't exist? if (topic == null) { throw new WikiException(new WikiMessage("common.exception.notopic")); } WikiUtil.validateTopicName(topic.getName()); if (topic.getTopicType() == Topic.TYPE_REDIRECT && (request.getParameter("redirect") == null || !request.getParameter("redirect").equalsIgnoreCase("no"))) { Topic child = Utilities.findRedirectedTopic(topic, 0); if (!child.getName().equals(topic.getName())) { pageInfo.setRedirectName(topic.getName()); pageTitle = new WikiMessage("topic.title", child.getName()); topic = child; } } String virtualWiki = topic.getVirtualWiki(); String topicName = topic.getName(); WikiUser user = Utilities.currentUser(); if (sectionEdit && !ServletUtil.isEditable(virtualWiki, topicName, user)) { sectionEdit = false; } ParserInput parserInput = new ParserInput(); parserInput.setContext(request.getContextPath()); parserInput.setLocale(request.getLocale()); parserInput.setWikiUser(user); parserInput.setTopicName(topicName); parserInput.setUserIpAddress(request.getRemoteAddr()); parserInput.setVirtualWiki(virtualWiki); parserInput.setAllowSectionEdit(sectionEdit); ParserDocument parserDocument = new ParserDocument(); String content = Utilities.parse(parserInput, parserDocument, topic.getTopicContent()); // FIXME - the null check should be unnecessary if (parserDocument != null && parserDocument.getCategories().size() > 0) { LinkedHashMap categories = new LinkedHashMap(); for (Iterator iterator = parserDocument.getCategories().keySet().iterator(); iterator.hasNext(); ) { String key = (String) iterator.next(); String value = key.substring( NamespaceHandler.NAMESPACE_CATEGORY.length() + NamespaceHandler.NAMESPACE_SEPARATOR.length()); categories.put(key, value); } next.addObject("categories", categories); } topic.setTopicContent(content); if (topic.getTopicType() == Topic.TYPE_CATEGORY) { loadCategoryContent(next, virtualWiki, topic.getName()); } if (topic.getTopicType() == Topic.TYPE_IMAGE || topic.getTopicType() == Topic.TYPE_FILE) { Collection fileVersions = WikiBase.getDataHandler().getAllWikiFileVersions(virtualWiki, topicName, true); for (Iterator iterator = fileVersions.iterator(); iterator.hasNext(); ) { // update version urls to include web root path WikiFileVersion fileVersion = (WikiFileVersion) iterator.next(); String url = FilenameUtils.normalize( Environment.getValue(Environment.PROP_FILE_DIR_RELATIVE_PATH) + "/" + fileVersion.getUrl()); url = FilenameUtils.separatorsToUnix(url); fileVersion.setUrl(url); } next.addObject("fileVersions", fileVersions); if (topic.getTopicType() == Topic.TYPE_IMAGE) { next.addObject("topicImage", new Boolean(true)); } else { next.addObject("topicFile", new Boolean(true)); } } pageInfo.setSpecial(false); pageInfo.setTopicName(topicName); next.addObject(ServletUtil.PARAMETER_TOPIC_OBJECT, topic); if (pageTitle != null) { pageInfo.setPageTitle(pageTitle); } }