mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 22:43:12 +00:00
Replace duplicated literals with manifest constants.
This commit is contained in:
@@ -1426,11 +1426,11 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
|
||||
if (bundleName == null) {
|
||||
// is it license.txt?
|
||||
if ("license.txt".equals(fileName)) {
|
||||
newBundleName = "LICENSE";
|
||||
if (Constants.LICENSE_BITSTREAM_NAME.equals(fileName)) {
|
||||
newBundleName = Constants.LICENSE_BUNDLE_NAME;
|
||||
} else {
|
||||
// call it ORIGINAL
|
||||
newBundleName = "ORIGINAL";
|
||||
newBundleName = Constants.CONTENT_BUNDLE_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1494,11 +1494,11 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
|
||||
if (StringUtils.isBlank(bundleName)) {
|
||||
// is it license.txt?
|
||||
if (bitstreamPath.endsWith("license.txt")) {
|
||||
newBundleName = "LICENSE";
|
||||
if (bitstreamPath.endsWith(Constants.LICENSE_BITSTREAM_NAME)) {
|
||||
newBundleName = Constants.LICENSE_BUNDLE_NAME;
|
||||
} else {
|
||||
// call it ORIGINAL
|
||||
newBundleName = "ORIGINAL";
|
||||
newBundleName = Constants.CONTENT_BUNDLE_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,7 @@ import org.dspace.content.Item;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.BitstreamFormatService;
|
||||
import org.dspace.content.service.InstallItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.Group;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
@@ -138,10 +139,10 @@ public class AddBitstreamsAction extends UpdateBitstreamsAction {
|
||||
String newBundleName = ce.bundlename;
|
||||
|
||||
if (ce.bundlename == null) { // should be required but default convention established
|
||||
if (ce.filename.equals("license.txt")) {
|
||||
newBundleName = "LICENSE";
|
||||
if (ce.filename.equals(Constants.LICENSE_BITSTREAM_NAME)) {
|
||||
newBundleName = Constants.LICENSE_BUNDLE_NAME;
|
||||
} else {
|
||||
newBundleName = "ORIGINAL";
|
||||
newBundleName = Constants.CONTENT_BUNDLE_NAME;
|
||||
}
|
||||
}
|
||||
ItemUpdate.pr(" Bitstream " + ce.filename + " to be added to bundle: " + newBundleName);
|
||||
|
@@ -594,7 +594,7 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
public void removeDSpaceLicense(Context context, Item item) throws SQLException, AuthorizeException, IOException {
|
||||
// get all bundles with name "LICENSE" (these are the DSpace license
|
||||
// bundles)
|
||||
List<Bundle> bunds = getBundles(item, "LICENSE");
|
||||
List<Bundle> bunds = getBundles(item, Constants.LICENSE_BUNDLE_NAME);
|
||||
|
||||
for (Bundle bund : bunds) {
|
||||
// FIXME: probably serious troubles with Authorizations
|
||||
|
@@ -22,6 +22,7 @@ import org.dspace.content.service.BitstreamFormatService;
|
||||
import org.dspace.content.service.BitstreamService;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
|
||||
@@ -139,10 +140,10 @@ public class LicenseUtils {
|
||||
// Store text as a bitstream
|
||||
byte[] licenseBytes = licenseText.getBytes("UTF-8");
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(licenseBytes);
|
||||
Bitstream b = itemService.createSingleBitstream(context, bais, item, "LICENSE");
|
||||
Bitstream b = itemService.createSingleBitstream(context, bais, item, Constants.LICENSE_BUNDLE_NAME);
|
||||
|
||||
// Now set the format and name of the bitstream
|
||||
b.setName(context, "license.txt");
|
||||
b.setName(context, Constants.LICENSE_BITSTREAM_NAME);
|
||||
b.setSource(context, "Written by org.dspace.content.LicenseUtils");
|
||||
|
||||
DCDate acceptanceDCDate = DCDate.getCurrent();
|
||||
|
@@ -26,6 +26,7 @@ import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.content.Bundle;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.contentreport.ItemFilterUtil.BundleName;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
@@ -268,7 +269,7 @@ public enum Filter {
|
||||
HAS_LICENSE_DOCUMENTATION(FilterCategory.BUNDLE, (context, item) -> {
|
||||
List<String> names = ItemFilterUtil.getBitstreamNames(BundleName.LICENSE, item);
|
||||
return names.stream()
|
||||
.anyMatch(name -> !name.equals("license.txt"));
|
||||
.anyMatch(name -> !name.equals(Constants.LICENSE_BITSTREAM_NAME));
|
||||
}),
|
||||
|
||||
/**
|
||||
|
@@ -1095,7 +1095,7 @@ public class ItemTest extends AbstractDSpaceObjectTest {
|
||||
public void testRemoveDSpaceLicenseAuth() throws Exception {
|
||||
// First create a bundle for test
|
||||
context.turnOffAuthorisationSystem();
|
||||
String name = "LICENSE";
|
||||
String name = Constants.LICENSE_BUNDLE_NAME;
|
||||
Bundle created = bundleService.create(context, it, name);
|
||||
created.setName(context, name);
|
||||
context.restoreAuthSystemState();
|
||||
@@ -1117,7 +1117,7 @@ public class ItemTest extends AbstractDSpaceObjectTest {
|
||||
public void testRemoveDSpaceLicenseNoAuth() throws Exception {
|
||||
// First create a bundle for test
|
||||
context.turnOffAuthorisationSystem();
|
||||
String name = "LICENSE";
|
||||
String name = Constants.LICENSE_BUNDLE_NAME;
|
||||
Bundle created = bundleService.create(context, it, name);
|
||||
created.setName(context, name);
|
||||
context.restoreAuthSystemState();
|
||||
@@ -1133,7 +1133,7 @@ public class ItemTest extends AbstractDSpaceObjectTest {
|
||||
public void testRemoveLicensesAuth() throws Exception {
|
||||
// First create test content
|
||||
context.turnOffAuthorisationSystem();
|
||||
String name = "LICENSE";
|
||||
String name = Constants.LICENSE_BUNDLE_NAME;
|
||||
Bundle created = bundleService.create(context, it, name);
|
||||
created.setName(context, name);
|
||||
|
||||
@@ -1167,7 +1167,7 @@ public class ItemTest extends AbstractDSpaceObjectTest {
|
||||
public void testRemoveLicensesNoAuth() throws Exception {
|
||||
// First create test content
|
||||
context.turnOffAuthorisationSystem();
|
||||
String name = "LICENSE";
|
||||
String name = Constants.LICENSE_BUNDLE_NAME;
|
||||
Bundle created = bundleService.create(context, it, name);
|
||||
created.setName(context, name);
|
||||
|
||||
@@ -1376,7 +1376,7 @@ public class ItemTest extends AbstractDSpaceObjectTest {
|
||||
public void testReplaceAllBitstreamPolicies() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
//we add some bundles for the test
|
||||
String name = "LICENSE";
|
||||
String name = Constants.LICENSE_BUNDLE_NAME;
|
||||
Bundle created = bundleService.create(context, it, name);
|
||||
created.setName(context, name);
|
||||
|
||||
@@ -1451,7 +1451,7 @@ public class ItemTest extends AbstractDSpaceObjectTest {
|
||||
}
|
||||
|
||||
//we add some bundles for the test
|
||||
String name = "LICENSE";
|
||||
String name = Constants.LICENSE_BUNDLE_NAME;
|
||||
Bundle created = bundleService.create(context, it, name);
|
||||
created.setName(context, name);
|
||||
|
||||
|
@@ -31,6 +31,7 @@ import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.content.service.InstallItemService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.content.service.WorkspaceItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.dspace.core.service.LicenseService;
|
||||
import org.dspace.eperson.EPerson;
|
||||
@@ -259,7 +260,8 @@ public class LicenseUtilsTest extends AbstractUnitTest {
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
IOUtils.copy(
|
||||
bitstreamService.retrieve(context, itemService.getBundles(item, "LICENSE").get(0).getBitstreams().get(0)),
|
||||
bitstreamService.retrieve(context,
|
||||
itemService.getBundles(item, Constants.LICENSE_BUNDLE_NAME).get(0).getBitstreams().get(0)),
|
||||
writer, StandardCharsets.UTF_8);
|
||||
String license = writer.toString();
|
||||
|
||||
|
@@ -2167,7 +2167,7 @@ public class BitstreamRestRepositoryIT extends AbstractControllerIntegrationTest
|
||||
.build();
|
||||
|
||||
Bundle license = BundleBuilder.createBundle(context, publicItem1)
|
||||
.withName("LICENSE")
|
||||
.withName(Constants.LICENSE_BUNDLE_NAME)
|
||||
.build();
|
||||
|
||||
String bitstreamContent = "This is an archived bitstream";
|
||||
@@ -2221,7 +2221,7 @@ public class BitstreamRestRepositoryIT extends AbstractControllerIntegrationTest
|
||||
.build();
|
||||
|
||||
Bundle license = BundleBuilder.createBundle(context, publicItem1)
|
||||
.withName("LICENSE")
|
||||
.withName(Constants.LICENSE_BUNDLE_NAME)
|
||||
.build();
|
||||
|
||||
String bitstreamContent = "This is an archived bitstream";
|
||||
@@ -2267,7 +2267,7 @@ public class BitstreamRestRepositoryIT extends AbstractControllerIntegrationTest
|
||||
.build();
|
||||
|
||||
Bundle license = BundleBuilder.createBundle(context, publicItem1)
|
||||
.withName("LICENSE")
|
||||
.withName(Constants.LICENSE_BUNDLE_NAME)
|
||||
.build();
|
||||
|
||||
String bitstreamContent = "This is an archived bitstream";
|
||||
@@ -2332,7 +2332,7 @@ public class BitstreamRestRepositoryIT extends AbstractControllerIntegrationTest
|
||||
.build();
|
||||
|
||||
Bundle license = BundleBuilder.createBundle(context, publicItem1)
|
||||
.withName("LICENSE")
|
||||
.withName(Constants.LICENSE_BUNDLE_NAME)
|
||||
.build();
|
||||
|
||||
String bitstreamContent = "This is an archived bitstream";
|
||||
@@ -2372,7 +2372,7 @@ public class BitstreamRestRepositoryIT extends AbstractControllerIntegrationTest
|
||||
.build();
|
||||
|
||||
Bundle license = BundleBuilder.createBundle(context, publicItem1)
|
||||
.withName("LICENSE")
|
||||
.withName(Constants.LICENSE_BUNDLE_NAME)
|
||||
.build();
|
||||
|
||||
String bitstreamContent = "This is an archived bitstream";
|
||||
|
@@ -358,7 +358,7 @@ public class LinksetRestControllerIT extends AbstractControllerIntegrationTest {
|
||||
}
|
||||
|
||||
try (InputStream is = IOUtils.toInputStream("test", CharEncoding.UTF_8)) {
|
||||
Bitstream bitstream4 = BitstreamBuilder.createBitstream(context, item, is, "LICENSE")
|
||||
Bitstream bitstream4 = BitstreamBuilder.createBitstream(context, item, is, Constants.LICENSE_BUNDLE_NAME)
|
||||
.withName("Bitstream 4")
|
||||
.withDescription("description")
|
||||
.withMimeType("application/pdf")
|
||||
|
Reference in New Issue
Block a user