* @return Array of buckets
*/
public static Bucket[] loadBucketsFromRegistry(int tenantId) throws CEPConfigurationException {
Bucket[] buckets = null;
Registry registry = null;
try {
registry = CEPServiceValueHolder.getInstance().getRegistry(tenantId);
} catch (RegistryException e) {
String errorMessage = "Error in getting registry specific to tenant :" + tenantId;
log.error(errorMessage, e);
throw new CEPConfigurationException(errorMessage, e);
}
String parentCollectionPath = CEPConstants.CEP_CONF_ELE_CEP_BUCKETS + CEPConstants.CEP_REGISTRY_BS;
try {
if (registry.resourceExists(parentCollectionPath)) {
if (registry.get(parentCollectionPath) instanceof Collection) {
Collection cepBucketsCollection = (Collection) registry.get(parentCollectionPath);
buckets = new Bucket[cepBucketsCollection.getChildCount()];
int bucketCount = 0;
for (String bucketName : cepBucketsCollection.getChildren()) {
Bucket bucket = new Bucket();
if (registry.get(bucketName) instanceof Collection) {
Collection bucketDetailsCollection = (Collection) registry.get(bucketName);
for (String attirbute : bucketDetailsCollection.getChildren()) {
if (registry.get(attirbute) instanceof Collection) {
Input input;
Query query;
Collection attributeCollection = (Collection) registry.get(attirbute);
for (String names : attributeCollection.getChildren()) {
if (registry.get(names) instanceof Collection) {
if ((CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_INPUTS)
.equals(attirbute.substring(attirbute.lastIndexOf(CEPConstants.CEP_REGISTRY_BS)))) {
input = new Input();
Collection collection3 = (Collection) registry.get(names);
for (String names2 : collection3.getChildren()) {
if (registry.get(names2) instanceof Collection) {
Collection mappingCollection = (Collection) registry.get(names2);
Mapping mapping = new Mapping();
for (String mappingChild : mappingCollection.getChildren()) {
if (registry.get(mappingChild) instanceof Collection) {
Collection mapCollection = (Collection) registry.get(mappingChild);
if ((CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_XPATH_DEFS)
.equals(mappingChild.substring(mappingChild.lastIndexOf(CEPConstants.CEP_REGISTRY_BS)))) {
for (String defs : mapCollection.getChildren()) {
Resource xpathDefResource = registry.get(defs);
Hashtable propertiesHashtable = xpathDefResource.getProperties();
Enumeration e = propertiesHashtable.keys();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
ArrayList values = (ArrayList) propertiesHashtable.get(key);
XpathDefinition xpathDefinition = new XpathDefinition();
xpathDefinition.setPrefix(key);
xpathDefinition.setNamespace(values.get(0).toString());
mapping.addXpathDefinition(xpathDefinition);
}
}
} else if (
(CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_PROPERTIES)
.equals(mappingChild.substring(mappingChild.lastIndexOf(CEPConstants.CEP_REGISTRY_BS)))) {
for (String defs : mapCollection.getChildren()) {
Resource xpathDefResource = registry.get(defs);
Hashtable propertiesHashtable = xpathDefResource.getProperties();
Enumeration e = propertiesHashtable.keys();
Property property = new Property();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
ArrayList values = (ArrayList) propertiesHashtable.get(key);
if (CEPConstants.CEP_REGISTRY_NAME.equals(key)) {
property.setName(values.get(0).toString());
} else if (CEPConstants.CEP_REGISTRY_TYPE.equals(key)) {
property.setType(values.get(0).toString());
} else if (CEPConstants.CEP_REGISTRY_XPATH.equals(key)) {
property.setXpath(values.get(0).toString());
}
}
mapping.addProperty(property);
}
}
} else {
Resource resource = registry.get(mappingChild);
Hashtable propertiesHashtable = resource.getProperties();
Enumeration e = propertiesHashtable.keys();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
ArrayList values = (ArrayList) propertiesHashtable.get(key);
if (CEPConstants.CEP_REGISTRY_STREAM.equals(key)) {
mapping.setStream(values.get(0).toString());
}
}
}
}
input.setMapping(mapping);
} else {
if ((CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_DETAILS)
.equals(names2.substring(names2.lastIndexOf(CEPConstants.CEP_REGISTRY_BS)))) {
Resource resource = registry.get(names2);
Hashtable propertiesHashtable = resource.getProperties();
Enumeration e = propertiesHashtable.keys();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
ArrayList values = (ArrayList) propertiesHashtable.get(key);
if (CEPConstants.CEP_REGISTRY_TOPIC.equals(key)) {
input.setTopic(values.get(0).toString());
} else if (CEPConstants.CEP_CONF_ELE_BROKER_NAME.equals(key)) {
input.setBrokerName(values.get(0).toString());
}
}
}
}
}
bucket.addInput(input);
} else if ((CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_QUERIES)
.equals(attirbute.substring(attirbute.lastIndexOf(CEPConstants.CEP_REGISTRY_BS)))) {
query = new Query();
Expression expression = new Expression();
Output output = new Output();
Collection collection3 = (Collection) registry.get(names);
for (String names2 : collection3.getChildren()) {
if (registry.get(names2) instanceof Collection) {
Collection outputCollection = (Collection) registry.get(names2);
for (String outputS : outputCollection.getChildren()) {
if (registry.get(outputS) instanceof Collection) {
Collection outputMapping = (Collection) registry.get(outputS);
if ((CEPConstants.CEP_REGISTRY_BS + CEPConstants.CEP_REGISTRY_ELEMENT_MAPPING)
.equals(outputS.substring(outputS.lastIndexOf(CEPConstants.CEP_REGISTRY_BS)))) {
ElementMapping elementMapping = new ElementMapping();
for (String mappingName : outputMapping.getChildren()) {
if (registry.get(mappingName) instanceof Collection) {
Collection propertyCollection = (Collection) registry.get(mappingName);
for (String propertyName : propertyCollection.getChildren()) {
Resource propertyResource = registry.get(propertyName);
Hashtable propertiesHashtable = propertyResource.getProperties();
Enumeration e = propertiesHashtable.keys();
Property property = new Property();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
ArrayList values = (ArrayList) propertiesHashtable.get(key);
if (CEPConstants.CEP_REGISTRY_NAME.equals(key)) {
property.setName(values.get(0).toString());
} else if (CEPConstants.CEP_REGISTRY_XML_FIELD_NAME.equals(key)) {
property.setXmlFieldName(values.get(0).toString());
} else if (CEPConstants.CEP_REGISTRY_XML_FIELD_TYPE.equals(key)) {
property.setXmlFieldType(values.get(0).toString());
}
}
elementMapping.addProperty(property);
}
} else {
Resource outputdetailsResource = registry.get(mappingName);
Hashtable propertiesHashtable = outputdetailsResource.getProperties();
Enumeration e = propertiesHashtable.keys();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
ArrayList values = (ArrayList) propertiesHashtable.get(key);
if (CEPConstants.CEP_REGISTRY_DOC_ELEMENT.equals(key)) {
elementMapping.setDocumentElement(values.get(0).toString());
} else if (CEPConstants.CEP_REGISTRY_NS.equals(key)) {
elementMapping.setNamespace(values.get(0).toString());
}
}
}
output.setElementMapping(elementMapping);
}
} else {
XMLMapping xmlMapping = null;
for (String mappingName : outputMapping.getChildren()) {
xmlMapping = new XMLMapping();
if (registry.get(mappingName) instanceof Collection) {
} else {
Resource outputdetailsResource = registry.get(mappingName);
Hashtable propertiesHashtable = outputdetailsResource.getProperties();
Enumeration e = propertiesHashtable.keys();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
ArrayList values = (ArrayList) propertiesHashtable.get(key);
if (CEPConstants.CEP_REGISTRY_TEXT.equals(key)) {
xmlMapping.setMappingXMLText(values.get(0).toString());
}
}
}
}
output.setXmlMapping(xmlMapping);
}
} else {
Resource outputdetailsResource = registry.get(outputS);
Hashtable propertiesHashtable = outputdetailsResource.getProperties();
Enumeration e = propertiesHashtable.keys();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
ArrayList values = (ArrayList) propertiesHashtable.get(key);
if (CEPConstants.CEP_REGISTRY_TOPIC.equals(key)) {
output.setTopic(values.get(0).toString());
} else if (CEPConstants.CEP_CONF_ELE_BROKER_NAME.equals(key)) {
output.setBrokerName(values.get(0).toString());
}
}
}
}
} else {
Resource detailsResource = registry.get(names2);
Hashtable propertiesHashtable = detailsResource.getProperties();
Enumeration e = propertiesHashtable.keys();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
ArrayList values = (ArrayList) propertiesHashtable.get(key);
if (CEPConstants.CEP_REGISTRY_NAME.equals(key)) {
query.setName(values.get(0).toString());
} else if (CEPConstants.CEP_REGISTRY_TYPE.equals(key)) {
expression.setType(values.get(0).toString());
} /*else if (CEPConstants.CEP_REGISTRY_EXPRESSION.equals(key)) {
expression.setText(values.get(0).toString());
}*/
}
String content = new String((byte[]) detailsResource.getContent());
expression.setText(content);
}
}
query.setExpression(expression);
query.setOutput(output);
bucket.addQuery(query);
}
}
}
} else {
Resource propertyResource = registry.get(attirbute);
Hashtable propeHashtable = propertyResource.getProperties();
Enumeration e = propeHashtable.keys();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
ArrayList values = (ArrayList) propeHashtable.get(key);