Commits

Steve Hetland  committed 58eb200

Changes to be committed:
Updating source files to correct form label issues

  • Participants
  • Parent commits 877bed3

Comments (0)

Files changed (7)

File xproduct-admin-ui-plugin/pom.xml

     <modelVersion>4.0.0</modelVersion>
     <groupId>com.atlassian.plugins.tutorial</groupId>
     <artifactId>xproduct-admin-ui-plugin</artifactId>
-    <version>1.0</version>
+    <version>1.0-SNAPSHOT</version>
+
     <organization>
         <name>Example Company</name>
         <url>http://www.example.com/</url>
     </organization>
+
     <name>xproduct-admin-ui-plugin</name>
-    <description>This plugin has an admin UI that can be used in any Atlassian product.</description>
+    <description>Provides a custom field to store money amounts.</description>
     <packaging>atlassian-plugin</packaging>
+
     <dependencies>
         <dependency>
-            <groupId>com.atlassian.sal</groupId>
-            <artifactId>sal-api</artifactId>
-            <version>2.0.17</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>com.atlassian.templaterenderer</groupId>
-            <artifactId>atlassian-template-renderer-api</artifactId>
-            <version>1.1.1</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <version>4.6</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>javax.ws.rs</groupId>
-            <artifactId>jsr311-api</artifactId>
-            <version>1.0</version>
-            <scope>provided</scope>
+          <groupId>com.atlassian.sal</groupId>
+          <artifactId>sal-api</artifactId>
+          <version>2.0.17</version>
+          <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>javax.xml.bind</groupId>
-            <artifactId>jaxb-api</artifactId>
-            <version>2.1</version>
-            <scope>provided</scope>
+          <groupId>com.atlassian.templaterenderer</groupId>
+          <artifactId>atlassian-template-renderer-api</artifactId>
+          <version>1.1.1</version>
+          <scope>provided</scope>
+        </dependency>
+        <dependency>
+          <groupId>javax.ws.rs</groupId>
+          <artifactId>jsr311-api</artifactId>
+          <version>1.0</version>
+          <scope>provided</scope>
+        </dependency>
+        <dependency>
+          <groupId>javax.xml.bind</groupId>
+          <artifactId>jaxb-api</artifactId>
+          <version>2.1</version>
+          <scope>provided</scope>
         </dependency>
     </dependencies>
     <dependencyManagement>
             </dependency>
         </dependencies>
     </dependencyManagement>
+
     <build>
         <plugins>
             <plugin>
             </plugin>
         </plugins>
     </build>
+    
     <properties>
         <refapp.version>2.12.0</refapp.version>
         <amps.version>3.11</amps.version>
     </properties>
+
 </project>

File xproduct-admin-ui-plugin/src/main/java/com/atlassian/plugins/tutorial/xproductadminui/AdminServlet.java

 package com.atlassian.plugins.tutorial.xproductadminui;
-
+ 
 import java.io.IOException;
+ 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+
 import java.net.URI;
 import com.atlassian.sal.api.auth.LoginUriProvider;
 import com.atlassian.sal.api.user.UserManager;
+ 
 import com.atlassian.templaterenderer.TemplateRenderer;
 
 public class AdminServlet extends HttpServlet
 {
-    private final UserManager userManager;
-    private final LoginUriProvider loginUriProvider;
-    private final TemplateRenderer renderer;
+  private final UserManager userManager;
+  private final LoginUriProvider loginUriProvider;
+  private final TemplateRenderer renderer;
+ 
 
-    public AdminServlet(UserManager userManager, LoginUriProvider loginUriProvider, TemplateRenderer renderer)
-    {
-        this.userManager = userManager;
-        this.loginUriProvider = loginUriProvider;
-        this.renderer = renderer;
-    }
+public AdminServlet(UserManager userManager, LoginUriProvider loginUriProvider, TemplateRenderer renderer)
+{
+  this.userManager = userManager;
+  this.loginUriProvider = loginUriProvider;
+  this.renderer = renderer;
+}
+ 
+@Override
+public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
+{
+  String username = userManager.getRemoteUsername(request);
+  if (username == null || !userManager.isSystemAdmin(username))
+  {
+    redirectToLogin(request, response);
+    return;
+  }
+         
+  response.setContentType("text/html;charset=utf-8");
+  renderer.render("admin.vm", response.getWriter());
+}
 
-    @Override
-    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
-    {
-        String username = userManager.getRemoteUsername(request);
-        if (username == null || !userManager.isSystemAdmin(username))
-            {
-                  redirectToLogin(request, response);
-                  return;
-            }
-        response.setContentType("text/html;charset=utf-8");
-        renderer.render("admin.vm", response.getWriter());
-    }
 
-    private void redirectToLogin(HttpServletRequest request, HttpServletResponse response) throws IOException
+  private void redirectToLogin(HttpServletRequest request, HttpServletResponse response) throws IOException
+  {
+    response.sendRedirect(loginUriProvider.getLoginUri(getUri(request)).toASCIIString());
+  }
+  
+  private URI getUri(HttpServletRequest request)
+  {
+    StringBuffer builder = request.getRequestURL();
+    if (request.getQueryString() != null)
     {
-        response.sendRedirect(loginUriProvider.getLoginUri(getUri(request)).toASCIIString());
+      builder.append("?");
+      builder.append(request.getQueryString());
     }
- 
-    private URI getUri(HttpServletRequest request)
-    {
-        StringBuffer builder = request.getRequestURL();
-        if (request.getQueryString() != null)
-        {
-            builder.append("?");
-            builder.append(request.getQueryString());
-        }
-        return URI.create(builder.toString());
-    }
-
+    return URI.create(builder.toString());
+  }
 }

File xproduct-admin-ui-plugin/src/main/java/com/atlassian/plugins/tutorial/xproductadminui/ConfigResource.java

 import com.atlassian.sal.api.transaction.TransactionTemplate;
 import com.atlassian.sal.api.user.UserManager;
 
-
 @Path("/")
 public class ConfigResource
 {
-    private final UserManager userManager;
-    private final PluginSettingsFactory pluginSettingsFactory;
-    private final TransactionTemplate transactionTemplate;
+  private final UserManager userManager;
+  private final PluginSettingsFactory pluginSettingsFactory;
+  private final TransactionTemplate transactionTemplate;
 
-    public ConfigResource(UserManager userManager, PluginSettingsFactory pluginSettingsFactory, TransactionTemplate transactionTemplate)
-    {
-        this.userManager = userManager;
-        this.pluginSettingsFactory = pluginSettingsFactory;
-        this.transactionTemplate = transactionTemplate;
-    }
+  public ConfigResource(UserManager userManager, PluginSettingsFactory pluginSettingsFactory, 
+                  TransactionTemplate transactionTemplate)
+  {
+    this.userManager = userManager;
+    this.pluginSettingsFactory = pluginSettingsFactory;
+    this.transactionTemplate = transactionTemplate;
+  }
 
-
-    @XmlRootElement
-    @XmlAccessorType(XmlAccessType.FIELD)
-    public static final class Config
-    {
-        @XmlElement private String name;
-        @XmlElement private int time;
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+public static final class Config
+{
+  @XmlElement private String name;
+  @XmlElement private int time;
         
-        public String getName()
-        {
-            return name;
-        }
+  public String getName()
+  {
+    return name;
+  }
         
-        public void setName(String name)
-        {
-            this.name = name;
-        }
+  public void setName(String name)
+  {
+    this.name = name;
+  }
         
-        public int getTime()
-        {
-            return time;
-        }
+  public int getTime()
+  {
+    return time;
+  }
         
-        public void setTime(int time)
-        {
-            this.time = time;
-        }
-    }
+  public void setTime(int time)
+  {
+    this.time = time;
+  }
+}
 
+@GET
+@Produces(MediaType.APPLICATION_JSON)
+public Response get(@Context HttpServletRequest request)
+{
+  String username = userManager.getRemoteUsername(request);
+  if (username == null || !userManager.isSystemAdmin(username))
+  {
+    return Response.status(Status.UNAUTHORIZED).build();
+  }
 
-    @GET
-    @Produces(MediaType.APPLICATION_JSON)
-    public Response get(@Context HttpServletRequest request)
+  return Response.ok(transactionTemplate.execute(new TransactionCallback()
+  {
+    public Object doInTransaction()
     {
-        String username = userManager.getRemoteUsername(request);
-        if (username == null || !userManager.isSystemAdmin(username))
-            {
-                    return Response.status(Status.UNAUTHORIZED).build();
-            }
-
-        return Response.ok(transactionTemplate.execute(new TransactionCallback()
-        {
-            public Object doInTransaction()
-            {
-                PluginSettings settings = pluginSettingsFactory.createGlobalSettings();
-                Config config = new Config();
-                config.setName((String) settings.get(Config.class.getName() + ".name"));
+      PluginSettings settings = pluginSettingsFactory.createGlobalSettings();
+      Config config = new Config();
+      config.setName((String) settings.get(Config.class.getName() + ".name"));
                 
-                String time = (String) settings.get(Config.class.getName() + ".time");
-                if (time != null)
-                {
-                    config.setTime(Integer.parseInt(time));
-                }
-                return config;
-            }
-        })).build();
+      String time = (String) settings.get(Config.class.getName() + ".time");
+      if (time != null)
+      {
+        config.setTime(Integer.parseInt(time));
+      }
+      return config;
     }
+  })).build();
+}
+@PUT
+@Consumes(MediaType.APPLICATION_JSON)
+public Response put(final Config config, @Context HttpServletRequest request)
+{
+  String username = userManager.getRemoteUsername(request);
+  if (username == null || !userManager.isSystemAdmin(username))
+  {
+    return Response.status(Status.UNAUTHORIZED).build();
+  }
 
-
-    @PUT
-    @Consumes(MediaType.APPLICATION_JSON)
-    public Response put(final Config config, @Context HttpServletRequest request)
+  transactionTemplate.execute(new TransactionCallback()
+  {
+    public Object doInTransaction()
     {
-        String username = userManager.getRemoteUsername(request);
-        if (username == null || !userManager.isSystemAdmin(username))
-            {
-               return Response.status(Status.UNAUTHORIZED).build();
-            }
-
-        transactionTemplate.execute(new TransactionCallback()
-        {
-            public Object doInTransaction()
-            {
-                PluginSettings pluginSettings = pluginSettingsFactory.createGlobalSettings();
-                pluginSettings.put(Config.class.getName() + ".name", config.getName());
-                pluginSettings.put(Config.class.getName()  +".time", Integer.toString(config.getTime()));
-                return null;
-            }
-        });
-        
-        return Response.noContent().build();
+      PluginSettings pluginSettings = pluginSettingsFactory.createGlobalSettings();
+      pluginSettings.put(Config.class.getName() + ".name", config.getName());
+      pluginSettings.put(Config.class.getName()  +".time", Integer.toString(config.getTime()));
+      return null;
     }
+  });
+  return Response.noContent().build();
+}
+
+
 
 }

File xproduct-admin-ui-plugin/src/main/resources/admin.js

 AJS.toInit(function() {
-    var baseUrl = AJS.$("meta[name='application-base-url']").attr("content");
+  var baseUrl = AJS.$("meta[name='application-base-url']").attr("content");
     
-    function populateForm() {
-        AJS.$.ajax({
-            url: baseUrl + "/rest/xproduct-admin/1.0/",
-            dataType: "json",
-            success: function(config) {
-                AJS.$("#name").attr("value", config.name);
-                AJS.$("#time").attr("value", config.time);
-            }
-        });
-    }
-    
-
-    function updateConfig() {
-        AJS.$.ajax({
-            url: baseUrl + "/rest/xproduct-admin/1.0/",
-            type: "PUT",
-            contentType: "application/json",
-            data: '{ "name": "' + AJS.$("#name").attr("value") + '", "time": ' +  AJS.$("#time").attr("value") + ' }',
-            processData: false
-        });
-    }
-
-    populateForm();
-
-
-    AJS.$("#admin").submit(function(e) {
-        e.preventDefault();
-        updateConfig();
+  function populateForm() {
+    AJS.$.ajax({
+      url: baseUrl + "/rest/xproduct-admin/1.0/",
+      dataType: "json",
+      success: function(config) {
+        AJS.$("#name").attr("value", config.name);
+        AJS.$("#time").attr("value", config.time);
+      }
     });
+  }
+  function updateConfig() {
+    AJS.$.ajax({
+      url: baseUrl + "/rest/xproduct-admin/1.0/",
+      type: "PUT",
+      contentType: "application/json",
+      data: '{ "name": "' + AJS.$("#name").attr("value") + '", "time": ' +  AJS.$("#time").attr("value") + ' }',
+      processData: false
+    });
+  }  
+  populateForm();
 
-
+  AJS.$("#admin").submit(function(e) {
+    e.preventDefault();
+    updateConfig();
+  });
 });

File xproduct-admin-ui-plugin/src/main/resources/admin.vm

   <head>
     <title>$i18n.getText("xproduct.admin.label")</title>
     <meta name="decorator" content="atl.admin" />
-    <meta name="application-base-url" content="$applicationProperties.getBaseUrl()">
     $webResourceManager.requireResource("com.atlassian.plugins.tutorial.xproduct-admin-ui-plugin:resources")
+    <meta name="application-base-url" content="$applicationProperties.getBaseUrl()">
   </head>
   <body>
     <form id="admin" class="aui">

File xproduct-admin-ui-plugin/src/main/resources/atlassian-plugin.xml

     <servlet name="xproduct-admin-ui-plugin" class="com.atlassian.plugins.tutorial.ExampleServlet" key="test">
         <url-pattern>/test</url-pattern>
     </servlet>
-    <component-import key="userManager" interface="com.atlassian.sal.api.user.UserManager" />
-    <component-import key="loginUriProvider" interface="com.atlassian.sal.api.auth.LoginUriProvider" />
-    <component-import key="renderer" interface="com.atlassian.templaterenderer.velocity.one.six.VelocityTemplateRenderer" />
-    <servlet key="admin-servlet" class="com.atlassian.plugins.tutorial.xproductadminui.AdminServlet">
-        <url-pattern>/xproduct/admin</url-pattern>
-    </servlet>
-    <resource type="i18n" name="i18n" location="com.atlassian.tutorial.xproductadminui.i18n" />
-    <component-import key="applicationProperties" interface="com.atlassian.sal.api.ApplicationProperties" /> 
-    <template-context-item key="applicationPropertiesContextItem" component-ref="applicationProperties" 
-context-key="applicationProperties" name="Application Properties Context Item"/>
+
+
+
+<component-import key="userManager" interface="com.atlassian.sal.api.user.UserManager" />
+<component-import key="loginUriProvider" interface="com.atlassian.sal.api.auth.LoginUriProvider" />
+<component-import key="renderer" interface="com.atlassian.templaterenderer.velocity.one.six.VelocityTemplateRenderer" />
+  
+<servlet key="admin-servlet" class="com.atlassian.plugins.tutorial.xproductadminui.AdminServlet">
+  <url-pattern>/xproduct/admin</url-pattern>
+</servlet>
+
+
+<resource type="i18n" name="i18n" location="com.atlassian.tutorial.xproductadminui.i18n" />
+
+<component-import key="applicationProperties" interface="com.atlassian.sal.api.ApplicationProperties" /> 
+<template-context-item key="applicationPropertiesContextItem" component-ref="applicationProperties" 
+context-key="applicationProperties" name="Application Properties Context Item"/> 
+
 <web-resource name="Admin Web Resources" key="resources"> 
-    <dependency>com.atlassian.auiplugin:ajs</dependency> 
-    <resource type="download" name="admin.js" location="admin.js"/> 
+  <dependency>com.atlassian.auiplugin:ajs</dependency> 
+  <resource type="download" name="admin.js" location="admin.js"/> 
 </web-resource> 
+
 <component-import key="pluginSettingsFactory" interface="com.atlassian.sal.api.pluginsettings.PluginSettingsFactory" />
 <component-import key="transactionTemplate" interface="com.atlassian.sal.api.transaction.TransactionTemplate" />
+
 <rest key="rest" path="/xproduct-admin" version="1.0">
-    <description>Provides REST resources for the admin UI.</description>
+  <description>Provides REST resources for the admin UI.</description>
 </rest>
+
+
 <web-item key="jira-menu-item" name="XProduct Admin" section="system.admin/globalsettings" weight="10" application="jira">
-    <description>Link to xproduct-admin page.</description> 
-    <label key="xproduct.admin.label" /> 
-    <link linkId="xproduct-admin-link">/plugins/servlet/xproduct/admin</link> 
+  <description>Link to xproduct-admin page.</description> 
+  <label key="xproduct.admin.label" /> 
+  <link linkId="xproduct-admin-link">/plugins/servlet/xproduct/admin</link> 
 </web-item> 
+
 <web-item key="fe-menu-item" name="XProduct Admin" section="system.admin/global" weight="10" application="fisheye"> 
-    <description>Link to xproduct-admin page.</description> 
-    <label key="XProduct Admin" /> 
-    <link linkId="xproduct-admin-link">/plugins/servlet/xproduct/admin</link> 
-</web-item>
+  <description>Link to xproduct-admin page.</description> 
+  <label key="XProduct Admin" /> 
+  <link linkId="xproduct-admin-link">/plugins/servlet/xproduct/admin</link> 
+</web-item> 
+
 <web-item key="bamboo-menu-item" name="XProduct Admin" section="system.admin/plugins" weight="10" application="bamboo"> 
-    <description>Link to xproduct-admin page.</description> 
-    <label key="XProduct Admin" /> 
-    <link linkId="xproduct-admin-link">/plugins/servlet/xproduct/admin</link> 
+  <description>Link to xproduct-admin page.</description> 
+  <label key="XProduct Admin" /> 
+  <link linkId="xproduct-admin-link">/plugins/servlet/xproduct/admin</link> 
 </web-item> 
+
 <web-item key="conf-menu-item" name="XProduct Admin" section="system.admin/configuration" weight="10"> 
-    <description>Link to xproduct-admin page.</description> 
-    <label key="xproduct.admin.label" /> 
-    <link linkId="xproduct-admin-link">/plugins/servlet/xproduct/admin</link> 
+  <description>Link to xproduct-admin page.</description> 
+  <label key="xproduct.admin.label" /> 
+  <link linkId="xproduct-admin-link">/plugins/servlet/xproduct/admin</link> 
 </web-item> 
+
 <web-item key="refapp-menu-item" name="XProduct Admin" section="system.admin/general" weight="10" application="refapp"> 
-    <description>Link to xproduct-admin page.</description> 
-    <label key="xproduct.admin.label" /> 
-    <link linkId="xproduct-admin-link">/plugins/servlet/xproduct/admin</link> 
-</web-item>
-</atlassian-plugin>
+  <description>Link to xproduct-admin page.</description> 
+  <label key="xproduct.admin.label" /> 
+  <link linkId="xproduct-admin-link">/plugins/servlet/xproduct/admin</link> 
+</web-item> 
+
+
 
+
+
+</atlassian-plugin>

File xproduct-admin-ui-plugin/src/main/resources/com/atlassian/tutorial/xproductadminui/i18n.properties

 xproduct.admin.label=XProduct Admin
-xproduct.admin.name.label=Name
-xproduct.admin.time.label=Time
+xproduct.admin.name.label=Name:
+xproduct.admin.time.label=Time:
 xproduct.admin.save.label=Save