Skip to content

Commit

Permalink
Changed FedoraFieldSearch to use injected Session
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed May 8, 2013
1 parent de54a45 commit 3101b9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Expand Up @@ -26,8 +26,10 @@
import org.fcrepo.jaxb.search.FieldSearchResult;
import org.fcrepo.jaxb.search.ObjectFields;
import org.fcrepo.provider.VelocityViewer;
import org.fcrepo.session.InjectedSession;
import org.fcrepo.utils.FedoraJcrTypes;
import org.slf4j.Logger;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.codahale.metrics.annotation.Timed;
Expand All @@ -38,31 +40,34 @@
*/

@Component
@Scope("prototype")
@Path("/rest/fcr:search")
public class FedoraFieldSearch extends AbstractResource implements
FedoraJcrTypes {

@InjectedSession
private Session session;

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

private static final String QUERY_STRING = buildQueryString();

@GET
@Timed
@Timed
@Produces(TEXT_HTML)
public String searchForm() throws RepositoryException {
return new VelocityViewer().getFieldSearch(null);
}

@POST
@Timed
@Timed
@Produces(TEXT_HTML)
public String searchSubmit(@FormParam("terms")
final String terms, @FormParam("offSet")
@DefaultValue("0")
final String offSet, @FormParam("maxResults")
final String maxResults) throws RepositoryException {

final Session session = getAuthenticatedSession();
final QueryManager queryManager =
session.getWorkspace().getQueryManager();
final ValueFactory valueFactory = session.getValueFactory();
Expand Down Expand Up @@ -144,4 +149,8 @@ public static String buildQueryString() {
"] like $sterm";
return sqlExpression;
}

public void setSession(final Session session) {
this.session = session;
}
}
Expand Up @@ -49,6 +49,8 @@ public void setUp() throws LoginException, RepositoryException {
any(HttpServletRequest.class))).thenReturn(mockSession);
testObj = new FedoraFieldSearch();
testObj.setSessionFactory(mockSessions);
testObj.setSession(mockSession);

}

@After
Expand Down

0 comments on commit 3101b9f

Please sign in to comment.