Revision 7134
Added by Chris Jones over 12 years ago
src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java | ||
---|---|---|
725 | 725 |
// if MNs are listed as replicas, allow access |
726 | 726 |
if ( systemMetadata != null ) { |
727 | 727 |
replicaList = systemMetadata.getReplicaList(); |
728 |
if ( subject != null ) { |
|
729 |
// get the list of nodes with a matching node subject |
|
730 |
try { |
|
731 |
nodeListBySubject = listNodesBySubject(session.getSubject()); |
|
732 |
|
|
733 |
} catch (BaseException e) { |
|
734 |
// Unexpected error contacting the CN via D1Client |
|
735 |
String msg = "Caught an unexpected error while trying " + |
|
736 |
"to potentially authorize system metadata access " + |
|
737 |
"based on the session subject. The error was " + |
|
738 |
e.getMessage(); |
|
739 |
logMetacat.error(msg); |
|
740 |
if ( logMetacat.isDebugEnabled() ) { |
|
741 |
e.printStackTrace(); |
|
742 |
|
|
728 |
// only check if there are in fact replicas listed |
|
729 |
if ( replicaList != null ) { |
|
730 |
|
|
731 |
if ( subject != null ) { |
|
732 |
// get the list of nodes with a matching node subject |
|
733 |
try { |
|
734 |
nodeListBySubject = listNodesBySubject(session |
|
735 |
.getSubject()); |
|
736 |
|
|
737 |
} catch (BaseException e) { |
|
738 |
// Unexpected error contacting the CN via D1Client |
|
739 |
String msg = "Caught an unexpected error while trying " |
|
740 |
+ "to potentially authorize system metadata access " |
|
741 |
+ "based on the session subject. The error was " |
|
742 |
+ e.getMessage(); |
|
743 |
logMetacat.error(msg); |
|
744 |
if (logMetacat.isDebugEnabled()) { |
|
745 |
e.printStackTrace(); |
|
746 |
|
|
747 |
} |
|
748 |
// isAuthorized is still false |
|
743 | 749 |
} |
744 |
// isAuthorized is still false |
|
750 |
|
|
745 | 751 |
} |
752 |
if (nodeListBySubject != null) { |
|
753 |
// compare node ids to replica node ids |
|
754 |
outer: for (Replica replica : replicaList) { |
|
755 |
replicaNodeRef = replica.getReplicaMemberNode(); |
|
746 | 756 |
|
747 |
} |
|
748 |
|
|
749 |
if ( nodeListBySubject != null ) { |
|
750 |
// compare node ids to replica node ids |
|
751 |
outer: |
|
752 |
for (Replica replica : replicaList) { |
|
753 |
replicaNodeRef = replica.getReplicaMemberNode(); |
|
754 |
|
|
755 |
for (Node node : nodeListBySubject ) { |
|
756 |
if (node.getIdentifier().equals(replicaNodeRef)) { |
|
757 |
// node id via session subject matches a replica node |
|
758 |
isAuthorized = true; |
|
759 |
break outer; |
|
757 |
for (Node node : nodeListBySubject) { |
|
758 |
if (node.getIdentifier().equals(replicaNodeRef)) { |
|
759 |
// node id via session subject matches a replica node |
|
760 |
isAuthorized = true; |
|
761 |
break outer; |
|
762 |
} |
|
760 | 763 |
} |
761 | 764 |
} |
762 | 765 |
} |
Also available in: Unified diff
As Ben suggested, don't compare to the node list if there are no replicas listed. This reduces the number of calls to listNodes() on the CN.