Commits

John Kodumal committed 3885467

Rename classes / plugin key

Comments (0)

Files changed (5)

 
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.atlassian.labs</groupId>
-    <artifactId>streams-jira-debug-log-plugin</artifactId>
+    <artifactId>streams-jira-delete-issue-plugin</artifactId>
     <version>1.0-SNAPSHOT</version>
 
     <organization>
         <url>http://www.example.com/</url>
     </organization>
 
-    <name>streams-jira-debug-log-plugin</name>
-    <description>This is the com.atlassian.labs:streams-jira-debug-log-plugin plugin for Atlassian JIRA.</description>
+    <name>streams-jira-delete-issue-plugin</name>
+    <description>This is the com.atlassian.labs:streams-jira-delete-issue-plugin plugin for Atlassian JIRA.</description>
     <packaging>atlassian-plugin</packaging>
 
     <dependencies>
         <plugins>
             <plugin>
                 <groupId>com.atlassian.maven.plugins</groupId>
-                <artifactId>maven-jira-plugin</artifactId>
-                <version>3.3</version>
+                <artifactId>maven-amps-plugin</artifactId>
+                <version>${amps.version}</version>
                 <extensions>true</extensions>
                 <configuration>
+                    <product>jira</product>
+                    <httpPort>${httpPort}</httpPort>
+                    <contextPath>${contextPath}</contextPath>
                     <productVersion>${jira.version}</productVersion>
                     <productDataVersion>${jira.data.version}</productDataVersion>
+                    <productDataPath>${jira.data.base}</productDataPath>
                     <output>${project.build.directory}/jira-${jira.version}.log</output>
                     <bundledArtifacts>
                         <bundledArtifact>
     </build>
 
     <properties>
+        <amps.version>3.5-m6</amps.version>
         <jira.version>5.0-alpha3</jira.version>
         <jira.data.version>5.0-alpha3</jira.data.version>
         <streams.version>5.0-SNAPSHOT</streams.version>
         <ao.version>0.15.6</ao.version>
         <atlassian.event.version>2.1.1</atlassian.event.version>
         <sal.api.version>2.2.1</sal.api.version>
+        <contextPath>/streams</contextPath>
+        <httpPort>3990</httpPort>
+        <jira.data.base>${basedir}/src/test/resources/jira/test-resources/base.zip</jira.data.base>
     </properties>
 </project>

src/main/java/com/atlassian/labs/streams/jira/DeleteIssueListener.java

+package com.atlassian.labs.streams.jira;
+
+import java.net.URI;
+
+import com.atlassian.crowd.embedded.api.User;
+import com.atlassian.event.api.EventListener;
+import com.atlassian.event.api.EventPublisher;
+import com.atlassian.jira.event.issue.IssueEvent;
+import com.atlassian.jira.event.type.EventType;
+import com.atlassian.sal.api.ApplicationProperties;
+import com.atlassian.streams.thirdparty.api.Activity;
+import com.atlassian.streams.thirdparty.api.ActivityObject;
+import com.atlassian.streams.thirdparty.api.ThirdPartyStreamsService;
+
+import org.joda.time.DateTime;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.InitializingBean;
+
+public class DeleteIssueListener implements InitializingBean, DisposableBean
+{
+    private final EventPublisher eventPublisher;
+    private final ThirdPartyStreamsService thirdPartyStreamsService;
+    private final ApplicationProperties applicationProperties;
+    private static final Logger log = LoggerFactory.getLogger(DeleteIssueListener.class);
+
+    public DeleteIssueListener(EventPublisher eventPublisher,
+                               ThirdPartyStreamsService thirdPartyStreamsService,
+                               ApplicationProperties applicationProperties)
+    {
+        this.eventPublisher = eventPublisher;
+        this.thirdPartyStreamsService = thirdPartyStreamsService;
+        this.applicationProperties = applicationProperties;
+    }
+
+    @Override
+    public void destroy() throws Exception
+    {
+        eventPublisher.unregister(this);
+    }
+
+    @Override
+    public void afterPropertiesSet() throws Exception
+    {
+        eventPublisher.register(this);
+    }
+
+    @EventListener
+    public void onIssueDelete(IssueEvent issueEvent)
+    {
+        if (issueEvent.getEventTypeId().equals(EventType.ISSUE_DELETED_ID))
+        {
+            User user = issueEvent.getUser();
+            ActivityObject generator = new ActivityObject.Builder().displayName("JIRA Deleted Issues").id(URI.create(applicationProperties.getBaseUrl())).build();
+            ActivityObject actor = new ActivityObject.Builder().id(URI.create(user.getName())).build();
+            Activity activity = thirdPartyStreamsService.postActivity(new Activity.Builder(actor, generator, new DateTime()).content(issueEvent.getIssue().getDescription())
+                                                                          .title(user.getDisplayName() + " deleted " + issueEvent.getIssue().getKey() + " - " + issueEvent.getIssue().getSummary())
+                                                                          .id(URI.create(issueEvent.getIssue().getKey())).build());
+        }
+    }
+}

src/main/java/com/atlassian/labs/streams/jira/UserListener.java

-package com.atlassian.labs.streams.jira;
-
-import java.net.URI;
-
-import com.atlassian.crowd.embedded.api.User;
-import com.atlassian.event.api.EventListener;
-import com.atlassian.event.api.EventPublisher;
-import com.atlassian.jira.event.issue.IssueEvent;
-import com.atlassian.jira.event.type.EventType;
-import com.atlassian.sal.api.ApplicationProperties;
-import com.atlassian.streams.thirdparty.api.Activity;
-import com.atlassian.streams.thirdparty.api.ActivityObject;
-import com.atlassian.streams.thirdparty.api.ThirdPartyStreamsService;
-
-import org.joda.time.DateTime;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.InitializingBean;
-
-public class UserListener implements InitializingBean, DisposableBean
-{
-    private final EventPublisher eventPublisher;
-    private final ThirdPartyStreamsService thirdPartyStreamsService;
-    private final ApplicationProperties applicationProperties;
-    private static final Logger log = LoggerFactory.getLogger(UserListener.class);
-
-    public UserListener(EventPublisher eventPublisher, ThirdPartyStreamsService thirdPartyStreamsService, ApplicationProperties applicationProperties)
-    {
-        this.eventPublisher = eventPublisher;
-        this.thirdPartyStreamsService = thirdPartyStreamsService;
-        this.applicationProperties = applicationProperties;
-    }
-
-    @Override
-    public void destroy() throws Exception
-    {
-        eventPublisher.unregister(this);
-    }
-
-    @Override
-    public void afterPropertiesSet() throws Exception
-    {
-        eventPublisher.register(this);
-    }
-
-    @EventListener
-    public void onIssueDelete(IssueEvent issueEvent)
-    {
-        if (issueEvent.getEventTypeId().equals(EventType.ISSUE_DELETED_ID))
-        {
-            User user = issueEvent.getUser();
-            ActivityObject generator = new ActivityObject.Builder().displayName("JIRA Deleted Issues").id(URI.create(applicationProperties.getBaseUrl())).build();
-            ActivityObject actor = new ActivityObject.Builder().id(URI.create(user.getName())).build();
-            Activity activity = thirdPartyStreamsService.postActivity(new Activity.Builder(actor, generator, new DateTime()).content("Deleted issue").title(issueEvent.getIssue().getKey() + " deleted").id(URI.create(issueEvent.getIssue().getKey())).build());
-        }
-    }
-}

src/main/resources/atlassian-plugin.xml

     <component-import key="thirdPartyStreamsService" interface="com.atlassian.streams.thirdparty.api.ThirdPartyStreamsService"/>
     <component-import key="applicationProperties" interface="com.atlassian.sal.api.ApplicationProperties"/>
 
-    <component key="userListener" class="com.atlassian.labs.streams.jira.UserListener">
-        <description>Class that processes the incoming JIRA user events.</description>
+    <component key="userListener" class="com.atlassian.labs.streams.jira.DeleteIssueListener">
+        <description>Class that processes JIRA delete issue events.</description>
     </component>
 
 

src/test/resources/jira/test-resources/base.zip

Binary file added.