Clean up more warnings. #8320

This commit is contained in:
Mark H. Wood
2022-07-13 16:49:18 -04:00
parent e9313acd24
commit 41e1d8506b
26 changed files with 174 additions and 151 deletions

View File

@@ -138,6 +138,7 @@ public class StructBuilder {
* @throws SQLException passed through.
* @throws FileNotFoundException if input or output could not be opened.
* @throws TransformerException if the input document is invalid.
* @throws XPathExpressionException passed through.
*/
public static void main(String[] argv)
throws ParserConfigurationException, SQLException,
@@ -209,6 +210,7 @@ public class StructBuilder {
// Export? Import?
if (line.hasOption('x')) { // export
exportStructure(context, outputStream);
outputStream.close();
} else { // Must be import
String input = line.getOptionValue('f');
if (null == input) {
@@ -224,6 +226,10 @@ public class StructBuilder {
}
importStructure(context, inputStream, outputStream);
inputStream.close();
outputStream.close();
// save changes from import
context.complete();
}

View File

@@ -630,11 +630,9 @@ public class ItemExportServiceImpl implements ItemExportService {
Thread go = new Thread() {
@Override
public void run() {
Context context = null;
Context context = new Context();
Iterator<Item> iitems = null;
try {
// create a new dspace context
context = new Context();
// ignore auths
context.turnOffAuthorisationSystem();

View File

@@ -1665,26 +1665,27 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
.trim();
}
if (isTest) {
continue;
}
Bitstream bs = null;
boolean notfound = true;
boolean updateRequired = false;
if (!isTest) {
// find bitstream
List<Bitstream> bitstreams = itemService.getNonInternalBitstreams(c, myItem);
for (int j = 0; j < bitstreams.size() && notfound; j++) {
if (bitstreams.get(j).getName().equals(bitstreamName)) {
bs = bitstreams.get(j);
notfound = false;
}
// find bitstream
List<Bitstream> bitstreams = itemService.getNonInternalBitstreams(c, myItem);
for (Bitstream bitstream : bitstreams) {
if (bitstream.getName().equals(bitstreamName)) {
bs = bitstream;
break;
}
}
if (notfound && !isTest) {
if (null == bs) {
// this should never happen
System.out.println("\tdefault permissions set for "
+ bitstreamName);
} else if (!isTest) {
System.out.printf("\tdefault permissions set for %s%n",
bitstreamName);
} else {
if (permissionsExist) {
if (myGroup == null) {
System.out.println("\t" + groupName
@@ -2025,15 +2026,11 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
Thread go = new Thread() {
@Override
public void run() {
Context context = null;
Context context = new Context();
String importDir = null;
EPerson eperson = null;
try {
// create a new dspace context
context = new Context();
eperson = ePersonService.find(context, oldEPerson.getID());
context.setCurrentUser(eperson);
context.turnOffAuthorisationSystem();
@@ -2044,7 +2041,8 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
if (theOtherCollections != null) {
for (String colID : theOtherCollections) {
UUID colId = UUID.fromString(colID);
if (!theOwningCollection.getID().equals(colId)) {
if (theOwningCollection != null
&& !theOwningCollection.getID().equals(colId)) {
Collection col = collectionService.find(context, colId);
if (col != null) {
collectionList.add(col);

View File

@@ -77,7 +77,7 @@ public class AddBitstreamsAction extends UpdateBitstreamsAction {
ItemUpdate.pr("Contents bitstream count: " + contents.size());
String[] files = dir.list(ItemUpdate.fileFilter);
List<String> fileList = new ArrayList<String>();
List<String> fileList = new ArrayList<>();
for (String filename : files) {
fileList.add(filename);
ItemUpdate.pr("file: " + filename);
@@ -134,9 +134,6 @@ public class AddBitstreamsAction extends UpdateBitstreamsAction {
ItemUpdate.pr("contents entry for bitstream: " + ce.toString());
File f = new File(dir, ce.filename);
// get an input stream
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(f));
Bitstream bs = null;
String newBundleName = ce.bundlename;
@@ -173,7 +170,9 @@ public class AddBitstreamsAction extends UpdateBitstreamsAction {
targetBundle = bundles.iterator().next();
}
bs = bitstreamService.create(context, targetBundle, bis);
try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(f));) {
bs = bitstreamService.create(context, targetBundle, bis);
}
bs.setName(context, ce.filename);
// Identify the format

View File

@@ -290,7 +290,7 @@ public class BrowseEngine {
// now, if we don't have any results, we are at the end of the browse. This will
// be because a starts_with value has been supplied for which we don't have
// any items.
if (results.size() == 0) {
if (results.isEmpty()) {
// In this case, we will calculate a new offset for the last page of results
offset = total - scope.getResultsPerPage();
if (offset < 0) {
@@ -450,7 +450,7 @@ public class BrowseEngine {
// now, if we don't have any results, we are at the end of the browse. This will
// be because a starts_with value has been supplied for which we don't have
// any items.
if (results.size() == 0) {
if (results.isEmpty()) {
// In this case, we will calculate a new offset for the last page of results
offset = total - scope.getResultsPerPage();
if (offset < 0) {
@@ -463,7 +463,7 @@ public class BrowseEngine {
}
} else {
// No records, so make an empty list
results = new ArrayList<String[]>();
results = new ArrayList<>();
}
// construct the BrowseInfo object to pass back
@@ -554,7 +554,7 @@ public class BrowseEngine {
}
String col = "sort_1";
if (so.getNumber() > 0) {
if (so != null && so.getNumber() > 0) {
col = "sort_" + Integer.toString(so.getNumber());
}
@@ -591,7 +591,7 @@ public class BrowseEngine {
}
String col = "sort_1";
if (so.getNumber() > 0) {
if (so != null && so.getNumber() > 0) {
col = "sort_" + Integer.toString(so.getNumber());
}

View File

@@ -100,8 +100,9 @@ public class CitationPage extends AbstractCurationTask {
try {
dBundle = bundleService.create(Curator.curationContext(), item, CitationPage.DISPLAY_BUNDLE_NAME);
} catch (AuthorizeException e) {
log.error("User not authroized to create bundle on item \""
+ item.getName() + "\": " + e.getMessage());
log.error("User not authroized to create bundle on item \"{}\": {}",
item::getName, e::getMessage);
return;
}
} else {
dBundle = dBundles.get(0);
@@ -120,7 +121,7 @@ public class CitationPage extends AbstractCurationTask {
List<Bundle> pBundles = itemService.getBundles(item, CitationPage.PRESERVATION_BUNDLE_NAME);
Bundle pBundle = null;
List<Bundle> bundles = new ArrayList<>();
if (pBundles != null && pBundles.size() > 0) {
if (pBundles != null && !pBundles.isEmpty()) {
pBundle = pBundles.get(0);
bundles.addAll(itemService.getBundles(item, "ORIGINAL"));
bundles.addAll(pBundles);

View File

@@ -75,7 +75,7 @@ var CollReport = function() {
this.createCollectionTable = function() {
var self = this;
var tbl = $("<table/>");
var tbl = $("<table/>");
tbl.attr("id","table");
$("#report").replaceWith(tbl);
@@ -144,8 +144,6 @@ var CollReport = function() {
self.myHtmlUtil.addTd(tr, parval).addClass("title comm");
self.myHtmlUtil.addTdAnchor(tr, coll.name, self.ROOTPATH + coll.handle).addClass("title");
var td = self.myHtmlUtil.addTd(tr, "").addClass("num").addClass("link").addClass("numCount");
td = self.myHtmlUtil.addTd(tr, "").addClass("num").addClass("numFiltered");
};

View File

@@ -29,13 +29,13 @@ THE SOFTWARE.
(function(root, factory) {
/* CommonJS */
if (typeof exports == 'object') module.exports = factory()
if (typeof exports == 'object') module.exports = factory();
/* AMD module */
else if (typeof define == 'function' && define.amd) define(factory)
else if (typeof define == 'function' && define.amd) define(factory);
/* Browser global */
else root.Spinner = factory()
else root.Spinner = factory();
}
(this, function() {
"use strict";
@@ -43,6 +43,7 @@ THE SOFTWARE.
var prefixes = ['webkit', 'Moz', 'ms', 'O'] /* Vendor prefixes */
, animations = {} /* Animation rules keyed by their name */
, useCssAnimations /* Whether to use CSS animations or setTimeout */
;
/**
* Utility function to create elements. If no tag name is given,
@@ -51,9 +52,10 @@ THE SOFTWARE.
function createEl(tag, prop) {
var el = document.createElement(tag || 'div')
, n
;
for(n in prop) el[n] = prop[n]
return el
for(n in prop) el[n] = prop[n];
return el;
}
/**
@@ -63,17 +65,17 @@ THE SOFTWARE.
for (var i=1, n=arguments.length; i<n; i++)
parent.appendChild(arguments[i])
return parent
return parent;
}
/**
* Insert a new stylesheet to hold the @keyframe or VML rules.
*/
var sheet = (function() {
var el = createEl('style', {type : 'text/css'})
ins(document.getElementsByTagName('head')[0], el)
return el.sheet || el.styleSheet
}())
var el = createEl('style', {type : 'text/css'});
ins(document.getElementsByTagName('head')[0], el);
return el.sheet || el.styleSheet;
}());
/**
* Creates an opacity keyframe animation rule and returns its name.
@@ -86,6 +88,7 @@ THE SOFTWARE.
, z = Math.max(1 - (1-alpha) / trail * (100-start), alpha)
, prefix = useCssAnimations.substring(0, useCssAnimations.indexOf('Animation')).toLowerCase()
, pre = prefix && '-' + prefix + '-' || ''
;
if (!animations[name]) {
sheet.insertRule(
@@ -95,12 +98,12 @@ THE SOFTWARE.
(start+0.01) + '%{opacity:1}' +
(start+trail) % 100 + '%{opacity:' + alpha + '}' +
'100%{opacity:' + z + '}' +
'}', sheet.cssRules.length)
'}', sheet.cssRules.length);
animations[name] = 1
animations[name] = 1;
}
return name
return name;
}
/**
@@ -110,13 +113,14 @@ THE SOFTWARE.
var s = el.style
, pp
, i
;
prop = prop.charAt(0).toUpperCase() + prop.slice(1)
prop = prop.charAt(0).toUpperCase() + prop.slice(1);
for(i=0; i<prefixes.length; i++) {
pp = prefixes[i]+prop
if(s[pp] !== undefined) return pp
pp = prefixes[i]+prop;
if(s[pp] !== undefined) return pp;
}
if(s[prop] !== undefined) return prop
if(s[prop] !== undefined) return prop;
}
/**
@@ -124,9 +128,9 @@ THE SOFTWARE.
*/
function css(el, prop) {
for (var n in prop)
el.style[vendor(el, n)||n] = prop[n]
el.style[vendor(el, n)||n] = prop[n];
return el
return el;
}
/**
@@ -134,18 +138,18 @@ THE SOFTWARE.
*/
function merge(obj) {
for (var i=1; i < arguments.length; i++) {
var def = arguments[i]
var def = arguments[i];
for (var n in def)
if (obj[n] === undefined) obj[n] = def[n]
if (obj[n] === undefined) obj[n] = def[n];
}
return obj
return obj;
}
/**
* Returns the line color from the given string or array.
*/
function getColor(color, idx) {
return typeof color == 'string' ? color : color[idx % color.length]
return typeof color == 'string' ? color : color[idx % color.length];
}
// Built-in defaults
@@ -168,15 +172,15 @@ THE SOFTWARE.
top: '50%', // center vertically
left: '50%', // center horizontally
position: 'absolute' // element position
}
};
/** The constructor */
function Spinner(o) {
this.opts = merge(o || {}, Spinner.defaults, defaults)
this.opts = merge(o || {}, Spinner.defaults, defaults);
}
// Global defaults that override the built-ins:
Spinner.defaults = {}
Spinner.defaults = {};
merge(Spinner.prototype, {
@@ -186,23 +190,24 @@ THE SOFTWARE.
* stop() internally.
*/
spin: function(target) {
this.stop()
this.stop();
var self = this
, o = self.opts
, el = self.el = css(createEl(0, {className: o.className}), {position: o.position, width: 0, zIndex: o.zIndex})
;
css(el, {
left: o.left,
top: o.top
})
});
if (target) {
target.insertBefore(el, target.firstChild||null)
target.insertBefore(el, target.firstChild||null);
}
el.setAttribute('role', 'progressbar')
self.lines(el, self.opts)
el.setAttribute('role', 'progressbar');
self.lines(el, self.opts);
if (!useCssAnimations) {
// No CSS animation support, use setTimeout() instead
@@ -217,27 +222,27 @@ THE SOFTWARE.
;(function anim() {
i++;
for (var j = 0; j < o.lines; j++) {
alpha = Math.max(1 - (i + (o.lines - j) * astep) % f * ostep, o.opacity)
alpha = Math.max(1 - (i + (o.lines - j) * astep) % f * ostep, o.opacity);
self.opacity(el, j * o.direction + start, alpha, o)
self.opacity(el, j * o.direction + start, alpha, o);
}
self.timeout = self.el && setTimeout(anim, ~~(1000/fps))
})()
self.timeout = self.el && setTimeout(anim, ~~(1000/fps));
})();
}
return self
return self;
},
/**
* Stops and removes the Spinner.
*/
stop: function() {
var el = this.el
var el = this.el;
if (el) {
clearTimeout(this.timeout)
if (el.parentNode) el.parentNode.removeChild(el)
this.el = undefined
clearTimeout(this.timeout);
if (el.parentNode) el.parentNode.removeChild(el);
this.el = undefined;
}
return this
return this;
},
/**
@@ -248,6 +253,7 @@ THE SOFTWARE.
var i = 0
, start = (o.lines - 1) * (1 - o.direction) / 2
, seg
;
function fill(color, shadow) {
return css(createEl(), {
@@ -259,7 +265,7 @@ THE SOFTWARE.
transformOrigin: 'left',
transform: 'rotate(' + ~~(360/o.lines*i+o.rotate) + 'deg) translate(' + o.radius+'px' +',0)',
borderRadius: (o.corners * o.width>>1) + 'px'
})
});
}
for (; i < o.lines; i++) {
@@ -269,12 +275,12 @@ THE SOFTWARE.
transform: o.hwaccel ? 'translate3d(0,0,0)' : '',
opacity: o.opacity,
animation: useCssAnimations && addAnimation(o.opacity, o.trail, start + i * o.direction, o.lines) + ' ' + 1/o.speed + 's linear infinite'
})
});
if (o.shadow) ins(seg, css(fill('#000', '0 0 4px ' + '#000'), {top: 2+'px'}))
ins(el, ins(seg, fill(getColor(o.color, i), '0 0 1px rgba(0,0,0,.1)')))
if (o.shadow) ins(seg, css(fill('#000', '0 0 4px ' + '#000'), {top: 2+'px'}));
ins(el, ins(seg, fill(getColor(o.color, i), '0 0 1px rgba(0,0,0,.1)')));
}
return el
return el;
},
/**
@@ -282,25 +288,26 @@ THE SOFTWARE.
* Will be overwritten in VML fallback mode below.
*/
opacity: function(el, i, val) {
if (i < el.childNodes.length) el.childNodes[i].style.opacity = val
if (i < el.childNodes.length) el.childNodes[i].style.opacity = val;
}
})
});
function initVML() {
/* Utility function to create a VML tag */
function vml(tag, attr) {
return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr)
return createEl('<' + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr);
}
// No CSS transforms but VML support, add a CSS rule for VML elements:
sheet.addRule('.spin-vml', 'behavior:url(#default#VML)')
sheet.addRule('.spin-vml', 'behavior:url(#default#VML)');
Spinner.prototype.lines = function(el, o) {
var r = o.length+o.width
, s = 2*r
;
function grp() {
return css(
@@ -309,12 +316,13 @@ THE SOFTWARE.
coordorigin: -r + ' ' + -r
}),
{ width: s, height: s }
)
);
}
var margin = -(o.width+o.length)*2 + 'px'
, g = css(grp(), {position: 'absolute', top: margin, left: margin})
, i
;
function seg(i, dx, filter) {
ins(g,
@@ -330,32 +338,32 @@ THE SOFTWARE.
vml('stroke', {opacity: 0}) // transparent stroke to fix color bleeding upon opacity change
)
)
)
);
}
if (o.shadow)
for (i = 1; i <= o.lines; i++)
seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)')
seg(i, -2, 'progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)');
for (i = 1; i <= o.lines; i++) seg(i)
return ins(el, g)
}
for (i = 1; i <= o.lines; i++) seg(i);
return ins(el, g);
};
Spinner.prototype.opacity = function(el, i, val, o) {
var c = el.firstChild
o = o.shadow && o.lines || 0
var c = el.firstChild;
o = o.shadow && o.lines || 0;
if (c && i+o < c.childNodes.length) {
c = c.childNodes[i+o]; c = c && c.firstChild; c = c && c.firstChild
if (c) c.opacity = val
c = c.childNodes[i+o]; c = c && c.firstChild; c = c && c.firstChild;
if (c) c.opacity = val;
}
}
};
}
var probe = css(createEl('group'), {behavior: 'url(#default#VML)'})
var probe = css(createEl('group'), {behavior: 'url(#default#VML)'});
if (!vendor(probe, 'transform') && probe.adj) initVML()
else useCssAnimations = vendor(probe, 'animation')
if (!vendor(probe, 'transform') && probe.adj) initVML();
else useCssAnimations = vendor(probe, 'animation');
return Spinner
return Spinner;
}));

View File

@@ -21,7 +21,7 @@ import org.springframework.hateoas.Link;
* This Projection will allow us to specify how many levels deep we're going to embed resources onto the requested
* HalResource.
* The projection is used by using the name combined with the embedLevelDepth parameter to specify how deep the embeds
* have to go. There is an upperlimit in place for this, which is specified on the bean through the maxEmbed property
* have to go. There is an upper limit in place for this, which is specified on the bean through the maxEmbed property.
*/
public class SpecificLevelProjection extends AbstractProjection {
@@ -55,7 +55,7 @@ public class SpecificLevelProjection extends AbstractProjection {
throw new MissingParameterException("The embedLevelDepth parameter needs to be specified" +
" for this Projection");
}
Integer embedLevelDepth = Integer.parseInt(embedLevelDepthString);
int embedLevelDepth = Integer.parseInt(embedLevelDepthString);
if (embedLevelDepth > maxEmbed) {
throw new IllegalArgumentException("The embedLevelDepth may not exceed the configured max: " + maxEmbed);
}

View File

@@ -136,7 +136,7 @@ public class BrowseItemLinkRepository extends AbstractDSpaceRestRepository
}
// For second level browses on metadata indexes, we need to adjust the default sorting
if (bi != null && bi.isMetadataIndex() && bs.isSecondLevel() && bs.getSortBy() <= 0) {
if (bi.isMetadataIndex() && bs.isSecondLevel() && bs.getSortBy() <= 0) {
bs.setSortBy(1);
}
@@ -144,7 +144,7 @@ public class BrowseItemLinkRepository extends AbstractDSpaceRestRepository
Pageable pageResultInfo =
PageRequest.of((binfo.getStart() - 1) / binfo.getResultsPerPage(), binfo.getResultsPerPage());
List<Item> tmpResult = new ArrayList<Item>();
List<Item> tmpResult = new ArrayList<>();
for (Item bb : binfo.getBrowseItemResults()) {
tmpResult.add(bb);
}

View File

@@ -62,14 +62,14 @@ public class ClaimedTaskRestPermissionEvaluatorPlugin extends RestObjectPermissi
if (ePerson == null) {
return false;
}
Integer dsoId = Integer.parseInt(targetId.toString());
int dsoId = Integer.parseInt(targetId.toString());
ClaimedTask claimedTask = claimedTaskService.find(context, dsoId);
// If the claimed task is null then we give permission so we can throw another status code instead
if (claimedTask == null) {
return true;
}
// task's owner can interact with it
if (claimedTask != null && ePerson.equals(claimedTask.getOwner())) {
if (ePerson.equals(claimedTask.getOwner())) {
return true;
}

View File

@@ -64,7 +64,7 @@ public class PoolTaskRestPermissionEvaluatorPlugin extends RestObjectPermissionE
if (ePerson == null) {
return false;
}
Integer dsoId = Integer.parseInt(targetId.toString());
int dsoId = Integer.parseInt(targetId.toString());
PoolTask poolTask = poolTaskService.find(context, dsoId);
// If the pool task is null then we give permission so we can throw another status code instead

View File

@@ -64,7 +64,7 @@ public class ResourcePolicyAdminPermissionEvalutatorPlugin extends RestObjectPer
Context context = ContextUtil.obtainContext(request.getHttpServletRequest());
try {
Integer resourcePolicyID = Integer.parseInt(targetId.toString());
int resourcePolicyID = Integer.parseInt(targetId.toString());
ResourcePolicy resourcePolicy = resourcePolicyService.find(context, resourcePolicyID);
if (resourcePolicy == null) {
throw new ResourceNotFoundException(

View File

@@ -75,7 +75,7 @@ public class WorkflowRestPermissionEvaluatorPlugin extends RestObjectPermissionE
if (ePerson == null) {
return false;
}
Integer dsoId = Integer.parseInt(targetId.toString());
int dsoId = Integer.parseInt(targetId.toString());
XmlWorkflowItem workflowItem = workflowItemService.find(context, dsoId);
// submitter can see their inprogress submission
if (ePerson.equals(workflowItem.getSubmitter())) {

View File

@@ -62,7 +62,7 @@ public class WorkspaceItemRestPermissionEvaluatorPlugin extends RestObjectPermis
WorkspaceItem witem = null;
try {
ePerson = context.getCurrentUser();
Integer dsoId = Integer.parseInt(targetId.toString());
int dsoId = Integer.parseInt(targetId.toString());
// anonymous user
if (ePerson == null) {

View File

@@ -49,7 +49,7 @@ public class BitstreamMetadataValueRemovePatchOperation extends MetadataValueRem
bitstreamMetadataValuePathUtils.validate(absolutePath);
Item item = source.getItem();
List<Bundle> bundle = itemService.getBundles(item, Constants.CONTENT_BUNDLE_NAME);
;
for (Bundle bb : bundle) {
int idx = 0;
for (Bitstream b : bb.getBitstreams()) {
@@ -58,7 +58,7 @@ public class BitstreamMetadataValueRemovePatchOperation extends MetadataValueRem
if (split.length == 4) {
deleteValue(context, b, split[3], -1);
} else {
Integer toDelete = Integer.parseInt(split[4]);
int toDelete = Integer.parseInt(split[4]);
deleteValue(context, b, split[3], toDelete);
}
}

View File

@@ -65,7 +65,7 @@ public class BitstreamResourcePolicyRemovePatchOperation
ResourcePolicy.TYPE_CUSTOM);
int index = 0;
for (ResourcePolicy policy : policies) {
Integer toDelete = Integer.parseInt(rpIdx);
int toDelete = Integer.parseInt(rpIdx);
if (index == toDelete) {
b.getResourcePolicies().remove(policy);
bitstream = b;

View File

@@ -56,7 +56,7 @@ public class BitstreamResourcePolicyReplacePatchOperation extends ReplacePatchOp
Item item = source.getItem();
List<Bundle> bundle = itemService.getBundles(item, Constants.CONTENT_BUNDLE_NAME);
;
Collection<UploadConfiguration> uploadConfigsCollection = uploadConfigurationService.getMap().values();
Iterator<UploadConfiguration> uploadConfigs = uploadConfigsCollection.iterator();
for (Bundle bb : bundle) {
@@ -70,7 +70,7 @@ public class BitstreamResourcePolicyReplacePatchOperation extends ReplacePatchOp
int index = 0;
for (ResourcePolicy policy : policies) {
Integer toReplace = Integer.parseInt(rpIdx);
int toReplace = Integer.parseInt(rpIdx);
if (index == toReplace) {
b.getResourcePolicies().remove(policy);
break;

View File

@@ -50,7 +50,7 @@ public class ItemMetadataValueRemovePatchOperation extends MetadataValueRemovePa
if (split.length == 1) {
deleteValue(context, source.getItem(), split[0], -1);
} else {
Integer toDelete = Integer.parseInt(split[1]);
int toDelete = Integer.parseInt(split[1]);
deleteValue(context, source.getItem(), split[0], toDelete);
}
}

View File

@@ -370,9 +370,10 @@ public class Utils {
}
}
File file = File.createTempFile(prefixTempName + "-" + suffixTempName, ".temp", uploadDir);
InputStream io = new BufferedInputStream(multipartFile.getInputStream());
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
org.dspace.core.Utils.bufferedCopy(io, out);
try (InputStream io = new BufferedInputStream(multipartFile.getInputStream());
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));) {
org.dspace.core.Utils.bufferedCopy(io, out);
}
return file;
}

View File

@@ -121,6 +121,7 @@ public class Author extends XmlElement implements SwordElementInterface {
*
* @return A XOM Element.
*/
@Override
public Element marshall() {
Element element = new Element(getQualifiedName(), xmlName.getNamespace());
@@ -155,8 +156,8 @@ public class Author extends XmlElement implements SwordElementInterface {
handleIncorrectElement(author, validationProperties);
}
ArrayList<SwordValidationInfo> validationItems = new ArrayList<SwordValidationInfo>();
ArrayList<SwordValidationInfo> attributeItems = new ArrayList<SwordValidationInfo>();
ArrayList<SwordValidationInfo> validationItems = new ArrayList<>();
ArrayList<SwordValidationInfo> attributeItems = new ArrayList<>();
processUnexpectedAttributes(author, attributeItems);
@@ -194,6 +195,7 @@ public class Author extends XmlElement implements SwordElementInterface {
return result;
}
@Override
public SwordValidationInfo validate(Properties validationContext) {
return validate(null, null, validationContext);
}
@@ -208,7 +210,7 @@ public class Author extends XmlElement implements SwordElementInterface {
SwordValidationInfo.MISSING_ELEMENT_ERROR,
SwordValidationInfoType.ERROR);
result.addValidationInfo(info);
} else if (elements == null && name != null) {
} else if (elements == null) {
result.addValidationInfo(name.validate(validationContext));
}
@@ -230,6 +232,7 @@ public class Author extends XmlElement implements SwordElementInterface {
*
* @param author The element to unmarshall.
*/
@Override
public void unmarshall(Element author)
throws UnmarshallException {
unmarshall(author, null);

View File

@@ -215,10 +215,10 @@ public class Entry extends XmlElement implements SwordElementInterface {
*
*/
protected void initialise() {
authors = new ArrayList<Author>();
categories = new ArrayList<Category>();
contributors = new ArrayList<Contributor>();
links = new ArrayList<Link>();
authors = new ArrayList<>();
categories = new ArrayList<>();
contributors = new ArrayList<>();
links = new ArrayList<>();
}
/**
@@ -226,6 +226,7 @@ public class Entry extends XmlElement implements SwordElementInterface {
*
* @return An element that holds the data associated with this object.
*/
@Override
public Element marshall() {
Element entry = new Element(getQualifiedName(), Namespaces.NS_ATOM);
entry.addNamespaceDeclaration(Namespaces.PREFIX_SWORD, Namespaces.NS_SWORD);
@@ -297,6 +298,7 @@ public class Entry extends XmlElement implements SwordElementInterface {
* element, or if there is a problem processing the element or any
* subelements.
*/
@Override
public void unmarshall(Element entry)
throws UnmarshallException {
unmarshall(entry, null);
@@ -472,8 +474,10 @@ public class Entry extends XmlElement implements SwordElementInterface {
}
/**
*
* @param validationContext FIXME: PLEASE DOCUMENT.
* @return SWORD validation info.
*/
@Override
public SwordValidationInfo validate(Properties validationContext) {
return validate(null, validationContext);
}
@@ -498,7 +502,7 @@ public class Entry extends XmlElement implements SwordElementInterface {
result.addValidationInfo(new SwordValidationInfo(Id.elementName(),
SwordValidationInfo.MISSING_ELEMENT_ERROR,
SwordValidationInfoType.ERROR));
} else if (id != null && validateAll) {
} else if (validateAll) {
result.addValidationInfo(id.validate(validationContext));
}
@@ -506,7 +510,7 @@ public class Entry extends XmlElement implements SwordElementInterface {
result.addValidationInfo(new SwordValidationInfo(Title.elementName(),
SwordValidationInfo.MISSING_ELEMENT_ERROR,
SwordValidationInfoType.ERROR));
} else if (title != null && validateAll) {
} else if (validateAll) {
result.addValidationInfo(title.validate(validationContext));
}
@@ -514,7 +518,7 @@ public class Entry extends XmlElement implements SwordElementInterface {
result.addValidationInfo(new SwordValidationInfo(Updated.elementName(),
SwordValidationInfo.MISSING_ELEMENT_ERROR,
SwordValidationInfoType.ERROR));
} else if (updated != null && validateAll) {
} else if (validateAll) {
result.addValidationInfo(updated.validate(validationContext));
}
@@ -543,7 +547,7 @@ public class Entry extends XmlElement implements SwordElementInterface {
" SHOULD contain the URI and version of the server " +
"software.",
SwordValidationInfoType.ERROR));
} else if (generator != null && validateAll) {
} else if (validateAll) {
result.addValidationInfo(generator.validate(validationContext));
}
@@ -619,7 +623,7 @@ public class Entry extends XmlElement implements SwordElementInterface {
* @return An iterator.
*/
public Iterator<String> getCategories() {
ArrayList<String> items = new ArrayList<String>();
ArrayList<String> items = new ArrayList<>();
for (int i = 0; i < categories.size(); i++) {
items.add(categories.get(i).getContent());
}

View File

@@ -13,6 +13,7 @@ import java.util.Properties;
import nu.xom.Attribute;
import nu.xom.Element;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.purl.sword.base.Namespaces;
import org.purl.sword.base.SwordElementInterface;
@@ -62,7 +63,7 @@ public class Generator extends XmlElement implements SwordElementInterface {
/**
* The logger.
*/
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(Generator.class);
private static final Logger log = LogManager.getLogger();
/**
* The Xml name details for the element.
@@ -94,6 +95,7 @@ public class Generator extends XmlElement implements SwordElementInterface {
*
* @return The element.
*/
@Override
public Element marshall() {
Element element = new Element(getQualifiedName(), xmlName.getNamespace());
@@ -122,6 +124,7 @@ public class Generator extends XmlElement implements SwordElementInterface {
* @throws UnmarshallException If the specified element is not an atom:generator
* element, or if there is an error accessing the data.
*/
@Override
public void unmarshall(Element generator)
throws UnmarshallException {
unmarshall(generator, null);
@@ -133,8 +136,8 @@ public class Generator extends XmlElement implements SwordElementInterface {
return handleIncorrectElement(generator, validationProperties);
}
ArrayList<SwordValidationInfo> validationItems = new ArrayList<SwordValidationInfo>();
ArrayList<SwordValidationInfo> attributeValidationItems = new ArrayList<SwordValidationInfo>();
ArrayList<SwordValidationInfo> validationItems = new ArrayList<>();
ArrayList<SwordValidationInfo> attributeValidationItems = new ArrayList<>();
try {
initialise();
@@ -228,7 +231,7 @@ public class Generator extends XmlElement implements SwordElementInterface {
new SwordValidationInfo(xmlName, attributeName,
SwordValidationInfo.MISSING_ATTRIBUTE_WARNING,
SwordValidationInfoType.WARNING));
} else if (validateAll && uri != null) {
} else if (validateAll) {
result.addAttributeValidationInfo(createValidAttributeInfo(ATTRIBUTE_URI, uri));
}
@@ -241,7 +244,7 @@ public class Generator extends XmlElement implements SwordElementInterface {
new SwordValidationInfo(xmlName, attributeName,
SwordValidationInfo.MISSING_ATTRIBUTE_WARNING,
SwordValidationInfoType.WARNING));
} else if (validateAll && version != null) {
} else if (validateAll) {
result.addAttributeValidationInfo(createValidAttributeInfo(ATTRIBUTE_VERSION, version));
}
@@ -306,6 +309,7 @@ public class Generator extends XmlElement implements SwordElementInterface {
/**
* Get a string representation.
*/
@Override
public String toString() {
return "Generator - content: " + getContent() +
" version: " + getVersion() +

View File

@@ -76,6 +76,7 @@ public class SWORDEntry extends Entry {
super(name);
}
@Override
protected void initialise() {
super.initialise();
swordNoOp = null;
@@ -207,6 +208,7 @@ public class SWORDEntry extends Entry {
this.swordPackaging = new SwordPackaging(packaging);
}
@Override
protected void marshallElements(Element entry) {
super.marshallElements(entry);
@@ -329,6 +331,7 @@ public class SWORDEntry extends Entry {
return result;
}
@Override
public SwordValidationInfo unmarshall(Element entry, Properties validationProperties)
throws UnmarshallException {
@@ -343,6 +346,7 @@ public class SWORDEntry extends Entry {
* @param elementName name of element to check
* @return true if element is checked
*/
@Override
protected boolean isElementChecked(XmlName elementName) {
if (elementName == null) {
return false;
@@ -356,10 +360,12 @@ public class SWORDEntry extends Entry {
super.isElementChecked(elementName);
}
@Override
public SwordValidationInfo validate(Properties validationContext) {
return validate(null, validationContext);
}
@Override
protected SwordValidationInfo validate(SwordValidationInfo info,
Properties validationContext) {
boolean validateAll = (info == null);
@@ -379,7 +385,7 @@ public class SWORDEntry extends Entry {
"element.",
SwordValidationInfoType.WARNING));
}
} else if (swordUserAgent != null && validateAll) {
} else if (validateAll) {
swordEntry.addValidationInfo(swordUserAgent.validate(validationContext));
}
@@ -392,7 +398,7 @@ public class SWORDEntry extends Entry {
"resource has received or a URI that " +
"dereferences to such a description.",
SwordValidationInfoType.ERROR));
} else if (swordTreatment != null && validateAll) {
} else if (validateAll) {
swordEntry.addValidationInfo(swordTreatment.validate(validationContext));
}
@@ -408,7 +414,7 @@ public class SWORDEntry extends Entry {
" process.",
SwordValidationInfoType.WARNING));
}
} else if (swordVerboseDescription != null && validateAll) {
} else if (validateAll) {
swordEntry.addValidationInfo(swordVerboseDescription.validate(validationContext));
}
@@ -427,7 +433,7 @@ public class SWORDEntry extends Entry {
"this element to signify an error.",
SwordValidationInfoType.WARNING));
}
} else if (swordNoOp != null && validateAll) {
} else if (validateAll) {
swordEntry.addValidationInfo(swordNoOp.validate(validationContext));
}
@@ -439,7 +445,7 @@ public class SWORDEntry extends Entry {
"element to declare the packaging type. If used " +
"it SHOULD take a value from [SWORD-TYPES].",
SwordValidationInfoType.INFO));
} else if (swordPackaging != null && validateAll) {
} else if (validateAll) {
swordEntry.addValidationInfo(swordPackaging.validate(validationContext));
}

View File

@@ -71,7 +71,7 @@ public class SWORDComboBox extends JComboBox {
public void updateList() {
Object s = getSelectedItem();
if (!isEditable() || s == null || (s != null && ((String) s).trim().length() == 0)) {
if (!isEditable() || s == null || ((String) s).trim().length() == 0) {
// don't update with an empty item or if the combo box is not editable.
return;
}

View File

@@ -358,17 +358,14 @@ public class DepositServlet extends HttpServlet {
request,
response);
return;
} catch (SWORDException se) {
} catch (SWORDException | NoSuchAlgorithmException se) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
log.error(se.toString());
} catch (NoSuchAlgorithmException nsae) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
log.error(nsae.toString());
} finally {
// Try deleting the temp file
if (filename != null) {
File f = new File(filename);
if (f != null && !f.delete()) {
if (!f.delete()) {
log.error("Unable to delete file: " + filename);
}
}