Skip to content

Commit

Permalink
Mo better exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Apr 21, 2013
1 parent 858fa5e commit 0efb875
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
@@ -1,6 +1,7 @@

package org.fcrepo.messaging.legacy;

import static com.google.common.base.Throwables.propagate;
import static javax.jcr.observation.Event.NODE_ADDED;
import static javax.jcr.observation.Event.NODE_REMOVED;
import static javax.jcr.observation.Event.PROPERTY_ADDED;
Expand Down Expand Up @@ -53,19 +54,19 @@ public class LegacyMethod {
//TODO get this out of the build properties
public static final String SERVER_VERSION = "4.0.0-SNAPSHOT";

private final static String TYPES_NS =
private static final String TYPES_NS =
"http://www.fedora.info/definitions/1/0/types/";

private final static String VERSION_PREDICATE =
private static final String VERSION_PREDICATE =
"info:fedora/fedora-system:def/view#version";

private final static String XSD_NS = "http://www.w3.org/2001/XMLSchema";
private static final String XSD_NS = "http://www.w3.org/2001/XMLSchema";

private static String[] METHODS = new String[] {"ingest", "modifyObject",
"purgeObject", "addDatastream", "modifyDatastream",
private static final String[] METHODS = new String[] {"ingest",
"modifyObject", "purgeObject", "addDatastream", "modifyDatastream",
"purgeDatastream"};

private final static List<String> METHOD_NAMES = Arrays.asList(METHODS);
private static final List<String> METHOD_NAMES = Arrays.asList(METHODS);

private static final Logger logger = getLogger(LegacyMethod.class);

Expand All @@ -77,8 +78,8 @@ public class LegacyMethod {
LegacyMethod.class.getResourceAsStream(MAP_PROPERTIES)) {
FEDORA_TYPES.load(is);
} catch (final IOException e) {
throw new RuntimeException(e);
// it's in the jar.
// it's in the jar.s
throw propagate(e);
}
}

Expand Down Expand Up @@ -224,6 +225,7 @@ private static String getEntryContent(final String methodName,
if (obj == null) {
return "null";
}
// TODO how is this not a String or subclass?
final String javaType = obj.getClass().getCanonicalName();
String term;
//TODO Most of these types are not yet relevant to FCR4, but we can borrow their serializations as necessary
Expand Down Expand Up @@ -311,7 +313,7 @@ public static boolean canParse(final Message jmsMessage) {
.getStringProperty("methodName"));
} catch (final JMSException e) {
logger.info("Could not parse message: {}", jmsMessage);
return false;
throw propagate(e);
}
}

Expand Down
@@ -1,6 +1,8 @@

package org.fcrepo.messaging.legacy;

import static org.slf4j.LoggerFactory.getLogger;

import java.io.IOException;
import java.io.StringWriter;

Expand All @@ -13,12 +15,10 @@

import org.fcrepo.observer.JMSEventMessageFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LegacyMethodEventFactory implements JMSEventMessageFactory {

final private Logger logger = LoggerFactory
.getLogger(LegacyMethodEventFactory.class);
final private Logger logger = getLogger(LegacyMethodEventFactory.class);

public LegacyMethodEventFactory() {
}
Expand Down
@@ -1,6 +1,8 @@

package org.fcrepo.observer;

import static org.slf4j.LoggerFactory.getLogger;

import java.io.IOException;

import javax.annotation.PostConstruct;
Expand All @@ -18,15 +20,13 @@

import org.apache.activemq.ActiveMQConnectionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;

public class JMSTopicPublisher {

@Inject
EventBus eventBus;
private EventBus eventBus;

@Inject
private Repository repo;
Expand All @@ -43,8 +43,7 @@ public class JMSTopicPublisher {

private MessageProducer producer;

final private Logger logger = LoggerFactory
.getLogger(JMSTopicPublisher.class);
final private Logger logger = getLogger(JMSTopicPublisher.class);

private javax.jcr.Session session;

Expand Down
Expand Up @@ -117,16 +117,20 @@ public Map<String, String> getRepositoryNamespaces(final Session session)

@PostConstruct
public final void getSession() {
logger.trace("Logging in read only session...");
try {
readOnlySession = repo.login();
} catch (final RepositoryException e) {
throw propagate(e);
}
logger.trace("Logged in read only session.");
}

@PreDestroy
public final void logoutSession() {
logger.trace("Logging out read only session...");
readOnlySession.logout();
logger.trace("Logged out read only session.");
}

public void setRepository(final Repository repository) {
Expand Down

0 comments on commit 0efb875

Please sign in to comment.