Search in sources :

Example 26 with WikiEngine

use of org.apache.wiki.WikiEngine in project jspwiki by apache.

the class RSSImageLinkTag method doWikiStartTag.

/**
 *  {@inheritDoc}
 */
@Override
public final int doWikiStartTag() throws IOException {
    WikiEngine engine = m_wikiContext.getEngine();
    JspWriter out = pageContext.getOut();
    ResourceBundle rb = Preferences.getBundle(m_wikiContext, InternationalizationManager.CORE_BUNDLE);
    if (engine.getRSSGenerator() != null && engine.getRSSGenerator().isEnabled()) {
        if (RSSGenerator.MODE_FULL.equals(m_mode)) {
            String rssURL = engine.getGlobalRSSURL();
            if (rssURL != null) {
                out.print("<a class=\"feed\" href=\"" + rssURL + "\">&nbsp;</a>");
            }
        } else {
            String page = m_pageName != null ? m_pageName : m_wikiContext.getPage().getName();
            String params = "page=" + page + "&mode=" + m_mode;
            out.print("<a href='" + m_wikiContext.getURL(WikiContext.NONE, "rss.jsp", params));
            out.print("' class='feed'");
            out.print(" title='" + MessageFormat.format(rb.getString("rss.title"), page) + "'>");
            out.print("&nbsp;</a> ");
        }
    }
    return SKIP_BODY;
}
Also used : ResourceBundle(java.util.ResourceBundle) JspWriter(javax.servlet.jsp.JspWriter) WikiEngine(org.apache.wiki.WikiEngine)

Example 27 with WikiEngine

use of org.apache.wiki.WikiEngine in project jspwiki by apache.

the class WikiAjaxDispatcherServlet method validatePermission.

/**
 * Validate the permission of the {@link WikiAjaxServlet} using the {@link AuthorizationManager#checkPermission}
 *
 * @param req the servlet request
 * @param container the container info of the servlet
 * @return true if permission is valid
 */
private boolean validatePermission(HttpServletRequest req, AjaxServletContainer container) {
    final WikiEngine e = WikiEngine.getInstance(req.getSession().getServletContext(), null);
    boolean valid = false;
    if (container != null) {
        valid = e.getAuthorizationManager().checkPermission(WikiSession.getWikiSession(e, req), container.permission);
    }
    return valid;
}
Also used : WikiEngine(org.apache.wiki.WikiEngine)

Example 28 with WikiEngine

use of org.apache.wiki.WikiEngine in project jspwiki by apache.

the class JDBCGroupDatabaseTest method setUp.

/**
 */
@Before
public void setUp() throws Exception {
    m_hu.setUp();
    Properties props = TestEngine.getTestProperties();
    WikiEngine engine = new TestEngine(props);
    m_wiki = engine.getApplicationName();
    // Set up the mock JNDI initial context
    TestJNDIContext.initialize();
    Context initCtx = new InitialContext();
    try {
        initCtx.bind("java:comp/env", new TestJNDIContext());
    } catch (NameAlreadyBoundException e) {
    // ignore
    }
    Context ctx = (Context) initCtx.lookup("java:comp/env");
    DataSource ds = new TestJDBCDataSource(new File("target/test-classes/jspwiki-custom.properties"));
    ctx.bind(JDBCGroupDatabase.DEFAULT_GROUPDB_DATASOURCE, ds);
    try {
        m_conn = ds.getConnection();
    } catch (SQLException e) {
        Assert.fail("Looks like your database could not be connected to - " + "please make sure that you have started your database, exception: " + e.getMessage());
    }
    // Initialize the user database
    m_db = new JDBCGroupDatabase();
    m_db.initialize(engine, new Properties());
}
Also used : InitialContext(javax.naming.InitialContext) TestJNDIContext(org.apache.wiki.TestJNDIContext) Context(javax.naming.Context) NameAlreadyBoundException(javax.naming.NameAlreadyBoundException) TestJDBCDataSource(org.apache.wiki.TestJDBCDataSource) SQLException(java.sql.SQLException) TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) WikiEngine(org.apache.wiki.WikiEngine) TestJNDIContext(org.apache.wiki.TestJNDIContext) File(java.io.File) InitialContext(javax.naming.InitialContext) TestJDBCDataSource(org.apache.wiki.TestJDBCDataSource) DataSource(javax.sql.DataSource) Before(org.junit.Before)

Example 29 with WikiEngine

use of org.apache.wiki.WikiEngine in project jspwiki by apache.

the class XMLGroupDatabaseTest method setUp.

/**
 */
@Before
public void setUp() throws Exception {
    Properties props = TestEngine.getTestProperties();
    WikiEngine engine = new TestEngine(props);
    m_db = new XMLGroupDatabase();
    m_db.initialize(engine, props);
    m_wiki = engine.getApplicationName();
}
Also used : TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) WikiEngine(org.apache.wiki.WikiEngine) Before(org.junit.Before)

Example 30 with WikiEngine

use of org.apache.wiki.WikiEngine in project jspwiki by apache.

the class XMLUserDatabaseTest method setUp.

/**
 */
@Before
public void setUp() throws Exception {
    Properties props = TestEngine.getTestProperties();
    props.put(XMLUserDatabase.PROP_USERDATABASE, "target/test-classes/userdatabase.xml");
    WikiEngine engine = new TestEngine(props);
    m_db = new XMLUserDatabase();
    m_db.initialize(engine, props);
}
Also used : TestEngine(org.apache.wiki.TestEngine) Properties(java.util.Properties) WikiEngine(org.apache.wiki.WikiEngine) Before(org.junit.Before)

Aggregations

WikiEngine (org.apache.wiki.WikiEngine)67 WikiPage (org.apache.wiki.WikiPage)29 ProviderException (org.apache.wiki.api.exceptions.ProviderException)15 Attachment (org.apache.wiki.attachment.Attachment)10 WikiContext (org.apache.wiki.WikiContext)9 Properties (java.util.Properties)8 JspWriter (javax.servlet.jsp.JspWriter)8 TestEngine (org.apache.wiki.TestEngine)8 Element (org.jdom2.Element)7 IOException (java.io.IOException)5 SimpleDateFormat (java.text.SimpleDateFormat)5 Calendar (java.util.Calendar)5 Date (java.util.Date)5 ResourceBundle (java.util.ResourceBundle)5 PluginException (org.apache.wiki.api.exceptions.PluginException)5 Before (org.junit.Before)5 Principal (java.security.Principal)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 InternalWikiException (org.apache.wiki.InternalWikiException)4 ArrayList (java.util.ArrayList)3