Skip to content

Commit

Permalink
Reduce Sonar major issue - "Loggers should be "private static final"
Browse files Browse the repository at this point in the history
  • Loading branch information
yinlinchen authored and Andrew Woods committed Feb 19, 2015
1 parent c2e1af0 commit bff5326
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
Expand Up @@ -79,14 +79,14 @@ private void setBaseURL(final FedoraEvent event) {
url = url.substring(0, url.length() - 1);
}
this.baseURL = url;
log.debug("MessageFactory baseURL: {}", baseURL);
LOGGER.debug("MessageFactory baseURL: {}", baseURL);

} else {
log.warn("MessageFactory baseURL is empty!");
LOGGER.warn("MessageFactory baseURL is empty!");
}

} catch ( Exception ex ) {
log.warn("Error setting baseURL", ex);
} catch ( final Exception ex ) {
LOGGER.warn("Error setting baseURL", ex);
}
}

Expand All @@ -111,7 +111,7 @@ public Message getMessage(final FedoraEvent jcrEvent,
message.setStringProperty(BASE_URL_HEADER_NAME, baseURL);
message.setStringProperty(PROPERTIES_HEADER_NAME, Joiner.on(',').join(jcrEvent.getProperties()));

log.trace("getMessage() returning: {}", message);
LOGGER.trace("getMessage() returning: {}", message);
return message;
}

Expand All @@ -123,10 +123,10 @@ public String apply(final Integer type) {
return REPOSITORY_NAMESPACE + EventType.valueOf(type);
}
}));
log.debug("Constructed event type URIs: {}", uris);
LOGGER.debug("Constructed event type URIs: {}", uris);
return uris;
}

private static final Logger log = getLogger(DefaultMessageFactory.class);
private static final Logger LOGGER = getLogger(DefaultMessageFactory.class);

}
Expand Up @@ -31,7 +31,7 @@
*/
public class NamespaceConverter extends InternalIdentifierConverter {

private static final Logger log = getLogger(NamespaceConverter.class);
private static final Logger LOGGER = getLogger(NamespaceConverter.class);

/*
* (non-Javadoc)
Expand All @@ -41,13 +41,14 @@ public class NamespaceConverter extends InternalIdentifierConverter {
*/
@Override
protected String doForward(final String inputId) {
log.trace("Converting identifier {} from internal to external...", inputId);
LOGGER.trace("Converting identifier {} from internal to external...", inputId);
String result = inputId;
for (final String jcrNamespace : jcrNamespacesToRDFNamespaces.keySet()) {
log.trace("Replacing namespace: {} with: {}", jcrNamespace, jcrNamespacesToRDFNamespaces.get(jcrNamespace));
LOGGER.trace("Replacing namespace: {} with: {}", jcrNamespace, jcrNamespacesToRDFNamespaces
.get(jcrNamespace));
result = result.replace(jcrNamespace, jcrNamespacesToRDFNamespaces.get(jcrNamespace));
}
log.trace("Converted identifier {} from internal to external {}...", inputId, result);
LOGGER.trace("Converted identifier {} from internal to external {}...", inputId, result);
return result;
}

Expand All @@ -59,10 +60,11 @@ protected String doForward(final String inputId) {
*/
@Override
protected String doBackward(final String b) {
log.trace("Converting identifier from external to internal...");
LOGGER.trace("Converting identifier from external to internal...");
String result = b;
for (final String rdfNamespace : rdfNamespacesToJcrNamespaces.keySet()) {
log.trace("Replacing namespace: {} with: {}", rdfNamespace, rdfNamespacesToJcrNamespaces.get(rdfNamespace));
LOGGER.trace("Replacing namespace: {} with: {}", rdfNamespace, rdfNamespacesToJcrNamespaces
.get(rdfNamespace));
result = result.replace(rdfNamespace, rdfNamespacesToJcrNamespaces.get(rdfNamespace));
}
return result;
Expand Down
Expand Up @@ -60,7 +60,7 @@ public class AllNodeEventsOneEvent implements InternalExternalEventMapper {
public String apply(final Event ev) {
try {
final String id = ev.getIdentifier();
log.debug("Sorting an event by identifier: {}", id);
LOGGER.debug("Sorting an event by identifier: {}", id);
return id;
} catch (final RepositoryException e) {
throw new RepositoryRuntimeException(e);
Expand Down Expand Up @@ -126,13 +126,13 @@ private void addProperty( final FedoraEvent fedoraEvent, final Event ev ) {
final String eventPath = ev.getPath();
fedoraEvent.addProperty(eventPath.substring(eventPath.lastIndexOf('/') + 1));
} else {
log.trace("Not adding non-event property: {}, {}", fedoraEvent, ev);
LOGGER.trace("Not adding non-event property: {}, {}", fedoraEvent, ev);
}
} catch (final RepositoryException e) {
throw new RepositoryRuntimeException(e);
}
}
}

private final static Logger log = getLogger(AllNodeEventsOneEvent.class);
private final static Logger LOGGER = getLogger(AllNodeEventsOneEvent.class);
}
Expand Up @@ -59,7 +59,7 @@ public class VersionsRdfContext extends RdfStream {

private final com.hp.hpl.jena.graph.Node subject;

private final Logger LOGGER = getLogger(VersionsRdfContext.class);
private static final Logger LOGGER = getLogger(VersionsRdfContext.class);

/**
* Ordinary constructor.
Expand Down
12 changes: 6 additions & 6 deletions fcrepo-mint/src/main/java/org/fcrepo/mint/HttpPidMinter.java
Expand Up @@ -63,7 +63,7 @@
*/
public class HttpPidMinter implements PidMinter {

private static final Logger log = getLogger(HttpPidMinter.class);
private static final Logger LOGGER = getLogger(HttpPidMinter.class);
protected final String url;
protected final String method;
protected final String username;
Expand Down Expand Up @@ -101,7 +101,7 @@ public HttpPidMinter( final String url, final String method, final String userna
try {
this.xpath = XPathFactory.newInstance().newXPath().compile(xpath);
} catch ( XPathException ex ) {
log.warn("Error parsing xpath ({}): {}", xpath, ex );
LOGGER.warn("Error parsing xpath ({}): {}", xpath, ex );
throw new IllegalArgumentException("Error parsing xpath" + xpath, ex);
}
}
Expand Down Expand Up @@ -143,7 +143,7 @@ private HttpUriRequest minterRequest() {
* Override this method for processing more complex than a simple regex replacement.
**/
protected String responseToPid( final String responseText ) throws IOException {
log.debug("responseToPid({})", responseText);
LOGGER.debug("responseToPid({})", responseText);
if ( !isBlank(regex) ) {
return responseText.replaceFirst(regex,"");
} else if ( xpath != null ) {
Expand Down Expand Up @@ -175,14 +175,14 @@ private static String xpath( final String xml, final XPathExpression xpath )
@Override
public String mintPid() {
try {
log.debug("mintPid()");
LOGGER.debug("mintPid()");
final HttpResponse resp = client.execute( minterRequest() );
return responseToPid( EntityUtils.toString(resp.getEntity()) );
} catch ( IOException ex ) {
log.warn("Error minting pid from {}: {}", url, ex);
LOGGER.warn("Error minting pid from {}: {}", url, ex);
throw new RepositoryRuntimeException("Error minting pid", ex);
} catch ( Exception ex ) {
log.warn("Error processing minter response", ex);
LOGGER.warn("Error processing minter response", ex);
throw new RepositoryRuntimeException("Error processing minter response", ex);
}
}
Expand Down

0 comments on commit bff5326

Please sign in to comment.