Commits

Anonymous committed 9263604

Initial commit

Comments (0)

Files changed (18)

+.idea/
+*.iml
+*.ipr
+*.iws
+*.swp
+*.swo
+confluence-test/confluence-acceptance-test/target/
+confluence-core/confluence-webapp/src/main/resources/com/atlassian/confluence/setup/atlassian-bundled-plugins.zip
+confluence-core/confluence-webapp/src/main/resources/com/atlassian/confluence/setup/atlassian-bundled-plugins-dev.zip
+confluence-core/confluence-webapp/src/main/resources/com/atlassian/confluence/setup/atlassian-bundled-plugins-setup.zip
+confluence-core/confluence-webapp/target/
+confluence-core/confluence-compatibility/target/
+confluence-test/confluence-functestrpc-plugin/target/
+confluence-not-shippable/target/
+confluence-plugins/confluence-misc-plugins/confluence-rpc-plugin/target/
+confluence-test/confluence-selenium-test/target/
+confluence-core/confluence/target/
+confluence-core/confluence/test-attachments/
+confluence-core/confluence/config/
+confluence-core/confluence/logs/
+out/
+target/
+bin/
+test-output/
+bin/
+.classpath
+.project
+.settings/
+.externalToolBuilders/
+velocity.log*
+confluence-pseudo-loc/src/etc/
+.DS_Store
+.idea/
+confluence-build/confluence-webapp-cluster/overlays
+confluence-build/confluence-bundled-plugins-library/CISRR
+confluence-build/confluence-bundled-plugins-library/UPM/
+confluence-build/confluence-bundled-plugins-library/aui-plugin/
+confluence-build/confluence-bundled-plugins-library/bloggingrpc-plugin/
+confluence-build/confluence-bundled-plugins-library/chart-plugin/
+confluence-build/confluence-bundled-plugins-library/confluence-advanced-macros/
+confluence-build/confluence-bundled-plugins-library/confluence-attachment-extractors/
+confluence-build/confluence-bundled-plugins-library/confluence-attachments-plugin/
+confluence-build/confluence-bundled-plugins-library/confluence-basic-macros/
+confluence-build/confluence-bundled-plugins-library/confluence-code-macro/
+confluence-build/confluence-bundled-plugins-library/confluence-html-macros/
+confluence-build/confluence-bundled-plugins-library/confluence-image-effects/
+confluence-build/confluence-bundled-plugins-library/confluence-information-plugin/
+confluence-build/confluence-bundled-plugins-library/confluence-jira-plugin/
+confluence-build/confluence-bundled-plugins-library/confluence-json-rpc-plugin/
+confluence-build/confluence-bundled-plugins-library/confluence-layout-plugin/
+confluence-build/confluence-bundled-plugins-library/confluence-livesearch-plugin/
+confluence-build/confluence-bundled-plugins-library/confluence-macro-usage-plugin/
+confluence-build/confluence-bundled-plugins-library/confluence-masterdetail-plugin/
+confluence-build/confluence-bundled-plugins-library/confluence-profile-picture/
+confluence-build/confluence-bundled-plugins-library/confluence-userlister-plugin/
+confluence-build/confluence-bundled-plugins-library/contributors-plugin/
+confluence-build/confluence-bundled-plugins-library/dynamictasklist/
+confluence-build/confluence-bundled-plugins-library/impresence-plugin/
+confluence-build/confluence-bundled-plugins-library/jira-connector/
+confluence-build/confluence-bundled-plugins-library/mentions-plugin/
+confluence-build/confluence-bundled-plugins-library/officeconnector-2/
+confluence-build/confluence-bundled-plugins-library/officeconnector-3/
+confluence-build/confluence-bundled-plugins-library/officeconnector/
+confluence-build/confluence-bundled-plugins-library/pagetree-plugin/
+confluence-build/confluence-bundled-plugins-library/pdfexport/
+confluence-build/confluence-bundled-plugins-library/pom.xml.orig
+confluence-build/confluence-bundled-plugins-library/share-page/
+confluence-build/confluence-bundled-plugins-library/status-macro/
+confluence-build/confluence-bundled-plugins-library/threaddump/
+confluence-build/confluence-bundled-plugins-library/toc-plugin/
+confluence-build/confluence-bundled-plugins-library/usage-plugin/
+confluence-build/confluence-bundled-plugins-library/widget-connector/
+chromedriver.log
+You can find the full instructions for this tutorial here:
+
+https://developer.atlassian.com/display/CONFDEV/Working+with+Tasks+in+Confluence+Plugins
+You have successfully created a plugin using the Confluence plugin archetype!
+
+Here are the SDK commands you'll use immediately:
+
+* atlas-run   -- installs this plugin into Confluence and starts it on http://<machinename>:1990/confluence
+* atlas-debug -- same as atlas-run, but allows a debugger to attach at port 5005
+* atlas-cli   -- after atlas-run or atlas-debug, opens a Maven command line window:
+                 - 'pi' reinstalls the plugin into the running Confluence instance
+* atlas-help  -- prints description for all commands in the SDK
+
+Full documentation is always available at:
+
+https://developer.atlassian.com/display/DOCS/Developing+with+the+Atlassian+Plugin+SDK
+Copyright (c) 2011, Atlassian Pty Ltd
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+    * Neither the name of Atlassian nor the names of its contributors may be used to endorse or promote products derived from this software without
+      specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>com.atlassian.confluence.tutorials</groupId>
+    <artifactId>confluence-tasks</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <organization>
+        <name>Atlassian Docmentation</name>
+        <url>http://docs.atlassian.com/</url>
+    </organization>
+    <name>confluence-tasks</name>
+    <description>An example plugin for how to use the tasks API for Atlassian Confluence.</description>
+    <packaging>atlassian-plugin</packaging>
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.6</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.atlassian.confluence</groupId>
+            <artifactId>confluence</artifactId>
+            <version>${confluence.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.atlassian.confluence.plugin</groupId>
+            <artifactId>func-test</artifactId>
+            <version>2.3</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>net.sourceforge.jwebunit</groupId>
+            <artifactId>jwebunit-htmlunit-plugin</artifactId>
+            <version>2.2</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>net.sourceforge.nekohtml</groupId>
+            <artifactId>nekohtml</artifactId>
+            <version>1.9.12</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>2.4</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.1.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <version>1.8.5</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>com.atlassian.maven.plugins</groupId>
+                <artifactId>maven-confluence-plugin</artifactId>
+                <version>${amps.version}</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <productVersion>${confluence.version}</productVersion>
+                    <productDataVersion>${confluence.data.version}</productDataVersion>
+                    <instructions/>
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <properties>
+        <confluence.version>4.3</confluence.version>
+        <confluence.data.version>3.5</confluence.data.version>
+        <amps.version>3.11</amps.version>
+    </properties>
+</project>

src/main/java/com/atlassian/confluence/tutorials/ExampleMacro.java

+package com.atlassian.confluence.tutorials;
+
+import java.util.Map;
+import java.util.List;
+
+import com.atlassian.confluence.content.render.xhtml.ConversionContext;
+import com.atlassian.confluence.macro.Macro;
+import com.atlassian.confluence.macro.MacroExecutionException;
+import com.atlassian.confluence.pages.PageManager;
+import com.atlassian.confluence.pages.Page;
+import com.atlassian.confluence.spaces.SpaceManager;
+import com.atlassian.confluence.user.AuthenticatedUserThreadLocal;
+import com.atlassian.user.User;
+import com.opensymphony.util.TextUtils;
+
+/**
+ * This very simple macro shows you the very basic use-case of displaying *something* on the Confluence page where it is used.
+ * Use this example macro to toy around, and then quickly move on to the next example - this macro doesn't
+ * really show you all the fun stuff you can do with Confluence.
+ */
+public class ExampleMacro implements Macro
+{
+
+    // We just have to define the variables and the setters, then Spring injects the correct objects for us to use. Simple and efficient.
+    // You just need to know *what* you want to inject and use.
+
+    private final PageManager pageManager;
+    private final SpaceManager spaceManager;
+
+    public ExampleMacro(PageManager pageManager, SpaceManager spaceManager)
+    {
+        this.pageManager = pageManager;
+        this.spaceManager = spaceManager;
+    }
+
+    /**
+     * This method returns XHTML to be displayed on the page that uses this macro
+     * we just do random stuff here, trying to show how you can access the most basic
+     * managers and model objects. No emphasis is put on beauty of code nor on
+     * doing actually useful things :-)
+     */
+    @Override
+    public String execute(Map<String, String> parameters, String body, ConversionContext context) throws MacroExecutionException
+    {
+        // in this most simple example, we build the result in memory, appending HTML code to it at will.
+        // this is something you absolutely don't want to do once you start writing plugins for real. Refer
+        // to the next example for better ways to render content.
+        StringBuffer result = new StringBuffer();
+
+        // get the currently logged in user and display his name
+        User user = AuthenticatedUserThreadLocal.getUser();
+        if (user != null)
+        {
+            String greeting = "<p>Hello <b>" + TextUtils.htmlEncode(user.getFullName()) + "</b>.</p>";
+            result.append(greeting);
+        }
+
+        //get the pages added in the last 55 days to the DS space ("Demo Space"), and display them
+        List<Page> list = pageManager.getRecentlyAddedPages(55, "DS");
+        result.append("<p>");
+        result.append("Some stats for <b>Demonstration Space</b>:");
+        result.append("<table class=\"confluenceTable\">");
+        result.append("<thead><tr><th class=\"confluenceTh\">Page</th><th class=\"confluenceTh\">Number of children</th></tr></thead>");
+        result.append("<tbody>");
+        for (Page page : list)
+        {
+            int numberOfChildren = page.getChildren().size();
+            String pageWithChildren = "<tr><td class=\"confluenceTd\">" + TextUtils.htmlEncode(page.getTitle()) + "</td><td class=\"confluenceTd\" style=\"text-align:right\">" + numberOfChildren + "</td></tr>";
+            result.append(pageWithChildren);
+        }
+        result.append("</tbody>");
+        result.append("</table>");
+        result.append("</p>");
+
+        // and show the number of all spaces in this installation.
+        String spaces = "<p>Altogether, this installation has <b>" + spaceManager.getAllSpaces().size() + "</b> spaces.</p>";
+        result.append(spaces);
+
+        // this concludes our little demo. Now you should understand the basics of code injection use in Confluence, and how
+        // to get a really simple macro running.
+
+        return result.toString();
+    }
+
+    @Override
+    public BodyType getBodyType()
+    {
+        return BodyType.NONE;
+    }
+
+    @Override
+    public OutputType getOutputType()
+    {
+        return OutputType.BLOCK;
+    }
+
+}

src/main/java/com/atlassian/confluence/tutorials/tasks/actions/TasksJavaApiExampleAction.java

+package com.atlassian.confluence.tutorials.tasks.actions;
+
+import com.atlassian.confluence.core.ConfluenceActionSupport;
+
+/**
+ * Action that calls the Java API for tasks.
+ */
+public class TasksJavaApiExampleAction extends ConfluenceActionSupport
+{
+    @Override
+    public String execute() throws Exception
+    {
+        return super.execute();    //To change body of overridden methods use File | Settings | File Templates.
+    }
+}

src/main/java/com/atlassian/confluence/tutorials/tasks/actions/TasksRestApiExampleAction.java

+package com.atlassian.confluence.tutorials.tasks.actions;
+
+import com.atlassian.confluence.core.ConfluenceActionSupport;
+
+/**
+ * Action that serves JavaScript that calls the REST API for tasks.
+ */
+public class TasksRestApiExampleAction extends ConfluenceActionSupport
+{
+    @Override
+    public String execute() throws Exception
+    {
+        return SUCCESS;
+    }
+}

src/main/resources/atlassian-plugin.xml

+<?xml version="1.0" encoding="UTF-8"?>
+
+<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
+    <plugin-info>
+        <description>${project.description}</description>
+        <version>${project.version}</version>
+        <vendor name="${project.organization.name}" url="${project.organization.url}"/>
+    </plugin-info>
+
+    <resource type="i18n" name="i18n" location="com.atlassian.confluence.tutorials.confluence-tasks"/>
+
+    <web-resource name="Tasks Web Resources" i18n-name-key="tasks-web-resources.name" key="tasks-web-resources">
+        <description key="tasks-web-resources.description">The Tasks Web Resources Plugin</description>
+        <resource name="tasksWebResources" type="download" location="js/tasks.js"/>
+        <resource name="tasksCss" type="download" location="css/tasks.css"/>
+    </web-resource>
+
+    <xwork name="Task Example Actions" key="task-example-actions">
+        <description>Xwork actions for the Editor loader</description>
+        <package name="confluence-tasks-tutorial" extends="default" namespace="/plugins/confluence-tasks-tutorial">
+            <default-interceptor-ref name="validatingStack"/>
+            <action name="tasks-rest-api-example" class="com.atlassian.confluence.tutorials.tasks.actions.TasksRestApiExampleAction">
+                <result name="success" type="velocity">/templates/tasks-rest.vm</result>
+            </action>
+            <action name="tasks-rest-api-example" class="com.atlassian.confluence.tutorials.tasks.actions.TasksJavaApiExampleAction">
+                <result name="success" type="velocity">/templates/tasks-java.vm</result>
+            </action>
+        </package>
+    </xwork>
+</atlassian-plugin>

src/main/resources/com/atlassian/confluence/tutorials/confluence-tasks.properties

+
+tasks-rest-example-servlet.name=Tasks Rest Example Servlet
+tasks-rest-example-servlet.description=The Tasks Rest Example Servlet Plugin
+
+tasks-web-resources.name=Tasks Web Resources
+tasks-web-resources.description=The Tasks Web Resources Plugin
Add a comment to this file

src/main/resources/css/tasks.css

Empty file added.

Add a comment to this file

src/main/resources/js/tasks.js

Empty file added.

Add a comment to this file

src/main/resources/templates/tasks-java.vm

Empty file added.

Add a comment to this file

src/main/resources/templates/tasks-rest.vm

Empty file added.

src/test/java/com/atlassian/confluence/tutorials/ExampleMacroTest.java

+package com.atlassian.confluence.tutorials;
+
+import org.junit.Test;
+
+/**
+ * Testing {@link com.atlassian.confluence.tutorials.ExampleMacro}
+ */
+public class ExampleMacroTest
+{
+    @Test
+    public void basic()
+    {
+        // add test here...
+    }
+}

src/test/java/com/atlassian/confluence/tutorials/tasks/servlet/TasksRestExampleServletTest.java

+package com.atlassian.confluence.tutorials.tasks.servlet;
+
+import org.junit.Test;
+import org.junit.After;
+import org.junit.Before;
+import org.mockito.Mockito;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+public class TasksRestExampleServlet {
+
+    HttpServletRequest mockRequest;
+    HttpServletResponse mockResponse;
+
+    @Before
+    public void setup() {
+        mockRequest = mock(HttpServletRequest.class);
+        mockResponse = mock(HttpServletResponse.class);
+    }
+
+    @After
+    public void tearDown() {
+
+    }
+
+    @Test
+    public void testSomething() {
+        String expected = "test";
+        when(mockRequest.getParameter(Mockito.anyString())).thenReturn(expected);
+        assertEquals(expected,mockRequest.getParameter("some string"));
+
+    }
+}

src/test/java/it/AbstractIntegrationTestCase.java

+package it;
+
+import com.atlassian.confluence.plugin.functest.AbstractConfluencePluginWebTestCase;
+import com.atlassian.confluence.plugin.functest.JWebUnitConfluenceWebTester;
+import com.atlassian.confluence.plugin.functest.TesterConfiguration;
+import junit.framework.Assert;
+
+import java.io.IOException;
+import java.util.Properties;
+
+public class AbstractIntegrationTestCase extends AbstractConfluencePluginWebTestCase
+{
+    @Override
+    protected JWebUnitConfluenceWebTester createConfluenceWebTester()
+    {
+        Properties props = new Properties();
+        props.put("confluence.webapp.protocol", "http");
+        props.put("confluence.webapp.host", "localhost");
+
+        // this is deceiving: the func test library checks for the system properties
+        // *before* checking in this properties file for these values, so these
+        // properties are technically ignored
+        props.put("confluence.webapp.port", Integer.parseInt(System.getProperty("http.port")));
+        props.put("confluence.webapp.context.path", System.getProperty("context.path"));
+
+        props.put("confluence.auth.admin.username", "admin");
+        props.put("confluence.auth.admin.password", "admin");
+
+        TesterConfiguration conf;
+        try
+        {
+            conf = new TesterConfiguration(props);
+        }
+        catch (IOException ioe)
+        {
+            Assert.fail("Unable to create tester: " + ioe.getMessage());
+            return null;
+        }
+
+        JWebUnitConfluenceWebTester tester = new JWebUnitConfluenceWebTester(conf);
+
+        tester.getTestContext().setBaseUrl(tester.getBaseUrl());
+        tester.setScriptingEnabled(false);
+
+        return tester;
+    }
+}

src/test/java/it/IntegrationTestMyPlugin.java

+package it;
+
+public class IntegrationTestMyPlugin extends AbstractIntegrationTestCase
+{
+	public void testSomething()
+	{
+        gotoPage("");
+        assertTextPresent("Welcome");
+	}
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.