Search in sources :

Example 1 with GXFileCollection

use of com.genexus.util.GXFileCollection in project JavaClasses by genexuslabs.

the class BaseProvider method loadQueryTables.

private void loadQueryTables() {
    if (isEnabled()) {
        String path = SpecificImplementation.Application.getModelContext().getHttpContext().getDefaultPath();
        String configurationDirectoryPath = path + File.separatorChar + "Metadata" + File.separatorChar + "TableAccess";
        ConcurrentHashMap<String, Vector<String>> qTables = new ConcurrentHashMap<String, Vector<String>>();
        GXDirectory configurationDirectory = new GXDirectory(configurationDirectoryPath);
        GXFileCollection files = configurationDirectory.getFiles();
        XMLReader reader = new XMLReader();
        short ok;
        for (int i = 1; i <= files.getItemCount(); i++) {
            Vector<String> lst = new Vector<String>();
            // Caso en que se invalido el cache manualmente
            lst.add(FORCED_INVALIDATE);
            AbstractGXFile xmlFile = files.item(i);
            reader.open(xmlFile.getAbsoluteName());
            ok = reader.readType(1, "Table");
            while (ok == 1) {
                lst.add(normalizeKey((String) reader.getAttributeByName("name")));
                ok = reader.readType(1, "Table");
            }
            reader.close();
            qTables.put(normalizeKey((String) xmlFile.getNameNoExt()), lst);
        }
        startupDate = CommonUtil.now(false, false);
        queryTables = qTables;
    }
}
Also used : GXDirectory(com.genexus.util.GXDirectory) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) GXFileCollection(com.genexus.util.GXFileCollection) Vector(java.util.Vector) AbstractGXFile(com.genexus.common.classes.AbstractGXFile) XMLReader(com.genexus.xml.XMLReader)

Example 2 with GXFileCollection

use of com.genexus.util.GXFileCollection in project JavaClasses by genexuslabs.

the class GXExternalFileInfo method listFiles.

@Override
public GXFileCollection listFiles(String filter, Object prov, String name) {
    ExternalProvider provider = (ExternalProvider) prov;
    GXFileCollection files = new GXFileCollection();
    for (String file : (filter != null) ? provider.getFiles(name, filter) : provider.getFiles(name)) {
        files.add(new GXFile(new com.genexus.util.GXExternalFileInfo(file, provider)));
    }
    return files;
}
Also used : IExtensionGXExternalFileInfo(com.genexus.common.interfaces.IExtensionGXExternalFileInfo) ExternalProvider(com.genexus.db.driver.ExternalProvider) GXFileCollection(com.genexus.util.GXFileCollection) GXFile(com.genexus.util.GXFile)

Example 3 with GXFileCollection

use of com.genexus.util.GXFileCollection in project JavaClasses by genexuslabs.

the class URLRouter method load.

private static void load() {
    String line;
    InputStream is = null;
    String defaultPath = SpecificImplementation.Application.getModelContext().getHttpContext().getDefaultPath();
    String appPackage = SpecificImplementation.Application.getClientPreferences().getPACKAGE();
    if (!appPackage.equals(""))
        appPackage = File.separatorChar + appPackage.replace('.', File.separatorChar);
    String classesDirectoryPath = defaultPath + File.separator + "WEB-INF" + File.separatorChar + "classes" + appPackage;
    GXDirectory classesDirectory = new GXDirectory(classesDirectoryPath);
    GXFileCollection rewriteFiles = classesDirectory.getFiles(".rewrite");
    if (rewriteFiles != null) {
        for (int i = 1; i <= rewriteFiles.getItemCount(); i++) {
            serverRelative = true;
            AbstractGXFile rewriteFile = rewriteFiles.item(i);
            try {
                is = SpecificImplementation.Messages.getInputStream(rewriteFile.getName());
                if (is != null) {
                    BufferedReader bufread = new BufferedReader(new InputStreamReader(is, "UTF8"));
                    line = bufread.readLine();
                    while (line != null) {
                        parseLine(line);
                        line = bufread.readLine();
                    }
                    bufread.close();
                }
            } catch (UnsupportedEncodingException e) {
                logger.error(e.toString(), e);
            } catch (FileNotFoundException e) {
                logger.info("There is no URLRouter file");
            } catch (IOException e) {
                logger.error(e.toString(), e);
            }
        }
    }
}
Also used : GXDirectory(com.genexus.util.GXDirectory) GXFileCollection(com.genexus.util.GXFileCollection) AbstractGXFile(com.genexus.common.classes.AbstractGXFile)

Aggregations

GXFileCollection (com.genexus.util.GXFileCollection)3 AbstractGXFile (com.genexus.common.classes.AbstractGXFile)2 GXDirectory (com.genexus.util.GXDirectory)2 IExtensionGXExternalFileInfo (com.genexus.common.interfaces.IExtensionGXExternalFileInfo)1 ExternalProvider (com.genexus.db.driver.ExternalProvider)1 GXFile (com.genexus.util.GXFile)1 XMLReader (com.genexus.xml.XMLReader)1 Vector (java.util.Vector)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1