Java Code Examples for org.jivesoftware.util.JiveGlobals#getHomeDirectory()

The following examples show how to use org.jivesoftware.util.JiveGlobals#getHomeDirectory() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CrowdProperties.java    From Openfire with Apache License 2.0 6 votes vote down vote up
public CrowdProperties() throws IOException {
    props = new Properties();
    
    File file = new File(JiveGlobals.getHomeDirectory() + File.separator + "conf" + File.separator + "crowd.properties");
    if (!file.exists()) {
        throw new IOException("The file crowd.properties is missing from Openfire conf folder");
    } else {
        try {
            props.load(new FileInputStream(file));
        } catch (IOException ioe) {
            throw new IOException("Unable to load crowd.properties file");
        }
    }
    
    // checking for required info in file
    if (StringUtils.isBlank(props.getProperty(APPLICATION_NAME))
            || StringUtils.isBlank(props.getProperty(APPLICATION_PASSWORD))
            || StringUtils.isBlank(props.getProperty(CROWD_SERVER_URL))) {
        
        throw new IOException("crowd.properties is missing required information (app name, app passwd, crowd url)");
    }
}
 
Example 2
Source File: HttpBindManager.java    From Openfire with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a Jetty context handler that can be used to expose static files.
 *
 * Note that an invocation of this method will not register the handler (and thus make the related functionality
 * available to the end user). Instead, the created handler is returned by this method, and will need to be
 * registered with the embedded Jetty webserver by the caller.
 *
 * @return A Jetty context handler, or null when the static content could not be accessed.
 */
protected Handler createStaticContentHandler()
{
    final File spankDirectory = new File( JiveGlobals.getHomeDirectory() + File.separator + "resources" + File.separator + "spank" );
    if ( spankDirectory.exists() )
    {
        if ( spankDirectory.canRead() )
        {
            final WebAppContext context = new WebAppContext( null, spankDirectory.getPath(), "/" );
            context.setWelcomeFiles( new String[] { "index.html" } );

            return context;
        }
        else
        {
            Log.warn( "Openfire cannot read the directory: " + spankDirectory );
        }
    }
    return null;
}
 
Example 3
Source File: EmbeddedConnectionProvider.java    From Openfire with Apache License 2.0 6 votes vote down vote up
@Override
public void start() {
    File databaseDir = new File(JiveGlobals.getHomeDirectory(), File.separator + "embedded-db");
    // If the database doesn't exist, create it.
    if (!databaseDir.exists()) {
        databaseDir.mkdirs();
    }

    try {
        serverURL = "jdbc:hsqldb:" + databaseDir.getCanonicalPath() + File.separator + "openfire";
    }
    catch (IOException ioe) {
        Log.error("EmbeddedConnectionProvider: Error starting connection pool: ", ioe);
    }
    final ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(serverURL, "sa", "");
    final PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, null);
    poolableConnectionFactory.setMaxConnLifetimeMillis((long) (0.5 * JiveConstants.DAY));

    final GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
    poolConfig.setMinIdle(3);
    poolConfig.setMaxTotal(25);
    final GenericObjectPool<PoolableConnection> connectionPool = new GenericObjectPool<>(poolableConnectionFactory, poolConfig);
    poolableConnectionFactory.setPool(connectionPool);
    dataSource = new PoolingDataSource<>(connectionPool);
}
 
Example 4
Source File: OfMeetPlugin.java    From openfire-ofmeet-plugin with Apache License 2.0 5 votes vote down vote up
private void checkDownloadFolder(File pluginDirectory)
{
    String ofmeetHome = JiveGlobals.getHomeDirectory() + File.separator + "resources" + File.separator + "spank" + File.separator + "ofmeet-cdn";

    try
    {
        File ofmeetFolderPath = new File(ofmeetHome);

        if(!ofmeetFolderPath.exists())
        {
            ofmeetFolderPath.mkdirs();
        }

        List<String> lines = Arrays.asList("Move on, nothing here....");
        Path file = Paths.get(ofmeetHome + File.separator + "index.html");
        Files.write(file, lines, Charset.forName("UTF-8"));

        File downloadHome = new File(ofmeetHome + File.separator + "download");

        if(!downloadHome.exists())
        {
            downloadHome.mkdirs();
        }

        lines = Arrays.asList("Move on, nothing here....");
        file = Paths.get(downloadHome + File.separator + "index.html");
        Files.write(file, lines, Charset.forName("UTF-8"));
    }
    catch (Exception e)
    {
        Log.error("checkDownloadFolder", e);
    }
}
 
Example 5
Source File: UpdateManager.java    From Openfire with Apache License 2.0 5 votes vote down vote up
private void loadAvailablePluginsInfo() {
    Document xmlResponse;
    File file = new File(JiveGlobals.getHomeDirectory() + File.separator + "conf",
            "available-plugins.xml");
    if (!file.exists()) {
        return;
    }
    // Check read privs.
    if (!file.canRead()) {
        Log.warn("Cannot retrieve available plugins. File must be readable: " + file.getName());
        return;
    }
    try (FileReader reader = new FileReader(file)) {
        SAXReader xmlReader = new SAXReader();
        xmlReader.setEncoding("UTF-8");
        xmlResponse = xmlReader.read(reader);
    } catch (Exception e) {
        Log.error("Error reading available-plugins.xml", e);
        return;
    }

    // Parse info and recreate available plugins
    Iterator it = xmlResponse.getRootElement().elementIterator("plugin");
    while (it.hasNext()) {
        Element plugin = (Element) it.next();
        final AvailablePlugin instance = AvailablePlugin.getInstance( plugin );
        // Add plugin to the list of available plugins at js.org
        availablePlugins.put(instance.getName(), instance);
    }
}
 
Example 6
Source File: WebDAVLiteServlet.java    From Openfire with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize the WebDAV servlet, auto-creating it's file root if it doesn't exist.
 *
 * @param servletConfig Configuration settings of the servlet from web.xml.
 * @throws ServletException If there was an exception setting up the servlet.
 */
@Override
public void init(ServletConfig servletConfig) throws ServletException {
    super.init(servletConfig);
    File webdavDir = new File(JiveGlobals.getHomeDirectory(), WEBDAV_SUBDIR);
    if (!webdavDir.exists()) {
        webdavDir.mkdirs();
    }
}
 
Example 7
Source File: InternalComponentManager.java    From Openfire with Apache License 2.0 4 votes vote down vote up
public String getHomeDirectory() {
    return JiveGlobals.getHomeDirectory();
}
 
Example 8
Source File: WebDAVLiteServlet.java    From Openfire with Apache License 2.0 2 votes vote down vote up
/**
 * Retrieves a File object referring to a file in a service and room.  Leaving file as null
 * will get you the directory that would contain all of the files for a particular service and room.
 *
 * @param service Subdomain of the conference service we are forming a file path for.
 * @param room Conference room we are forming a file path for.
 * @param file Optional (can be null) filename for a path to a specific file (otherwise, directory).
 * @return The File reference constructed for the service, room, and file combination.
 */
private File getFileReference(String service, String room, String file) {
    return new File(JiveGlobals.getHomeDirectory(), WEBDAV_SUBDIR+File.separator+service+File.separator+room+(file != null ? File.separator+file : ""));
}