Skip to content

Commit

Permalink
revert change in 56a1413 to api/Config.java #298
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Mar 3, 2015
1 parent b4a242f commit 7cde601
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/main/java/edu/harvard/iq/dataverse/api/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;

@Path("config")
public class Config extends AbstractApiBean {
Expand All @@ -23,9 +20,16 @@ public class Config extends AbstractApiBean {
@EJB
DatasetFieldServiceBean datasetFieldService;

/**
* We use the output of this method to generate our Solr schema.xml
*
* @todo Someday we do want to have this return a Response rather than a
* String per https://github.com/IQSS/dataverse/issues/298 but not yet while
* we are trying to ship Dataverse 4.0
*/
@GET
@Path("solr/schema")
public Response getSolrSchema() {
public String getSolrSchema() {

StringBuilder sb = new StringBuilder();

Expand All @@ -48,11 +52,11 @@ public Response getSolrSchema() {
* when we do a big schema.xml update for
* https://github.com/IQSS/dataverse/issues/754
*/
logger.log(Level.INFO, "email type detected ({0}) See also https://github.com/IQSS/dataverse/issues/759", nameSearchable);
logger.info("email type detected (" + nameSearchable + ") See also https://github.com/IQSS/dataverse/issues/759");
}
String multivalued = datasetField.getSolrField().isAllowedToBeMultivalued().toString();
// <field name="datasetId" type="text_general" multiValued="false" stored="true" indexed="true"/>
sb.append(" <field name=\"").append(nameSearchable).append("\" type=\"").append(type).append("\" multiValued=\"").append(multivalued).append("\" stored=\"true\" indexed=\"true\"/>\n");
sb.append(" <field name=\"" + nameSearchable + "\" type=\"" + type + "\" multiValued=\"" + multivalued + "\" stored=\"true\" indexed=\"true\"/>\n");
}

List<String> listOfStaticFields = new ArrayList();
Expand All @@ -63,15 +67,16 @@ public Response getSolrSchema() {
String staticSearchField = null;
try {
staticSearchField = (String) fieldObject.get(searchFieldsObject);
} catch (IllegalArgumentException | IllegalAccessException ex) {
} catch (IllegalArgumentException ex) {
} catch (IllegalAccessException ex) {
}

/**
* @todo: if you search for "pdf" should you get all pdfs? do we
* need a copyField source="filetypemime_s" to the catchall?
*/
if (listOfStaticFields.contains(staticSearchField)) {
return errorResponse( Status.INTERNAL_SERVER_ERROR, "static search field defined twice: " + staticSearchField);
return error("static search field defined twice: " + staticSearchField);
}
listOfStaticFields.add(staticSearchField);
}
Expand All @@ -86,19 +91,19 @@ public Response getSolrSchema() {
if (nameSearchable.equals(SearchFields.DATASET_DESCRIPTION)) {
// Skip, expected conflct.
} else {
return errorResponse( Status.INTERNAL_SERVER_ERROR, "searchable dataset metadata field conflict detected with static field: " + nameSearchable);
return error("searchable dataset metadata field conflict detected with static field: " + nameSearchable);
}
}

if (listOfStaticFields.contains(nameFacetable)) {
return errorResponse( Status.INTERNAL_SERVER_ERROR, "facetable dataset metadata field conflict detected with static field: " + nameFacetable);
return error("facetable dataset metadata field conflict detected with static field: " + nameFacetable);
}

// <copyField source="*_i" dest="text" maxChars="3000"/>
sb.append(" <copyField source=\"").append(nameSearchable).append("\" dest=\"text\" maxChars=\"3000\"/>\n");
sb.append(" <copyField source=\"" + nameSearchable + "\" dest=\"text\" maxChars=\"3000\"/>\n");
}

return okResponse(sb.toString());
return sb.toString();
}

}

0 comments on commit 7cde601

Please sign in to comment.