Skip to content

Commit

Permalink
Code cleanup: removed unused imports, added suppression for unneccess…
Browse files Browse the repository at this point in the history
…ary generics warnings, etc.
  • Loading branch information
ajs6f committed Apr 11, 2013
1 parent 79658a6 commit 1bde722
Show file tree
Hide file tree
Showing 92 changed files with 2,920 additions and 2,623 deletions.
Expand Up @@ -68,7 +68,7 @@ public class FedoraDatastreams extends AbstractResource {

@Inject
DatastreamService datastreamService;

@Inject
LowLevelStorageService llStoreService;

Expand Down Expand Up @@ -139,7 +139,7 @@ public Response modifyDatastreams(@PathParam("pid")
public Response deleteDatastreams(@PathParam("pid")
final String pid, @QueryParam("dsid")
final List<String> dsidList) throws RepositoryException {
final Session session = getAuthenticatedSession();
final Session session = getAuthenticatedSession();
try {
for (String dsid : dsidList) {
logger.debug("purging datastream " + dsid);
Expand Down Expand Up @@ -208,8 +208,8 @@ public Response addDatastream(@PathParam("pid")
final String checksumType, @QueryParam("checksum")
final String checksum, @PathParam("dsid")
final String dsid, @HeaderParam("Content-Type")
MediaType requestContentType, InputStream requestBodyStream) throws IOException,
InvalidChecksumException, RepositoryException {
MediaType requestContentType, InputStream requestBodyStream)
throws IOException, InvalidChecksumException, RepositoryException {
final MediaType contentType =
requestContentType != null ? requestContentType
: APPLICATION_OCTET_STREAM_TYPE;
Expand All @@ -218,9 +218,8 @@ public Response addDatastream(@PathParam("pid")
try {
String dsPath = getDatastreamJcrNodePath(pid, dsid);
logger.info("addDatastream {}", dsPath);
datastreamService.createDatastreamNode(session, dsPath,
contentType.toString(), requestBodyStream,
checksumType, checksum);
datastreamService.createDatastreamNode(session, dsPath, contentType
.toString(), requestBodyStream, checksumType, checksum);
session.save();
return created(uriInfo.getRequestUri()).build();
} finally {
Expand Down Expand Up @@ -343,7 +342,7 @@ public Response getDatastreamContent(@PathParam("pid")
EntityTag etag = new EntityTag(ds.getContentDigest().toString());
Date date = ds.getLastModifiedDate();
Date roundedDate = new Date();
roundedDate.setTime(date.getTime() - (date.getTime() % 1000));
roundedDate.setTime(date.getTime() - date.getTime() % 1000);
ResponseBuilder builder =
request.evaluatePreconditions(roundedDate, etag);

Expand Down Expand Up @@ -424,7 +423,8 @@ public DatastreamFixity getDatastreamFixity(@PathParam("pid")
dsf.dsId = dsid;
dsf.timestamp = new Date();

Collection<FixityResult> blobs = llStoreService.runFixityAndFixProblems(ds);
Collection<FixityResult> blobs =
llStoreService.runFixityAndFixProblems(ds);
dsf.statuses = new ArrayList<FixityResult>(blobs);
return dsf;
}
Expand Down
23 changes: 12 additions & 11 deletions fcrepo-http-api/src/main/java/org/fcrepo/api/FedoraFieldSearch.java
Expand Up @@ -41,7 +41,7 @@ public class FedoraFieldSearch extends AbstractResource implements
FedoraJcrTypes {

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

private static final String QUERY_STRING = buildQueryString();

@GET
Expand Down Expand Up @@ -79,11 +79,11 @@ public String searchSubmit(@FormParam("terms")

return view.getFieldSearch(fsr);
}

Query getQuery(QueryManager queryManager, ValueFactory valueFactory, String terms) throws InvalidQueryException, RepositoryException {

Query getQuery(QueryManager queryManager, ValueFactory valueFactory,
String terms) throws InvalidQueryException, RepositoryException {
Query query = queryManager.createQuery(QUERY_STRING, JCR_SQL2);
query.bindValue("sterm", valueFactory.createValue(
"%" + terms + "%"));
query.bindValue("sterm", valueFactory.createValue("%" + terms + "%"));
logger.debug("statement is " + query.getStatement());
return query;
}
Expand All @@ -110,8 +110,8 @@ public FieldSearchResult search(Query query, int offSet, int maxResults)

//add the next set of results to the fieldObjects starting at offSet for pagination
int i = offSet;
nodeIter.skip((long) offSet);
while (nodeIter.hasNext() && i < (offSet + maxResults)) {
nodeIter.skip(offSet);
while (nodeIter.hasNext() && i < offSet + maxResults) {
ObjectFields obj = new ObjectFields();
try {
Node node = nodeIter.nextNode();
Expand All @@ -132,12 +132,13 @@ public FieldSearchResult search(Query query, int offSet, int maxResults)

return fsr;
}

public static String buildQueryString() {
//TODO expand to more fields
String sqlExpression = "SELECT * FROM [" + FEDORA_OBJECT + "] WHERE ["
+ DC_IDENTIFIER + "] like $sterm OR ["
+ DC_TITLE + "] like $sterm";
String sqlExpression =
"SELECT * FROM [" + FEDORA_OBJECT + "] WHERE [" +
DC_IDENTIFIER + "] like $sterm OR [" + DC_TITLE +
"] like $sterm";
return sqlExpression;
}
}
10 changes: 7 additions & 3 deletions fcrepo-http-api/src/main/java/org/fcrepo/api/FedoraObjects.java
Expand Up @@ -96,15 +96,19 @@ public Response modify(@PathParam("pid")
*/
@POST
@Path("/{pid}")
public Response ingest(@PathParam("pid") final String pid,
@QueryParam("label") @DefaultValue("") final String label) throws RepositoryException {
public Response ingest(@PathParam("pid")
final String pid, @QueryParam("label")
@DefaultValue("")
final String label) throws RepositoryException {

logger.debug("Attempting to ingest with pid: {}", pid);

final Session session = getAuthenticatedSession();
try {
FedoraObject result = objectService.createObject(session, pid);
if (label != null && !"".equals(label)) result.setLabel(label);
if (label != null && !"".equals(label)) {
result.setLabel(label);
}
session.save();
logger.debug("Finished ingest with pid: {}", pid);
return created(uriInfo.getRequestUri()).entity(pid).build();
Expand Down
Expand Up @@ -45,10 +45,10 @@
public class FedoraRepository extends AbstractResource {

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

@Inject
Repository repo;

@Inject
ObjectService objectService;

Expand All @@ -60,8 +60,9 @@ public Response describeModeshape() throws JsonGenerationException,
logger.debug("Repository name: " + repo.getDescriptor(REP_NAME_DESC));
final Builder<String, Object> repoproperties = builder();
for (final String key : repo.getDescriptorKeys()) {
if (repo.getDescriptor(key) != null)
if (repo.getDescriptor(key) != null) {
repoproperties.put(key, repo.getDescriptor(key));
}
}

// add in node namespaces
Expand Down Expand Up @@ -93,7 +94,8 @@ public DescribeRepository describe() throws LoginException,
uriInfo.getBaseUriBuilder().path(OBJECT_PATH + "/123/oai_dc")
.build();
description.repositorySize = objectService.getRepositorySize(session);
description.numberOfObjects = objectService.getRepositoryObjectCount(session);
description.numberOfObjects =
objectService.getRepositoryObjectCount(session);
session.logout();
return description;
}
Expand All @@ -111,7 +113,7 @@ public String describeHtml() throws LoginException, RepositoryException {
* @param repo
*/
public void setRepository(Repository repo) {
this.repo = repo;
this.repo = repo;
}

}
@@ -1,3 +1,4 @@

package org.fcrepo.provider;

import static org.slf4j.LoggerFactory.getLogger;
Expand All @@ -17,47 +18,43 @@
*
*/
public class VelocityViewer {

private VelocityEngine velocityEngine;

private static final Logger logger = getLogger(VelocityViewer.class);
private VelocityEngine velocityEngine;

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

public VelocityViewer() {
try
{
try {
// Load the velocity properties from the class path
Properties properties = new Properties();
properties.load( getClass().getClassLoader().getResourceAsStream( "velocity.properties" ) );
properties.load(getClass().getClassLoader().getResourceAsStream(
"velocity.properties"));

// Create and initialize the template engine
velocityEngine = new VelocityEngine( properties );
}
catch( Exception e )
{
velocityEngine = new VelocityEngine(properties);
} catch (Exception e) {
logger.warn("Exception rendering Velocity template: {}", e);
}
}

public String getRepoInfo(DescribeRepository repoinfo) {
try {
// Build a context to hold the model
VelocityContext velocityContext = new VelocityContext();
velocityContext.put("repo", repoinfo);

// Execute the template
StringWriter writer = new StringWriter();
velocityEngine.mergeTemplate( "views/repo-info.vm", "utf-8", velocityContext, writer );

// Return the result
return writer.toString();
}
catch( Exception e )
{
}

public String getRepoInfo(DescribeRepository repoinfo) {
try {
// Build a context to hold the model
VelocityContext velocityContext = new VelocityContext();
velocityContext.put("repo", repoinfo);

// Execute the template
StringWriter writer = new StringWriter();
velocityEngine.mergeTemplate("views/repo-info.vm", "utf-8",
velocityContext, writer);

// Return the result
return writer.toString();
} catch (Exception e) {
logger.warn("Exception rendering Velocity template: {}", e);
}
return null;
}
}
return null;
}

public String getFieldSearch(FieldSearchResult results) {
try {
Expand All @@ -67,17 +64,15 @@ public String getFieldSearch(FieldSearchResult results) {

// Execute the template
StringWriter writer = new StringWriter();
velocityEngine.mergeTemplate( "views/search-results-form.vm", "utf-8", velocityContext, writer );
velocityEngine.mergeTemplate("views/search-results-form.vm",
"utf-8", velocityContext, writer);

// Return the result
return writer.toString();
}
catch( Exception e )
{
} catch (Exception e) {
logger.warn("Exception rendering Velocity template: {}", e);
}
return null;
}


}

0 comments on commit 1bde722

Please sign in to comment.