Revision 5098
Added by daigle over 14 years ago
MetacatClient.java | ||
---|---|---|
710 | 710 |
* reached or does not respond |
711 | 711 |
* @throws MetacatException when the metacat server generates another error |
712 | 712 |
*/ |
713 |
public String setAccess(String _docid, String _principal, String |
|
714 |
_permission, String _permType, |
|
715 |
String _permOrder ) |
|
713 |
public String setAccess(String docid, String principal, String |
|
714 |
permission, String permType, String permOrder ) |
|
716 | 715 |
throws InsufficientKarmaException, MetacatException, |
717 | 716 |
MetacatInaccessibleException { |
718 | 717 |
//set up properties |
719 | 718 |
Properties prop = new Properties(); |
720 | 719 |
prop.put("action", "setaccess"); |
721 |
prop.put("docid", _docid);
|
|
722 |
prop.put("principal", _principal);
|
|
723 |
prop.put("permission", _permission);
|
|
724 |
prop.put("permType", _permType);
|
|
725 |
prop.put("permOrder", _permOrder);
|
|
720 |
prop.put("docid", docid); |
|
721 |
prop.put("principal", principal); |
|
722 |
prop.put("permission", permission); |
|
723 |
prop.put("permType", permType); |
|
724 |
prop.put("permOrder", permOrder); |
|
726 | 725 |
|
727 | 726 |
String response = null; |
728 | 727 |
try { |
... | ... | |
743 | 742 |
} |
744 | 743 |
|
745 | 744 |
/** |
745 |
* Set access for a given doc id. The access is represented in an access |
|
746 |
* block of xml. All existing access will be replaced with the access |
|
747 |
* provided in the access block. |
|
748 |
* |
|
749 |
* @param docid |
|
750 |
* the doc id for the doc we want to update |
|
751 |
* @param accessBlock |
|
752 |
* the xml access block. This is the same structure as that |
|
753 |
* returned by the getdocumentinfo action in metacat. |
|
754 |
* @return a string holding the response xml |
|
755 |
*/ |
|
756 |
public String setAccess(String docid, String accessBlock) |
|
757 |
throws InsufficientKarmaException, MetacatException, MetacatInaccessibleException { |
|
758 |
//set up properties |
|
759 |
Properties prop = new Properties(); |
|
760 |
prop.put("action", "setaccess"); |
|
761 |
prop.put("docid", docid); |
|
762 |
prop.put("accessBlock", accessBlock); |
|
763 |
|
|
764 |
String response = null; |
|
765 |
try { |
|
766 |
response = sendDataForString(prop, null, null, 0); |
|
767 |
} catch (Exception e) { |
|
768 |
throw new MetacatInaccessibleException(e.getMessage()); |
|
769 |
} |
|
770 |
|
|
771 |
// Check for an error condition |
|
772 |
if (response.indexOf("<error>") != -1) { |
|
773 |
if (response.indexOf("does not have permission") != -1) { |
|
774 |
throw new InsufficientKarmaException(response); |
|
775 |
} else { |
|
776 |
throw new MetacatException(response); |
|
777 |
} |
|
778 |
} |
|
779 |
return response; |
|
780 |
} |
|
781 |
|
|
782 |
/** |
|
746 | 783 |
* When the MetacatFactory creates an instance it needs to set the |
747 | 784 |
* MetacatUrl to which connections should be made. |
748 | 785 |
* |
Also available in: Unified diff
change AccessControlForSingleFile to only be instantiated for one file. move ACL methods to AccessControlForSingleFile. Change format of access sections returned to EML 2.1.0.