Skip to content

Commit

Permalink
Remove some commented old code.
Browse files Browse the repository at this point in the history
  • Loading branch information
taojing2002 committed Feb 25, 2019
1 parent 3d18123 commit 1e385ab
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 114 deletions.
16 changes: 1 addition & 15 deletions src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2008,21 +2008,7 @@ public boolean updateReplicationMetadata(Session session, Identifier pid,
D1AuthHelper authDel = new D1AuthHelper(request, pid, "4851", "4852");
authDel.doCNOnlyAuthorization(session);
}
/*try {
// what is the controlling permission?
if (!isAuthorized(session, pid, Permission.WRITE)) {
throw new NotAuthorized("4851", "not allowed by "
+ subject.getValue() + " on " + pid.getValue());
}
} catch (InvalidToken e) {
throw new NotAuthorized("4851", "not allowed by " + subject.getValue() +
" on " + pid.getValue());
}*/


SystemMetadata systemMetadata = null;
try {
lock = HazelcastService.getInstance().getLock(pid.getValue());
Expand Down
82 changes: 0 additions & 82 deletions src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2030,88 +2030,6 @@ protected SystemMetadata getSystemMetadataForPID(Identifier pid, String serviceF
return sysmeta;
}

/*protected SystemMetadata getSeriesHead(Identifier id, String serviceFailureCode, String notFoundCode) throws ServiceFailure, NotFound
{
try {
return getSeriesHead(id,serviceFailureCode, notFoundCode, null);
} catch (InvalidRequest e) {
ServiceFailure sf = new ServiceFailure(serviceFailureCode,e.getDescription());
sf.initCause(e);
throw sf;
}
}*/



/**
* If the id is a PID, returns the SystemMetadata associated with it. If the id is a SID,
* returns the SystemMetadata of the series' current head.
* @param id - either PID or SID
* @param serviceFailureCode - the detail code to use if ServiceFailure is
* @return - a systemMetadata object, never null
* @throws ServiceFailure
* @throws NotFound
* @throws InvalidRequest
*/
/*protected SystemMetadata getSeriesHead(Identifier id, String serviceFailureCode, String notFoundCode, String invalidRequestCode) throws ServiceFailure, NotFound, InvalidRequest {
SystemMetadata sysmeta = null;
if (id == null || StringUtils.isAnyBlank(id.getValue())) {
throw new InvalidRequest(serviceFailureCode, "The passed-in Identifier cannot be null or blank!!");
}
try {
// check first to see if it is a pid
try {
sysmeta = HazelcastService.getInstance().getSystemMetadataMap().get(id);
} catch (Exception e) {
// convert Hazelcast RuntimeException to NotFound
logMetacat.error("An error occurred while getting system metadata for identifier " +
id.getValue() + ". The error message was: " + e.getMessage(), e);
throw new ServiceFailure(serviceFailureCode, "Can't get the system metadata for " + id.getValue()+ " since "+e.getMessage());
}
if (sysmeta != null) {
return sysmeta;
}
// need to check if it is a seriesId
Identifier headPid = IdentifierManager.getInstance().getHeadPID(id);
if (headPid == null) {
String localId = null;
// check for deleted status to create a more informative exception message
try {
localId = IdentifierManager.getInstance().getLocalId(id.getValue());
} catch (Exception e) {
logMetacat.warn("Couldn't find the local id for the pid "+id.getValue());
}
String error = "No system metadata could be found for given PID: " + id.getValue();
if(localId != null && EventLog.getInstance().isDeleted(localId)) {
error = error + ". "+DELETEDMESSAGE;
} else if (localId == null && EventLog.getInstance().isDeleted(id.getValue())) {
error = error + ". "+DELETEDMESSAGE;
}
throw new NotFound(notFoundCode, error);
}
sysmeta = HazelcastService.getInstance().getSystemMetadataMap().get(headPid);
if (sysmeta == null) {
String error = "An unexpected error occurred. Could not get systemMetadata from Hazelcast although I series head [ " + headPid.getValue() + " ] has been found!";
logMetacat.error(error);
throw new ServiceFailure(serviceFailureCode,error);
}
return sysmeta;
} catch (SQLException sqle) {
throw new ServiceFailure(serviceFailureCode, "Database exception raised while trying to determine the head PID from identifier '" + id.getValue()
+ "': " + sqle.getMessage());
}
}*/


/*
Expand Down
17 changes: 0 additions & 17 deletions src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ public Identifier delete(Session session, Identifier id)
throw new ServiceFailure("2902", ReadOnlyChecker.DATAONEERROR);
}

//SystemMetadata sysmeta = getSeriesHead(pid, serviceFailureCode,notFoundCode);
Identifier HeadOfSid = getPIDForSID(id, serviceFailureCode);
if(HeadOfSid != null) {
id = HeadOfSid;
Expand Down Expand Up @@ -2784,24 +2783,8 @@ public boolean updateSystemMetadata(Session session, Identifier pid,
throw new InvalidRequest("4869", "We can't find the current system metadata on the member node for the id "+pid.getValue());
}
try {
//Following session can do the change:
//- Authoritative Member Node (we can use isNodeAdmin since we checked isAuthoritativeNode )
//- Owner of object (coved by the userHasPermission method)
//- user subjects with the change permission
//Note: Coordinating Node can not because MN is authoritative
/*if(!isAuthoritativeNode(pid)) {
throw new InvalidRequest("4863", "Client can only call updateSystemMetadata request on the authoritative memember node.");
}
if(!isNodeAdmin(session) && !userHasPermission(session, pid, Permission.CHANGE_PERMISSION)) {
throw new NotAuthorized("4861", "The client -"+ session.getSubject().getValue()+ "is not authorized for updating the system metadata of the object "+pid.getValue());
}*/

D1AuthHelper authDel = new D1AuthHelper(request, pid, "4861","4868");
authDel.doUpdateAuth(session, currentSysmeta, Permission.CHANGE_PERMISSION, this.getCurrentNodeId());

// if(!allowUpdating(session, pid, Permission.CHANGE_PERMISSION)) {
// throw new NotAuthorized("4861", "The client -"+ session.getSubject().getValue()+ "is not authorized for updating the system metadata of the object "+pid.getValue());
// }
} catch(ServiceFailure e) {
throw new ServiceFailure("4868", "Can't determine if the client has the permission to update the system metacat of the object with id "+pid.getValue()+" since "+e.getDescription());
} catch(NotAuthorized e) {
Expand Down

0 comments on commit 1e385ab

Please sign in to comment.