Commits

Don Brown committed de07436

Upgrade to latest container

  • Participants
  • Parent commits 1e204fc

Comments (0)

Files changed (2)

     <dependencies>
         <dependency>
             <groupId>com.atlassian.plugins</groupId>
-            <artifactId>remotable-plugins-api</artifactId>
+            <artifactId>remotable-plugins-plugin-api</artifactId>
             <version>${remotable.plugins.version}</version>
             <scope>provided</scope>
         </dependency>
         </dependency>
 
         <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-            <version>1.4</version>
+            <groupId>com.googlecode.json-simple</groupId>
+            <artifactId>json-simple</artifactId>
+            <version>1.1.1</version>
             <scope>provided</scope>
         </dependency>
 
+        <!--<dependency>-->
+            <!--<groupId>commons-io</groupId>-->
+            <!--<artifactId>commons-io</artifactId>-->
+            <!--<version>1.4</version>-->
+            <!--<scope>provided</scope>-->
+        <!--</dependency>-->
+
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <dependency>
                 <groupId>log4j</groupId>
                 <artifactId>log4j</artifactId>
-                <version>1.2.15</version>
+                <version>1.2.16</version>
+                <scope>provided</scope>
+            </dependency>
+            <dependency>
+                <groupId>com.atlassian.plugins</groupId>
+                <artifactId>remotable-plugins-spi</artifactId>
+                <version>0.6.7</version>
                 <scope>provided</scope>
-                <exclusions>
-                    <exclusion>
-                        <groupId>javax.jms</groupId>
-                        <artifactId>jms</artifactId>
-                    </exclusion>
-                </exclusions>
             </dependency>
         </dependencies>
     </dependencyManagement>
             <plugin>
                 <groupId>com.atlassian.maven.plugins</groupId>
                 <artifactId>maven-amps-plugin</artifactId>
-                <version>3.10.1</version>
+                <version>4.1.4</version>
                 <extensions>true</extensions>
                 <configuration>
                     <extractDependencies>true</extractDependencies>
                     <enableFastdev>false</enableFastdev>
                     <enableDevToolbox>false</enableDevToolbox>
                     <product>confluence</product>
+                    <containerVersion>${remotable.plugins.version}</containerVersion>
+                    <instructions>
+                        <Import-Package>*;resolution:=optional</Import-Package>
+                    </instructions>
                 </configuration>
             </plugin>
             <plugin>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <configuration>
-                    <source>1.5</source>
-                    <target>1.5</target>
+                    <source>1.6</source>
+                    <target>1.6</target>
                 </configuration>
             </plugin>
             <plugin>
     </scm>
 
     <properties>
-        <remotable.plugins.version>0.5.817</remotable.plugins.version>
+        <remotable.plugins.version>0.6.965</remotable.plugins.version>
     </properties>
 
 

src/main/java/servlets/MacroServlet.java

 package servlets;
 
+import com.atlassian.confluence.xmlrpc.client.api.ConfluenceAttachmentClient;
+import com.atlassian.confluence.xmlrpc.client.api.ConfluencePageClient;
+import com.atlassian.confluence.xmlrpc.client.api.domain.Attachment;
+import com.atlassian.confluence.xmlrpc.client.api.domain.MutableAttachment;
 import com.atlassian.httpclient.api.HttpClient;
 import com.atlassian.httpclient.api.Response;
-import com.atlassian.plugin.remotable.api.annotation.ServiceReference;
-import com.atlassian.plugin.remotable.api.service.confluence.ConfluenceAttachmentClient;
-import com.atlassian.plugin.remotable.api.service.confluence.ConfluencePageClient;
-import com.atlassian.plugin.remotable.api.service.confluence.domain.Attachment;
-import com.atlassian.plugin.remotable.api.service.confluence.domain.MutableAttachment;
+import com.atlassian.plugin.remotable.api.annotation.ComponentImport;
 import org.apache.commons.io.IOUtils;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+import org.json.simple.JSONValue;
 
 import javax.inject.Inject;
-import javax.inject.Singleton;
+import javax.inject.Named;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import java.io.PrintWriter;
 import java.net.URI;
 import java.net.UnknownHostException;
+import java.util.List;
 import java.util.Map;
 
+import static com.atlassian.confluence.xmlrpc.client.api.domain.ConfluenceDomain.newAttachment;
 import static com.atlassian.httpclient.api.EntityBuilders.newForm;
-import static com.atlassian.plugin.remotable.api.service.confluence.domain.ConfluenceDomain.newAttachment;
 
 /**
  *
  */
-@Singleton
+@Named
 public class MacroServlet extends HttpServlet
 {
     private final HttpClient httpClient;
 
     @Inject
     public MacroServlet(
-            @ServiceReference HttpClient httpClient,
-            @ServiceReference ConfluenceAttachmentClient attachmentClient,
-            @ServiceReference ConfluencePageClient confluencePageClient)
+            @ComponentImport HttpClient httpClient,
+            @ComponentImport ConfluenceAttachmentClient attachmentClient,
+            @ComponentImport ConfluencePageClient confluencePageClient)
     {
         this.httpClient = httpClient;
         this.attachmentClient = attachmentClient;
                 .post().claim();
 
         String result = response.getEntity();
-        String img = null;
-        try
+        String img;
+        JSONObject data  = (JSONObject) JSONValue.parse(result);
+        img = (String) data.get("img");
+        JSONArray errors = (JSONArray) data.get("errors");
+        if (!errors.isEmpty())
         {
-            JSONObject data  = new JSONObject(result);
-            img = (String) data.get("img");
-            JSONArray errors = data.getJSONArray("errors");
-            if (errors.length() > 0)
+            StringBuilder sb = new StringBuilder();
+            for (String error : (List<String>) errors)
             {
-                StringBuilder sb = new StringBuilder();
-                for (int x=0; x<errors.length(); x++)
-                {
-                    sb.append(errors.getString(x)).append(", ");
-                }
-                sb.substring(0, sb.length() - 2);
-                throw new IllegalArgumentException(sb.toString());
+                sb.append(error).append(", ");
             }
-        }
-        catch (JSONException e)
-        {
-            e.printStackTrace();
-            throw new IllegalArgumentException("Unable to parse json: " + result, e);
+            sb.substring(0, sb.length() - 2);
+            throw new IllegalArgumentException(sb.toString());
         }
 
         String key = params.get("key")[0];