Package org.wso2.carbon.bam.util

Examples of org.wso2.carbon.bam.util.BAMException


                    parse.close();
                }
            }

        } catch (XMLStreamException e) {
            throw new BAMException("error occurred creating stream for bam.xml", e);
        } catch (IOException e) {
            throw new BAMException("error occurred getting bam.xml ", e);
        }

        return bamDocumentElement;
    }
View Full Code Here


        if (bamConfFileOMElement != null) {
            configType = bamConfFileOMElement.getFirstElement();
        }
        if (configType == null) {
            throw new BAMException("configType  does not exist in bam.xml file");
        }

        return configType.getAttributeValue(new QName("type"));

    }
View Full Code Here

    protected String getBAMConfigType(OMElement bamConfig, String elementName) throws BAMException {

        OMElement configType = bamConfig.getFirstElement();
        if (configType == null) {
            throw new BAMException(elementName + "  does not exist in bam.xml file");
        }

        return configType.getAttributeValue(new QName("type"));
    }
View Full Code Here

    }

    protected String getPublisherEPR(OMElement bamConfig, String eprName) throws BAMException {
        OMElement bamMsgProcessor = bamConfig.getFirstChildWithName(new QName("bamMessageProcessor"));
        if (bamMsgProcessor == null) {
            throw new BAMException("bamMessageProcessor did not mention in bam.xml");
        }
        OMElement serverDataEpr = bamMsgProcessor.getFirstChildWithName(new QName(eprName));
        if (serverDataEpr == null) {
            throw new BAMException(eprName + " did not mention in bam.xml");
        }

        return serverDataEpr.getText();
    }
View Full Code Here

                break;
            case BAMCalendar.YEAR:
                time = meteringStub.getLatestYearlyBandwidthSummaryPeriodId(serverId);
                break;
            default:
                throw new BAMException("Unexpected timeInterval");
            }
           
            if (time != null && time[0] != null) {
                //we are sure that there will be only one record.
                cal = BAMCalendar.getInstance(time[0].getStartTime());
            }else {
                //This is the first time we are running the summary. So, get the minimum time stamp
                //for this server from "server user data" table
                time = meteringStub.getMinimumPeriodId(serverId);
                if (time != null && time[0] != null) {
                    //we are sure that there will be only one record.
                    cal = BAMCalendar.getInstance(time[0].getStartTime());
                }else{
                    //We are running for the first time and there are no records in
                    //"server user data". So, we can start from now
                    cal = BAMCalendar.getInstance();
                }
                //Start with last period so that it will include our intended period
                cal.add(summaryPeriod, -2);
            }
           
        } catch (Exception e) {
            String msg = "Unable to get LatestSummaryTime";
            log.error(msg);
            throw new BAMException(msg, e);
        }
        return cal;
    }
View Full Code Here

                break;
            case BAMCalendar.MONTH:
                time = meteringStub.getLatestMonthlyRegistryBandwidthSummaryPeriodId(tenantId);
                break;
            default:
                throw new BAMException("Unexpected timeInterval");
            }
            if (time == null || time[0] == null) {
                //This is the first time we are running the summary. So, start with current - 1 period
                cal = BAMCalendar.getInstance();
                cal.add(summaryPeriod, -2);
            }else{
                //we are sure that there will be only one record.
                cal = BAMCalendar.getInstance(time[0].getStartTime());
            }
        } catch (Exception e) {
            String msg = "Unable to get LatestSummaryTime";
                log.error(msg);
                throw new BAMException(msg, e);
        }
        return cal;
    }
View Full Code Here

        try {
            if (bamListAdminClient != null) {
                serverList = bamListAdminClient.getServerList();
            }
        } catch (BAMException e) {
            throw new BAMException("failed to get server list", e);
        }
        if (serverList != null) {
            for (MonitoredServerDTO monitoredServerDTO : serverList) {
                if (monitoredServerDTO.getServerId() == serverID) {
                    serverURL = monitoredServerDTO.getServerURL();
                }
            }
        }

        result.append("<level0 name=\"").append(serverURL).append("\">\n");
        try {
            if (bamDSClient != null) {
                Endpoint[] endpointList = bamDSClient.getEndpoints(serverID);
                if (endpointList != null && endpointList.length > 0) {
                    result.append("<level1 name=\"").append("Endpoints").append("\">\n");
                    for (Endpoint endpoint : endpointList) {
                        result.append(" <level2 name=\"").append(endpoint.getEndpoint()).append("\"");
                        result.append(" count=\"").append(bamDSClient.getLatestInCumulativeCountForEndpoint(serverID,
                                                                                                            "EndpointInCumulativeCount-" + endpoint.getEndpoint())).append("\"");
                        result.append(" meta1=\"").append(bamDSClient.getLatestInCumulativeCountForEndpoint(serverID,
                                                                                                            "EndpointInCumulativeCount-" + endpoint.getEndpoint())).append("\"");
                        result.append(" meta3=\"").append(bamDSClient.getLatestInFaultCountForEndpoint(serverID, "EndpointInFaultCount-"
                                                                                                                 + endpoint.getEndpoint())).append("\"");
                        result.append(" meta4=\"").append(bamDSClient.getLatestInAverageProcessingTimeForEndpointNoWrap(serverID,
                                                                                                                        "EndpointInAvgProcessingTime-" + endpoint.getEndpoint())).append("\"");
                        result.append(" meta5=\"").append(bamDSClient.getLatestInMinimumProcessingTimeForEndpointNoWrap(serverID,
                                                                                                                        "EndpointInMinProcessingTime-" + endpoint.getEndpoint())).append("\"");
                        result.append(" meta6=\"").append(bamDSClient.getLatestInMaximumProcessingTimeForEndpointNoWrap(serverID,
                                                                                                                        "EndpointInMaxProcessingTime-" + endpoint.getEndpoint())).append("\"");
                        result.append("/>\n");
                    }
                    result.append("</level1>\n");
                }
            }
        } catch (RemoteException e) {
            throw new BAMException("error occurred getting end points from server id =" + serverID, e);
        }

        if (bamDSClient != null) {
            ProxyService[] proxyServiceList = bamDSClient.getProxyServices(serverID);
            if (proxyServiceList != null && proxyServiceList.length > 0) {
View Full Code Here

                        // pick the key
                        QName keyQname = new QName(SERVER_USER_DEFINED_DATA_NS_URI, ELEMENT_NAME_KEY);
                        OMElement keyElement = dataElement.getFirstChildWithName(keyQname);
                        if (keyElement == null) {
                            messageFaultReason = "Key element not found in the message";
                            throw new BAMException(messageFaultReason);
                        }
                        // pick the value
                        QName valueQname = new QName(SERVER_USER_DEFINED_DATA_NS_URI, ELEMENT_NAME_VALUE);
                        OMElement valueElement = dataElement.getFirstChildWithName(valueQname);
                        if (valueElement == null) {
                            messageFaultReason = "Value element not found in the message";
                            throw new BAMException(messageFaultReason);
                        }

                        ServerUserDefinedDO serverUserDefinedDO = new ServerUserDefinedDO(server.getId() ,serverName,
                                calendar, keyElement.getText(), valueElement.getText());

                        try {
                            dsAdmin.addServerUserDefinedData(serverUserDefinedDO);
                        } catch (BAMException e) {
                            log.error("Error updating user defined data for server " + serverName
                                      + " from eventing message messagereceiver " + e.getLocalizedMessage(), e);
                        }
                    }
                } else {
                    // Invalid message, missing ServerName element
                    messageFaultReason = "ServerName element not found in the message";
                    throw new BAMException(messageFaultReason);
                }

            } else {
                // Invalid message, missing ServiceStatisticsData element
                messageFaultReason = "ServerUserDefinedData element not found in the message";
                throw new BAMException(messageFaultReason);
            }
        }
    }
View Full Code Here

                        OMElement dataElement = (OMElement) dataElements.next();
                        QName keyQName = new QName(OPERATION_USER_DEFINED_DATA_NS_URI, ELEMENT_NAME_KEY);
                        OMElement keyElement = dataElement.getFirstChildWithName(keyQName);
                        if (keyElement == null) {
                            messageFaultReason = "Key element not found in the message";
                            throw new BAMException(messageFaultReason);
                        }
                        QName valueQName = new QName(OPERATION_USER_DEFINED_DATA_NS_URI, ELEMENT_NAME_VALUE);
                        OMElement valueElement = dataElement.getFirstChildWithName(valueQName);
                        if (valueElement == null) {
                            messageFaultReason = "Value element not found in the message";
                            throw new BAMException(messageFaultReason);
                        }

                        OperationUserDefinedDO operationUserDefinedDO = new OperationUserDefinedDO(operationName, calendar,
                                                                                                   keyElement.getText(), valueElement.getText());

                        try {

                            int serverID = 0;
                            int serviceID = 0;
                            // check whether server is already in DB else add it
                            ServerDO server = dsAdmin.getServer(serverName, tenantId,
                                    BAMConstants.SERVER_TYPE_EVENTING,BAMConstants.MEDIATION_STAT_TYPE);
                            if (server == null) {
                                if (serverName != null && serverName.length() > 0) {
                                    server = new ServerDO();
                                    server.setServerURL(serverName);
                                    server.setTenantID(tenantId);
                                    BAMPersistenceManager.getPersistenceManager(BAMUtil.getRegistry()).syncServer(server);
                                }
                            } else {
                                serverID = server.getId();
                            }
                            ServiceDO monitoringService= dsAdmin.getService(serverID, serviceName);
                            // check whether service is already in DB else add it
                            if ( monitoringService== null) {
                                if (serviceName != null && serviceName.length() > 0) {
                                    ServiceDO service = new ServiceDO();
                                    service.setServerID(serverID);
                                    service.setName(serviceName);
                                    BAMPersistenceManager.getPersistenceManager(BAMUtil.getRegistry()).syncService(service);
                                    serviceID = monitoringService.getId();
                                }
                            } else {
                                serviceID = monitoringService.getId();
                            }

                            OperationDO monitoringOperation= dsAdmin.getOperation(serviceID, operationName);
                            // check whether operation is already in DB else add it
                            if (monitoringOperation == null) {

                                OperationDO operation = new OperationDO();
                                operation.setServiceID(serviceID);
                                operation.setName(operationName);
                                BAMPersistenceManager.getPersistenceManager(BAMUtil.getRegistry()).syncOperation(operation);
                            }

                            operationUserDefinedDO.setOperationID(monitoringOperation.getOperationID());
                            dsAdmin.addUserDefinedOperationData(operationUserDefinedDO);
                        } catch (Exception e) {
                            log.error("Error updating user defined data for operation " + operationName
                                      + " from eventing message messagereceiver " + e.getLocalizedMessage(), e);
                        }
                    }
                } else {
                    // Invalid message, missing ServerName element
                    messageFaultReason = "OperationName/ServiceName/WSASServerName element not found in the message";
                    throw new BAMException(messageFaultReason);
                }

            } else {
                // Invalid message, missing ServiceStatisticsData element
                messageFaultReason = "OperationUserDefinedData element not found in the message";
                throw new BAMException(messageFaultReason);
            }
        }
    }
View Full Code Here

        Message[] adbMessageArray = new Message[0];

        try {
            adbMessageArray = stub.getMessage(messageKeyId);
        } catch (RemoteException e) {
            throw new BAMException("getMessage failed", e);
        } catch (DataServiceFaultException e) {
            throw new BAMException("getMessage failed", e);
        }

        if (adbMessageArray != null && adbMessageArray.length > 0) {
            Message adbMessage = adbMessageArray[0];
            message = new MessageDO();
View Full Code Here

TOP

Related Classes of org.wso2.carbon.bam.util.BAMException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.