Skip to content

Commit

Permalink
Brought in only the customization specific changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathew1011 committed Oct 31, 2023
1 parent cc738cd commit 7c87905
Showing 1 changed file with 16 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,63 +54,53 @@ public class FullTextContentStreams extends ContentStreamBase {
//TAMU Customization - We need a BundleService to check for bitstream restrictions before indexing them
protected final BundleService bundleService = ContentServiceFactory.getInstance().getBundleService();

public FullTextContentStreams(Context context, Item parentItem) {
public FullTextContentStreams(Context context, Item parentItem) throws SQLException {
this.context = context;
try {
init(parentItem);
} catch (Exception e) {
e.printStackTrace();
}
init(parentItem);
}

protected void init(Item parentItem) {
protected void init(Item parentItem) throws SQLException {
fullTextStreams = new ArrayList<>();

if (parentItem != null) {

try {
sourceInfo = parentItem.getHandle();
sourceInfo = parentItem.getHandle();

//extracted full text is always extracted as plain text
contentType = "text/plain";
//extracted full text is always extracted as plain text
contentType = "text/plain";

buildFullTextList(parentItem);
} catch (Exception e) {
// TODO: handle exception
}
buildFullTextList(parentItem);
}
}

/**
* @param parentItem
* @throws SQLException
*/
private void buildFullTextList(Item parentItem) throws SQLException {
// now get full text of any bitstreams in the TEXT bundle
// trundle through the bundles
List<Bundle> myBundles = parentItem.getBundles();

for (Bundle myBundle : emptyIfNull(myBundles)) {
if (StringUtils.equals(FULLTEXT_BUNDLE, myBundle.getName())) {
// getting text out of the bitstreams
// a-ha! grab the text out of the bitstreams
List<Bitstream> bitstreams = myBundle.getBitstreams();
log.debug("Processing full-text bitstreams. Item handle: " + sourceInfo);

// TAMU Customization - Get bundle policies
// TAMU Customization - Only index text bitstreams that are not restricted
List<ResourcePolicy> bundlePolicies = bundleService.getBitstreamPolicies(context, myBundle);
boolean isIndexable = false;

log.debug("Processing full-text bitstreams. Item handle: " + sourceInfo);

for (Bitstream fulltextBitstream : emptyIfNull(bitstreams)) {
// TAMU Customization - Only index text bitstreams that are not restricted
boolean isIndexable = false;
for (ResourcePolicy rp : bundlePolicies) {
isIndexable = false;

for (ResourcePolicy rp:bundlePolicies) {
if (rp.getdSpaceObject().getID() == fulltextBitstream.getID()) {
if (rp.getGroup().getName().equalsIgnoreCase("anonymous")) {
isIndexable = true;
}
break;
}
}

// TAMU Customization - Only index text bitstreams that are not restricted
if (isIndexable) {
fullTextStreams.add(new FullTextBitstream(sourceInfo, fulltextBitstream));

Expand Down Expand Up @@ -264,4 +254,3 @@ public InputStream nextElement() {
}

}

0 comments on commit 7c87905

Please sign in to comment.