[DS-2911] Inspect and fix unused variables

This commit is contained in:
KevinVdV
2015-11-20 13:21:46 +01:00
parent 440c26c861
commit 3c8837ec78
46 changed files with 22 additions and 110 deletions

View File

@@ -185,7 +185,7 @@ public class MetadataImporter
{
// Schema does not exist - create
log.info("Registering Schema " + name + " (" + namespace + ")");
MetadataSchema schema = metadataSchemaService.create(context, name, namespace);
metadataSchemaService.create(context, name, namespace);
}
else
{

View File

@@ -483,7 +483,7 @@ public class MetadataImport
",looking_for_element=" + element +
",looking_for_qualifier=" + qualifier +
",looking_for_language=" + language));
String[] dcvalues = new String[0];
String[] dcvalues;
if(fromAuthority==null) {
List<MetadataValue> current = itemService.getMetadata(item, schema, element, qualifier, language);
dcvalues = new String[current.size()];

View File

@@ -1260,7 +1260,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
}
// now add the bitstream
bs = bitstreamService.register(c, assetstore, bitstreamPath);
bs = bitstreamService.register(c, targetBundle, assetstore, bitstreamPath);
// set the name to just the filename
int iLastSlash = bitstreamPath.lastIndexOf('/');

View File

@@ -55,8 +55,6 @@ public class SHERPAResponse
Document inDoc = db.parse(xmlData);
Element xmlRoot = inDoc.getDocumentElement();
Element dataRoot = XMLUtils.getSingleElement(xmlRoot, "romeoapi");
Element headersElement = XMLUtils.getSingleElement(xmlRoot,
"header");
Element journalsElement = XMLUtils.getSingleElement(xmlRoot,

View File

@@ -347,8 +347,7 @@ public class GoogleMetadata
{
configFilter = configFilter.trim();
}
ArrayList<ArrayList<String>> parsedOptions = new ArrayList<ArrayList<String>>();
parsedOptions = parseOptions(configFilter);
ArrayList<ArrayList<String>> parsedOptions = parseOptions(configFilter);
if (log.isDebugEnabled())
{

View File

@@ -360,9 +360,6 @@ public class AuthorizeServiceImpl implements AuthorizeService
return false;
}
// is eperson set? if not, userid = 0 (anonymous)
EPerson e = c.getCurrentUser();
//
// First, check all Resource Policies directly on this object
//

View File

@@ -106,8 +106,7 @@ public class ItemCountDAOSolr implements ItemCountDAO
public int getCount(DSpaceObject dso) throws ItemCountException
{
loadCount();
DiscoverQuery query = new DiscoverQuery();
Integer val = null;
Integer val;
if (dso instanceof Collection)
{
val = collectionsCount.get(String.valueOf(((Collection) dso).getID()));

View File

@@ -70,7 +70,7 @@ public class CrosswalkUtils {
if (mdField == null) {
if (forceCreate && fieldChoice.equals("add")) {
try {
mdField = metadataFieldService.create(context, mdSchema, element, qualifier, null);
metadataFieldService.create(context, mdSchema, element, qualifier, null);
} catch (NonUniqueMetadataException e) {
// This case should also not be possible
e.printStackTrace();

View File

@@ -677,7 +677,7 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
owningCollection = inProgressSubmission.getCollection();
}
addLicense(context, item, license, (Collection) ContentServiceFactory.getInstance().getDSpaceObjectService(dso).getParentObject(context, dso)
addLicense(context, item, license, owningCollection
, params);
// FIXME ?

View File

@@ -134,8 +134,6 @@ public class SubscribeCLITool {
// Truncation will actually pass in "Midnight of yesterday in UTC", which will be,
// at least in CDT, "7pm, the day before yesterday, in my current timezone".
cal.add(Calendar.HOUR, -24);
Date thisTimeYesterday = cal.getTime();
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);

View File

@@ -836,7 +836,7 @@ public class OAIHarvester {
// First, see if we can contact the target server at all.
try {
Identify idenTest = new Identify(oaiSource);
new Identify(oaiSource);
}
catch (Exception ex) {
errorSet.add(OAI_ADDRESS_ERROR + ": OAI server could not be reached.");

View File

@@ -330,14 +330,7 @@ public class CCLookup {
// Example: http://api.creativecommons.org/rest/1.5/details?
// license-uri=http://creativecommons.org/licenses/by-nc-sa/3.0/
String issueUrl = cc_root + "/details?license-uri=" + licenseURI;
// todo : modify for post as in the above issue
String post_data;
try {
post_data = URLEncoder.encode("license-uri", "UTF-8") + "=" + URLEncoder.encode(licenseURI, "UTF-8");
} catch (UnsupportedEncodingException e) {
return;
}
//end todo
URL request_url;
try {
request_url = new URL(issueUrl);
@@ -434,8 +427,7 @@ public class CCLookup {
public boolean isSuccess() {
setSuccess(false);
java.io.ByteArrayOutputStream outputstream = new java.io.ByteArrayOutputStream();
JDOMXPath xp_Success = null;
JDOMXPath xp_Success;
String text = null;
try {
xp_Success = new JDOMXPath("//message");

View File

@@ -179,7 +179,7 @@ public class CreativeCommonsServiceImpl implements CreativeCommonsService, Initi
bs_format = bitstreamFormatService.findByShortDescription(context, "License");
}
Bitstream bs = bitstreamService.create(context, licenseStm);
Bitstream bs = bitstreamService.create(context, bundle, licenseStm);
bs.setSource(context, CC_BS_SOURCE);
bs.setName(context, (mimeType != null &&
(mimeType.equalsIgnoreCase("text/xml") ||
@@ -270,7 +270,6 @@ public class CreativeCommonsServiceImpl implements CreativeCommonsService, Initi
@Override
public String fetchLicenseRdf(String ccResult) {
StringWriter result = new StringWriter();
String licenseRdfString = new String("");
try {
InputStream inputstream = new ByteArrayInputStream(ccResult.getBytes("UTF-8"));
templates.newTransformer().transform(new StreamSource(inputstream), new StreamResult(result));

View File

@@ -83,8 +83,6 @@ public class MediaRange
throws IllegalArgumentException, IllegalStateException
{
Pattern mediaRangePattern = Pattern.compile("^" + mediaRangeRegex + "$");
Pattern nonQualityParamPattern = Pattern.compile(nonQualityParam);
Pattern qualityParamPattern = Pattern.compile(qualityParam);
Matcher rangeMatcher = mediaRangePattern.matcher(mediarange.trim());
if (!rangeMatcher.matches())

View File

@@ -641,11 +641,6 @@ public class SolrLoggerServiceImpl implements SolrLoggerService, InitializingBea
{
return currentValsStored;
}
// We have at least one document good
SolrDocument document = response.getResults().get(0);
// System.out.println("HERE");
// Get the info we need
}
catch (SolrServerException e)
{

View File

@@ -115,7 +115,6 @@ public class StatisticsImporterElasticSearch {
DNSCache dnsCache = new DNSCache(2500, 0.75f, 2500);
Object fromCache;
Random rand = new Random();
ContentServiceFactory contentServiceFactory = ContentServiceFactory.getInstance();
while ((line = input.readLine()) != null)

View File

@@ -52,8 +52,6 @@ public class V5_0_2014_11_04__Enable_XMLWorkflow_Migration
public void migrate(Connection connection)
throws IOException, SQLException
{
String currentFlyWayState = DatabaseUtils.getCurrentFlywayState(connection);
// Make sure XML Workflow is enabled in workflow.cfg before proceeding
if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("xmlworkflow")
// If your database was upgraded to DSpace 6 prior to enabling XML Workflow, we MUST skip this 5.x migration, as it is incompatible

View File

@@ -425,7 +425,7 @@ public class DSpaceWorkspaceItemOutputGenerator implements OutputGenerator
if (mdfield == null)
{
mdfield = metadataFieldService.create(context, mdschema, element, qualifier,
metadataFieldService.create(context, mdschema, element, qualifier,
"Campo utilizzato per la cache del provider submission-lookup: "
+ schema);
create = true;

View File

@@ -236,7 +236,6 @@ public class CCLicenseStep extends AbstractProcessingStep
throws ServletException, IOException, SQLException,
AuthorizeException {
String ccLicenseUrl = request.getParameter("cc_license_url");
HttpSession session = request.getSession();
Map<String, String> map = new HashMap<String, String>();
String licenseclass = (request.getParameter("licenseclass_chooser") != null) ? request.getParameter("licenseclass_chooser") : "";

View File

@@ -116,7 +116,7 @@ public class MultiFormatDateParser
public static void main(String[] args)
throws IOException
{
DSpaceKernel kernel = DSpaceKernelInit.getKernel(null); // Mainly to initialize Spring
DSpaceKernelInit.getKernel(null); // Mainly to initialize Spring
// TODO direct log to stdout/stderr somehow
if (args.length > 0) // Test data supplied on the command line

View File

@@ -89,7 +89,6 @@ public class AssignOriginalSubmitterAction extends UserSelectionAction{
@Override
public ActionResult execute(Context c, XmlWorkflowItem wfi, Step step, HttpServletRequest request) throws SQLException, AuthorizeException, IOException, WorkflowException {
EPerson submitter = wfi.getSubmitter();
Step currentStep = getParent().getStep();
WorkflowActionConfig nextAction = getParent().getStep().getNextAction(this.getParent());
//Retrieve the action which has a user interface
while(nextAction != null && !nextAction.requiresUI()){

View File

@@ -79,7 +79,7 @@ public class AccessSettingTag extends TagSupport
public int doStartTag() throws JspException
{
String legend = LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.access-setting.legend");
// String legend = LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.access-setting.legend");
String label_name = LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.access-setting.label_name");
String label_group = LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.access-setting.label_group");
String label_embargo = LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.access-setting.label_embargo");

View File

@@ -83,7 +83,7 @@ public class MetadataSchemaRegistryServlet extends DSpaceServlet
if (id.equals(""))
{
// Create a new metadata schema
MetadataSchema schema = schemaService.create(context, name, namespace);
schemaService.create(context, name, namespace);
showSchemas(context, request, response);
context.complete();
}

View File

@@ -62,8 +62,6 @@ public class LocalURIRedirectionServlet extends HttpServlet
String[] path = request.getPathInfo().substring(1).split("/");
String handle = path[0] + "/" + path[1];
String dspaceURL =
(new DSpace()).getConfigurationService().getProperty("dspace.url");
// Prepare content negotiation
int requestedMimeType = Negotiator.negotiate(request.getHeader(ACCEPT_HEADER_NAME));

View File

@@ -165,7 +165,6 @@ public class BitstreamResource extends Resource
{
context = createContext(getUser(headers));
org.dspace.content.Bitstream dspaceBitstream = findBitstream(context, bitstreamId, org.dspace.core.Constants.READ);
List<org.dspace.authorize.ResourcePolicy> resourcePolicies = authorizeService.getPolicies(context, dspaceBitstream);
//TODO why isn't the above used...
policies = new Bitstream(dspaceBitstream,"policies", context).getPolicies();

View File

@@ -196,9 +196,6 @@ public class CollectionDepositManagerDSpace extends DSpaceSwordAPI
{
// get the things out of the service that we need
Context context = swordContext.getContext();
SwordUrlManager urlManager = swordConfig
.getUrlManager(swordContext.getContext(), swordConfig);
// is the content acceptable? If not, this will throw an error
this.isAcceptable(swordConfig, context, deposit, collection);
@@ -229,9 +226,6 @@ public class CollectionDepositManagerDSpace extends DSpaceSwordAPI
{
// get the things out of the service that we need
Context context = swordContext.getContext();
SwordUrlManager urlManager = swordConfig
.getUrlManager(swordContext.getContext(), swordConfig);
// Obtain the relevant ingester from the factory
SwordEntryIngester si = SwordIngesterFactory
.getEntryInstance(context, deposit, collection);
@@ -259,8 +253,6 @@ public class CollectionDepositManagerDSpace extends DSpaceSwordAPI
{
// get the things out of the service that we need
Context context = swordContext.getContext();
SwordUrlManager urlManager = swordConfig
.getUrlManager(swordContext.getContext(), swordConfig);
// is the content acceptable? If not, this will throw an error
this.isAcceptable(swordConfig, context, deposit, collection);

View File

@@ -56,7 +56,6 @@ public class ContainerManagerDSpace extends DSpaceSwordAPI
{
sc = this.noAuthContext();
SwordConfigurationDSpace config = (SwordConfigurationDSpace) swordConfig;
Context context = sc.getContext();
String acceptContentType = this.getHeader(accept, "Accept", null);
TreeMap<Float, List<String>> analysed = this
@@ -67,7 +66,7 @@ public class ContainerManagerDSpace extends DSpaceSwordAPI
SwordStatementDisseminator disseminator = null;
try
{
disseminator = SwordDisseminatorFactory
SwordDisseminatorFactory
.getStatementInstance(analysed);
}
catch (SwordError swordError)
@@ -732,8 +731,6 @@ public class ContainerManagerDSpace extends DSpaceSwordAPI
{
// get the things out of the service that we need
Context context = swordContext.getContext();
SwordUrlManager urlManager = swordConfig
.getUrlManager(swordContext.getContext(), swordConfig);
// is the content acceptable? If not, this will throw an error
this.isAcceptable(swordConfig, context, deposit, item);
@@ -807,8 +804,6 @@ public class ContainerManagerDSpace extends DSpaceSwordAPI
{
// get the things out of the service that we need
Context context = swordContext.getContext();
SwordUrlManager urlManager = swordConfig
.getUrlManager(swordContext.getContext(), swordConfig);
// Obtain the relevant ingester from the factory
SwordEntryIngester si = SwordIngesterFactory
@@ -852,8 +847,6 @@ public class ContainerManagerDSpace extends DSpaceSwordAPI
// get the things out of the service that we need
Context context = swordContext.getContext();
SwordUrlManager urlManager = swordConfig
.getUrlManager(swordContext.getContext(), swordConfig);
// Obtain the relevant ingester from the factory
SwordEntryIngester si = SwordIngesterFactory

View File

@@ -843,8 +843,6 @@ public class MediaResourceManagerDSpace extends DSpaceSwordAPI
{
// get the things out of the service that we need
Context context = swordContext.getContext();
SwordUrlManager urlManager = swordConfig
.getUrlManager(swordContext.getContext(), swordConfig);
// is the content acceptable? If not, this will throw an error
this.isAcceptable(swordConfig, context, deposit, item);
@@ -897,8 +895,6 @@ public class MediaResourceManagerDSpace extends DSpaceSwordAPI
// get the things out of the service that we need
Context context = swordContext.getContext();
SwordUrlManager urlManager = swordConfig
.getUrlManager(swordContext.getContext(), swordConfig);
// is the content acceptable to the items? If not, this will throw an error
for (Item item : items)
@@ -971,8 +967,6 @@ public class MediaResourceManagerDSpace extends DSpaceSwordAPI
{
// get the things out of the service that we need
Context context = swordContext.getContext();
SwordUrlManager urlManager = swordConfig
.getUrlManager(swordContext.getContext(), swordConfig);
// is the content acceptable? If not, this will throw an error
this.isAcceptable(swordConfig, context, deposit, item);

View File

@@ -296,8 +296,6 @@ public class SwordMETSContentIngester extends AbstractSwordContentIngester
// for some reason, DSpace will not give you the handle automatically,
// so we have to look it up
String handle = handleService.findHandle(context, installedItem);
verboseDescription.append("Replace successful");
result.setItem(installedItem);

View File

@@ -516,8 +516,6 @@ public class SwordUrlManager
// the bitstream id is the part up to the first "/"
int firstSlash = bitstreamParts.indexOf("/");
String bid = bitstreamParts.substring(0, firstSlash);
String fn = bitstreamParts.substring(firstSlash + 1);
Bitstream bitstream = bitstreamService
.findByIdOrLegacyId(context, bid);
return bitstream;

View File

@@ -328,7 +328,7 @@ public class FlowCurationUtils
public static Select getTaskSelectOptions(Select select, String curateGroup) throws WingException
{
String key = new String();
String key;
String[] values = null;
Iterator<String> iterator = null;
if (groupedTasks.isEmpty())
@@ -357,7 +357,7 @@ public class FlowCurationUtils
while (innerIterator.hasNext())
{
String optionValue = innerIterator.next().trim();
String optionText = new String("");
String optionText;
// out.print("Value: " + value + ": OptionValue: " + optionValue + ". Does value.trim().equals(optionValue)? " + value.equals(opti$
if (optionValue.equals(value.trim()))
{

View File

@@ -221,8 +221,6 @@ public class PrivateItems extends AbstractDSpaceTransformer implements
pageMeta.addMetadata("title").addContent(getTitleMessage(info));
DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
pageMeta.addTrailLink(contextPath + "/", T_dspace_home);
pageMeta.addTrail().addContent(getTrailMessage(info));

View File

@@ -220,8 +220,6 @@ public class WithdrawnItems extends AbstractDSpaceTransformer implements
pageMeta.addMetadata("title").addContent(getTitleMessage(info));
DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
pageMeta.addTrailLink(contextPath + "/", T_dspace_home);
pageMeta.addTrail().addContent(getTrailMessage(info));

View File

@@ -57,8 +57,6 @@ public class BatchImportConfirm extends AbstractDSpaceTransformer {
{
// Get list of changes
Request request = ObjectModelHelper.getRequest(objectModel);
// DIVISION: metadata-import
Division div = body.addInteractiveDivision("batch-import",contextPath + "/admin/batchimport", Division.METHOD_MULTIPART,"primary administrative");
div.setHead(T_head1);

View File

@@ -50,9 +50,6 @@ public class BatchImportUpload extends AbstractDSpaceTransformer {
@Override
public void addBody(Body body) throws SAXException, WingException, SQLException
{
// Get list of changes
Request request = ObjectModelHelper.getRequest(objectModel);
// DIVISION: batch-import
Division div = body.addInteractiveDivision("batch-import",contextPath + "/admin/batchimport", Division.METHOD_MULTIPART,"primary administrative");
div.setHead(T_head1);

View File

@@ -92,9 +92,6 @@ public class CurateItemForm extends AbstractDSpaceTransformer {
throws WingException, SQLException,
AuthorizeException, UnsupportedEncodingException
{
UUID itemID = UUID.fromString(parameters.getParameter("itemID", null));
Item item = itemService.find(context, itemID);
String baseURL = contextPath + "/admin/item?administrative-continue="
+ knot.getId() ;

View File

@@ -155,8 +155,6 @@ public class ItemRequestForm extends AbstractDSpaceTransformer implements Cachea
return;
}
Request request = ObjectModelHelper.getRequest(objectModel);
boolean firstVisit=Boolean.valueOf(request.getParameter("firstVisit"));
Item item = (Item) dso;
// Build the item viewer division.
Division itemRequest = body.addInteractiveDivision("itemRequest-form",

View File

@@ -69,8 +69,6 @@ public class ItemRequestResponseAction extends AbstractAction
String token = parameters.getParameter("token","");
String decision = request.getParameter("decision");
String isSent = request.getParameter("isSent");
String message = request.getParameter("message");
//contactPerson:requester or contactPerson:author
String contactPerson = request.getParameter("contactPerson");

View File

@@ -107,7 +107,6 @@ public class SendItemRequestAction extends AbstractAction
Item item = (Item) dso;
String title = "";
String titleDC = item.getName();
Bitstream bitstream = bitstreamService.find(context, UUID.fromString(bitstreamId));
RequestItemAuthor requestItemAuthor = new DSpace()

View File

@@ -240,11 +240,6 @@ public class BrowseFacet extends AbstractDSpaceTransformer implements CacheableP
discoverQuery.setMaxResults(1);
discoverQuery.setSortField(dateField, DiscoverQuery.SORT_ORDER.asc);
discoverQuery.addFilterQueries(filterquery);
DiscoverResult rsp = searchService.search(context, discoverQuery);
// if(0 < rsp.getResults().getNumFound()){
// return (Date) rsp.getResults().get(0).getFieldValue(dateField);
// }
}catch (Exception e){
log.error("Unable to get lowest date", e);
}

View File

@@ -117,8 +117,6 @@ public class CSVOutputter extends AbstractReader implements Recyclable
}
ElasticSearchStatsViewer esStatsViewer = new ElasticSearchStatsViewer(dso, fromDate, toDate);
StatisticsTransformer statisticsTransformerInstance = new StatisticsTransformer(fromDate, toDate);
if(requestedReport.equalsIgnoreCase("topCountries"))
{
SearchRequestBuilder requestBuilder = esStatsViewer.facetedQueryBuilder(esStatsViewer.facetTopCountries);

View File

@@ -67,7 +67,6 @@ public class EditPolicyStep extends AbstractStep
Collection collection = submission.getCollection();
String actionURL = contextPath + "/handle/"+collection.getHandle() + "/submit/" + knot.getId() + ".continue";
Request request = ObjectModelHelper.getRequest(objectModel);
Division div = body.addInteractiveDivision("submit-edit-policy", actionURL, Division.METHOD_POST, "primary submission");
div.setHead(T_submission_head);
addSubmissionProgressList(div);

View File

@@ -85,7 +85,7 @@ public class SelectTargetTransformer extends AbstractDSpaceTransformer
String urlValue = request.getParameter("url");
String otherUrlValue = request.getParameter("otherUrl");
String usernameValue = request.getParameter("username");
String passwordValue = request.getParameter("password");
// String passwordValue = request.getParameter("password");
Division main = body.addInteractiveDivision("service-document", contextPath + "/swordclient", Division.METHOD_POST, "");
main.setHead(T_main_head.parameterize(handle));

View File

@@ -43,8 +43,6 @@ public class SwordResponseTransformer extends AbstractDSpaceTransformer
public void addBody(Body body) throws WingException, SQLException, AuthorizeException
{
String handle = parameters.getParameter("handle", null);
//Division main = body.addDivision("deposit-response");
//main.setHead(T_main_head.parameterize(handle));

View File

@@ -188,8 +188,7 @@ public class DSpaceMultipartParser {
private void parsePart(DSpaceTokenStream ts)
throws IOException, MultipartException {
Hashtable headers = new Hashtable();
headers = readHeaders(ts);
Hashtable headers = readHeaders(ts);
try {
if (headers.containsKey("filename")) {
if (!"".equals(headers.get("filename"))) {

View File

@@ -87,8 +87,6 @@ public class DiscoveryOpenSearchGenerator extends AbstractOpenSearchGenerator
Context context = ContextUtil.obtainContext(objectModel);
DiscoverQuery queryArgs = new DiscoverQuery();
Request request = ObjectModelHelper.getRequest(objectModel);
// Sets the query
queryArgs.setQuery(query);
// start -1 because Solr indexing starts at 0 and OpenSearch