in src/main/java/com/aliyun/oss/internal/ResponseParsers.java [2604:2676]
public static List<ReplicationRule> parseGetBucketReplication(InputStream responseBody)
throws ResponseParseException {
try {
List<ReplicationRule> repRules = new ArrayList<ReplicationRule>();
Element root = getXmlRootElement(responseBody);
List<Element> ruleElems = root.getChildren("Rule");
for (Element ruleElem : ruleElems) {
ReplicationRule repRule = new ReplicationRule();
repRule.setReplicationRuleID(ruleElem.getChildText("ID"));
Element destination = ruleElem.getChild("Destination");
repRule.setTargetBucketName(destination.getChildText("Bucket"));
repRule.setTargetBucketLocation(destination.getChildText("Location"));
repRule.setTargetCloud(destination.getChildText("Cloud"));
repRule.setTargetCloudLocation(destination.getChildText("CloudLocation"));
repRule.setReplicationStatus(ReplicationStatus.parse(ruleElem.getChildText("Status")));
if (ruleElem.getChildText("HistoricalObjectReplication").equals("enabled")) {
repRule.setEnableHistoricalObjectReplication(true);
} else {
repRule.setEnableHistoricalObjectReplication(false);
}
if (ruleElem.getChild("PrefixSet") != null) {
List<String> objectPrefixes = new ArrayList<String>();
List<Element> prefixElems = ruleElem.getChild("PrefixSet").getChildren("Prefix");
for (Element prefixElem : prefixElems) {
objectPrefixes.add(prefixElem.getText());
}
repRule.setObjectPrefixList(objectPrefixes);
}
if (ruleElem.getChild("Action") != null) {
String[] actionStrs = ruleElem.getChildText("Action").split(",");
List<ReplicationAction> repActions = new ArrayList<ReplicationAction>();
for (String actionStr : actionStrs) {
repActions.add(ReplicationAction.parse(actionStr));
}
repRule.setReplicationActionList(repActions);
}
repRule.setSyncRole(ruleElem.getChildText("SyncRole"));
if (ruleElem.getChild("EncryptionConfiguration") != null){
repRule.setReplicaKmsKeyID(ruleElem.getChild("EncryptionConfiguration").getChildText("ReplicaKmsKeyID"));
}
if (ruleElem.getChild("SourceSelectionCriteria") != null &&
ruleElem.getChild("SourceSelectionCriteria").getChild("SseKmsEncryptedObjects") != null) {
repRule.setSseKmsEncryptedObjectsStatus(ruleElem.getChild("SourceSelectionCriteria").
getChild("SseKmsEncryptedObjects").getChildText("Status"));
}
if (ruleElem.getChild("Source") != null){
repRule.setSourceBucketLocation(ruleElem.getChild("Source").getChildText("Location"));
}
repRules.add(repRule);
}
return repRules;
} catch (JDOMParseException e) {
throw new ResponseParseException(e.getPartialDocument() + ": " + e.getMessage(), e);
} catch (Exception e) {
throw new ResponseParseException(e.getMessage(), e);
}
}