@Override
public void postInitModule() throws ModuleInitializationException {
String repositoryName = getParameter("repositoryName");
if (repositoryName == null) {
throw new ModuleInitializationException("repositoryName must be specified.",
getRole());
}
String repositoryDomainName = getParameter("repositoryDomainName");
if (repositoryDomainName == null) {
throw new ModuleInitializationException("repositoryDomainName must be specified.",
getRole());
}
String host = getServer().getParameter("fedoraServerHost");
if (host == null) {
throw new ModuleInitializationException("fedoraServerHost must be specified as primary server config element.",
getRole());
}
String context = getServer().getParameter("fedoraAppServerContext");
if (context == null) {
throw new ModuleInitializationException("fedoraAppServerContext must be specified as primary server config element.",
getRole());
}
String port = getServer().getParameter("fedoraServerPort");
if (port == null) {
throw new ModuleInitializationException("fedoraServerPort must be specified as primary server config element.",
getRole());
}
Module mgr = getServer().getModule("org.fcrepo.server.storage.DOManager");
if (mgr == null) {
throw new ModuleInitializationException("DOManager is required (for pidNamespace param), but isn't loaded.",
getRole());
}
String pidNamespace = mgr.getParameter("pidNamespace");
if (pidNamespace == null) {
throw new ModuleInitializationException("DOManager did not specify a pidNamespace, but this module requires that it does.",
getRole());
}
String aes = getParameter("adminEmails");
if (aes == null) {
throw new ModuleInitializationException("adminEmails must be specified.",
getRole());
}
HashSet<String> adminEmails = new HashSet<String>();
if (aes.indexOf(" ") == -1) {
adminEmails.add(aes);
} else {
String[] emails = aes.split(" ");
for (String element : emails) {
adminEmails.add(element);
}
}
HashSet<String> friends = new HashSet<String>();
if (getParameter("friends") != null) {
String f = getParameter("friends");
if (f.indexOf(" ") == -1) {
friends.add(f);
} else {
String[] fs = f.split(" ");
for (String element : fs) {
friends.add(element);
}
}
}
FieldSearch fieldSearch =
(FieldSearch) getServer()
.getModule("org.fcrepo.server.search.FieldSearch");
if (fieldSearch == null) {
throw new ModuleInitializationException("FieldSearch module was not loaded, but is required.",
getRole());
}
Module fsModule =
getServer().getModule("org.fcrepo.server.search.FieldSearch");
if (fsModule.getParameter("maxResults") == null) {
throw new ModuleInitializationException("maxResults parameter must be specified in FieldSearch module's configuration.",
getRole());
}
int maxResults = 0;
try {
maxResults = Integer.parseInt(fsModule.getParameter("maxResults"));
if (maxResults < 1) {
throw new NumberFormatException("");
}
} catch (NumberFormatException nfe) {
throw new ModuleInitializationException("maxResults specified in FieldSearch module's configuration must be a positive integer.",
getRole());
}
long maxSets = 100; // unused for now, but passed in the constructor anyway
long maxRecords = maxResults;
long maxHeaders = maxResults;
String maxRecordsString = getParameter("maxRecords");
if (maxRecordsString != null) {
try {
maxRecords = Long.parseLong(maxRecordsString);
if (maxRecords > maxResults) {
logger.warn("maxRecords was over the limit given by the FieldSearch module, using highest possible value: "
+ maxResults);
maxRecords = maxResults;
}
} catch (NumberFormatException nfe) {
throw new ModuleInitializationException("maxRecords value is invalid.",
getRole());
}
}
String maxHeadersString = getParameter("maxHeaders");
if (maxHeadersString != null) {
try {
maxHeaders = Long.parseLong(maxHeadersString);
if (maxHeaders > maxResults) {
logger.warn("maxHeaders was over the limit given by the FieldSearch module, using highest possible value: "
+ maxResults);
maxHeaders = maxResults;
}
} catch (NumberFormatException nfe) {
throw new ModuleInitializationException("maxHeaders value is invalid.",
getRole());
}
}
m_wrappedOAIProvider =
new FedoraOAIProvider(repositoryName,