summaryrefslogtreecommitdiff
path: root/calamus-nexus-plugin/src/main
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2014-04-12 20:37:55 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2014-04-12 20:37:55 +0200
commita521a2d74c480c53c1004e7e5e2addd28a0578f4 (patch)
treef6d36cdecb56bc35f18faf496c8251a14f3f3a26 /calamus-nexus-plugin/src/main
parentbfcfcf5e3b4301bc94c27f47bfda61693edf3595 (diff)
downloadcalamus-a521a2d74c480c53c1004e7e5e2addd28a0578f4.tar.gz
calamus-a521a2d74c480c53c1004e7e5e2addd28a0578f4.tar.bz2
calamus-a521a2d74c480c53c1004e7e5e2addd28a0578f4.tar.xz
calamus-a521a2d74c480c53c1004e7e5e2addd28a0578f4.zip
wip
Diffstat (limited to 'calamus-nexus-plugin/src/main')
-rw-r--r--calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusEventListener.java (renamed from calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/EventListener.java)19
-rw-r--r--calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusNexusPlugin.java14
-rw-r--r--calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusUiContributor.java2
-rw-r--r--calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/MqClient.java35
-rw-r--r--calamus-nexus-plugin/src/main/resources/static/js/Calamus/CalamusConfigPanel.js3
-rw-r--r--calamus-nexus-plugin/src/main/resources/static/js/calamus-nexus-plugin-boot.js3
6 files changed, 45 insertions, 31 deletions
diff --git a/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/EventListener.java b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusEventListener.java
index 4770974..ddfd171 100644
--- a/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/EventListener.java
+++ b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusEventListener.java
@@ -14,8 +14,8 @@ import javax.inject.Singleton;
import static org.slf4j.LoggerFactory.getLogger;
@Singleton
-@Named
-public class EventListener implements EventSubscriber {
+@Named("CalamusEventListener")
+public class CalamusEventListener implements EventSubscriber {
private final Logger log = getLogger(getClass());
@@ -23,8 +23,8 @@ public class EventListener implements EventSubscriber {
private final GavCalculator gavCalculator;
@Inject
- public EventListener(CalamusConfig config, @Named("maven2") GavCalculator gavCalculator) {
- log.info("CalamusNexusPlugin.CalamusNexusPlugin");
+ public CalamusEventListener(CalamusConfig config, @Named("maven2") GavCalculator gavCalculator) {
+ log.info("CalamusEventListener.CalamusEventListener");
log.info("gavCalculator = " + gavCalculator);
this.mqClient = new MqClient(config.getBrokerUrl());
@@ -33,19 +33,20 @@ public class EventListener implements EventSubscriber {
@Subscribe
public void onRepositoryItemEventStoreCreate(RepositoryItemEventStoreCreate event) {
+ log.info("EventListener.onRepositoryItemEventStoreCreate");
+
Gav gav = gavCalculator.pathToGav(event.getItem().getPath());
- if (gav == null) {
+ if (gav == null || gav.isHash() || gav.isSignature()) {
return;
}
String groupId = gav.getGroupId();
String artifactId = gav.getArtifactId();
String version = gav.getVersion();
- String type = gav.getExtension();
+ String extension = gav.getExtension();
String classifier = gav.getClassifier();
- mqClient.sendMessage(event.getRepository().getId(), groupId, artifactId, version, type, classifier);
-
- log.info("New artifact: groupId={}, artifactId={}, version={}, type={}, classifier={}", groupId, artifactId, version, type, classifier);
+ log.info("New artifact: groupId={}, artifactId={}, version={}, classifier={}, extension={}", groupId, artifactId, version, classifier, extension);
+ mqClient.sendMessage(event.getRepository().getId(), groupId, artifactId, version, classifier, extension);
}
}
diff --git a/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusNexusPlugin.java b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusNexusPlugin.java
index e60fed7..96d2c1d 100644
--- a/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusNexusPlugin.java
+++ b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusNexusPlugin.java
@@ -1,17 +1,25 @@
package io.trygvis.calamus.nexus;
-import org.eclipse.sisu.EagerSingleton;
+//import org.eclipse.sisu.EagerSingleton;
+
+import org.slf4j.Logger;
import org.sonatype.nexus.plugin.PluginIdentity;
import javax.inject.Inject;
import javax.inject.Named;
-@EagerSingleton
-@Named("calamus")
+import static org.slf4j.LoggerFactory.getLogger;
+
+@Named
+//@EagerSingleton
public class CalamusNexusPlugin extends PluginIdentity {
+ private final Logger log = getLogger(getClass());
+
@Inject
public CalamusNexusPlugin() throws Exception {
super("io.trygvis.calamus", "calamus-nexus-plugin");
+
+ System.out.println("CalamusNexusPlugin.CalamusNexusPlugin");
}
}
diff --git a/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusUiContributor.java b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusUiContributor.java
index ed2f745..18e1c68 100644
--- a/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusUiContributor.java
+++ b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/CalamusUiContributor.java
@@ -1,10 +1,12 @@
package io.trygvis.calamus.nexus;
+/*
import org.sonatype.nexus.plugins.ui.contribution.UiContributorSupport;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
+*/
//@Named
//@Singleton
diff --git a/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/MqClient.java b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/MqClient.java
index 51b2b3a..2564ed9 100644
--- a/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/MqClient.java
+++ b/calamus-nexus-plugin/src/main/java/io/trygvis/calamus/nexus/MqClient.java
@@ -1,26 +1,33 @@
package io.trygvis.calamus.nexus;
import org.apache.activemq.ActiveMQConnectionFactory;
+import org.slf4j.Logger;
import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
import javax.jms.JMSException;
-import javax.jms.MapMessage;
import javax.jms.MessageProducer;
import javax.jms.Session;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.util.Properties;
import static javax.jms.Session.AUTO_ACKNOWLEDGE;
+import static org.apache.commons.lang.StringUtils.trimToEmpty;
+import static org.slf4j.LoggerFactory.getLogger;
public class MqClient {
- ActiveMQConnectionFactory connectionFactory;
+ private final Logger log = getLogger(getClass());
+
+ private final ActiveMQConnectionFactory connectionFactory;
public MqClient(String brokerUrl) {
this.connectionFactory = new ActiveMQConnectionFactory(brokerUrl);
}
- public void sendMessage(String repository, String groupId, String artifactId, String version, String type, String classifier) {
+ public void sendMessage(String repository, String groupId, String artifactId, String version, String classifier, String extension) {
try {
Connection connection = connectionFactory.createConnection();
connection.start();
@@ -32,20 +39,22 @@ public class MqClient {
MessageProducer producer = session.createProducer(destination);
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- MapMessage message = session.createMapMessage();
- message.setString("repository", repository);
- message.setString("groupId", groupId);
- message.setString("artifactId", artifactId);
- message.setString("version", version);
- message.setString("type", type);
- message.setString("classifier", classifier);
+ Properties p = new Properties();
+ p.setProperty("repository", repository);
+ p.setProperty("groupId", groupId);
+ p.setProperty("artifactId", artifactId);
+ p.setProperty("version", version);
+ p.setProperty("classifier", trimToEmpty(classifier));
+ p.setProperty("extension", extension);
- producer.send(message);
+ CharArrayWriter buf = new CharArrayWriter();
+ p.store(buf, null);
+ producer.send(session.createTextMessage(buf.toString()));
session.close();
connection.close();
- } catch (JMSException e) {
- e.printStackTrace();
+ } catch (JMSException | IOException e) {
+ log.warn("Unable to send message to broker", e);
}
}
}
diff --git a/calamus-nexus-plugin/src/main/resources/static/js/Calamus/CalamusConfigPanel.js b/calamus-nexus-plugin/src/main/resources/static/js/Calamus/CalamusConfigPanel.js
deleted file mode 100644
index 81a7887..0000000
--- a/calamus-nexus-plugin/src/main/resources/static/js/Calamus/CalamusConfigPanel.js
+++ /dev/null
@@ -1,3 +0,0 @@
-define('Sonatype/repoServer/LdapConfigPanel', function () {
-
-});
diff --git a/calamus-nexus-plugin/src/main/resources/static/js/calamus-nexus-plugin-boot.js b/calamus-nexus-plugin/src/main/resources/static/js/calamus-nexus-plugin-boot.js
deleted file mode 100644
index 0c454be..0000000
--- a/calamus-nexus-plugin/src/main/resources/static/js/calamus-nexus-plugin-boot.js
+++ /dev/null
@@ -1,3 +0,0 @@
-define('calamus-nexus-plugin', [
- 'Calamus/CalamusConfigPanel'
-]);