Package org.apache.vysper.xmpp.modules.servicediscovery.collection

Examples of org.apache.vysper.xmpp.modules.servicediscovery.collection.ServiceCollector


        configureServiceRegistry(tsc);
        return tsc;
    }

    protected void configureServiceRegistry(TestSessionContext tsc) {
        ServiceCollector serviceCollector = new ServiceCollector();
        ((DefaultServerRuntimeContext) tsc.getServerRuntimeContext()).registerServerRuntimeContextService(serviceCollector);
    }
View Full Code Here


   
    @Override
    protected void setUp() throws Exception {
        super.setUp();
       
        ServiceCollector serviceCollector = new ServiceCollector();
        sessionContext.getServerRuntimeContext().registerServerRuntimeContextService(serviceCollector);
       
        MUCModule module = new MUCModule(SUBDOMAIN, conference);
        module.initialize(sessionContext.getServerRuntimeContext());
        sessionContext.getServerRuntimeContext().registerComponent(module);
       
        serviceCollector.addComponentInfoRequestListener(module);
        serviceCollector.addItemRequestListener(module);

    }
View Full Code Here

   
    @Override
    protected void setUp() throws Exception {
        super.setUp();
       
        serviceCollector = new ServiceCollector();
        serverRuntimeContext = new DefaultServerRuntimeContext(SERVER_JID, null);
        serverRuntimeContext.registerServerRuntimeContextService(serviceCollector);

       
    }
View Full Code Here

        return verifyInnerElementWorker(stanza, "query");
    }

    @Override
    protected Stanza handleGet(IQStanza stanza, ServerRuntimeContext serverRuntimeContext, SessionContext sessionContext) {
        ServiceCollector serviceCollector = null;

        // TODO if the target entity does not exist, return error/cancel/item-not-found
        // TODO more strictly, server can also return error/cancel/service-unavailable

        // retrieve the service collector
        try {
            serviceCollector = (ServiceCollector)serverRuntimeContext.getServerRuntimeContextService(ServiceDiscoveryRequestListenerRegistry.SERVICE_DISCOVERY_REQUEST_LISTENER_REGISTRY);
        } catch (Exception e) {
            logger.error("error retrieving ServiceCollector service {}", e);
            serviceCollector = null;
        }

        if (serviceCollector == null) {
            return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.INTERNAL_SERVER_ERROR, stanza,
                    StanzaErrorType.CANCEL,
                    "cannot retrieve IQ-get-info result from internal components",
                    getErrorLanguage(serverRuntimeContext, sessionContext), null);
        }

        // if "vysper.org" is the server entity, 'to' can either be "vysper.org", "node@vysper.org", "service.vysper.org".
        Entity to = stanza.getTo();
        boolean isServerInfoRequest = false;
        boolean isComponentInfoRequest = false;
        Entity serviceEntity = serverRuntimeContext.getServerEnitity();
        if (to == null || to.equals(serviceEntity)) {
            isServerInfoRequest = true; // this can only be meant to query the server
        } else if (serverRuntimeContext.getComponentStanzaProcessor(to.getDomain()) != null) {
            isComponentInfoRequest = true; // this is a query to a component
        } else if (!to.isNodeSet()) {
            isServerInfoRequest = serviceEntity.equals(to);
            if (!isServerInfoRequest) {
                return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.ITEM_NOT_FOUND, stanza,
                        StanzaErrorType.CANCEL,
                        "server does not handle info query requests for " + to.getFullQualifiedName(),
                        getErrorLanguage(serverRuntimeContext, sessionContext), null);
            }
        }

        XMLElement queryElement = stanza.getFirstInnerElement();
        String node = queryElement != null ? queryElement.getAttributeValue("node") : null;

        // collect all the info response elements
        List<InfoElement> elements = null;
        try {
            if (isServerInfoRequest) {
                elements = serviceCollector.processServerInfoRequest(new InfoRequest(stanza.getFrom(), to, node, stanza.getID()));
            } else if (isComponentInfoRequest) {
                elements = serviceCollector.processComponentInfoRequest(new InfoRequest(stanza.getFrom(), to, node, stanza.getID()));
            } else {
                elements = serviceCollector.processInfoRequest(new InfoRequest(stanza.getFrom(), to, node, stanza.getID()));
            }
        } catch (ServiceDiscoveryRequestException e) {
            // the request yields an error
            StanzaErrorCondition stanzaErrorCondition = e.getErrorCondition();
            if (stanzaErrorCondition == null) stanzaErrorCondition = StanzaErrorCondition.INTERNAL_SERVER_ERROR;
View Full Code Here

        return verifyInnerElementWorker(stanza, "query");
    }

    @Override
    protected Stanza handleGet(IQStanza stanza, ServerRuntimeContext serverRuntimeContext, SessionContext sessionContext) {
        ServiceCollector serviceCollector = null;

        // retrieve the service collector
        try {
            serviceCollector = (ServiceCollector)serverRuntimeContext.getServerRuntimeContextService(ServiceDiscoveryRequestListenerRegistry.SERVICE_DISCOVERY_REQUEST_LISTENER_REGISTRY);
        } catch (Exception e) {
            logger.error("error retrieving ServiceCollector service {}", e);
            serviceCollector = null;
        }

        if (serviceCollector == null) {
            return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.INTERNAL_SERVER_ERROR, stanza,
                    StanzaErrorType.CANCEL,
                    "cannot retrieve IQ-get-items result from internal components",
                    getErrorLanguage(serverRuntimeContext, sessionContext), null);
        }

        Entity to = stanza.getTo();
        boolean isServerInfoRequest = false;
        boolean isComponentInfoRequest = false;
        if (to == null) {
            isServerInfoRequest = true; // this can only be meant to query the server
        } else if (!to.isNodeSet()) {
            isServerInfoRequest = serverRuntimeContext.getServerEnitity().equals(to);
            isComponentInfoRequest = serverRuntimeContext.getComponentStanzaProcessor(to.getDomain()) != null;
            if (!isServerInfoRequest && !isComponentInfoRequest) {
                return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.ITEM_NOT_FOUND, stanza,
                        StanzaErrorType.CANCEL,
                        "server does not handle items query requests for " + to.getFullQualifiedName(),
                        getErrorLanguage(serverRuntimeContext, sessionContext), null);
            }
        }

        XMLElement queryElement = stanza.getFirstInnerElement();
        String node = queryElement != null ? queryElement.getAttributeValue("node") : null;

        // collect all the item response elements
        List<Item> items = null;
        try {
            items = serviceCollector.processItemRequest(new InfoRequest(stanza.getFrom(), stanza.getTo(), node, stanza.getID()));
        } catch (ServiceDiscoveryRequestException e) {
            // the request yields an error
            StanzaErrorCondition stanzaErrorCondition = e.getErrorCondition();
            if (stanzaErrorCondition == null) stanzaErrorCondition = StanzaErrorCondition.INTERNAL_SERVER_ERROR;
            return ServerErrorResponses.getInstance().getStanzaError(stanzaErrorCondition, stanza,
View Full Code Here

        dictionary.add(new ServiceDiscoveryItemDictionary());
    }

    @Override
    protected void addServerServices(List<ServerRuntimeContextService> serviceList) {
        serviceList.add(new ServiceCollector());
    }
View Full Code Here

   
    public void testExtendedInfo() throws EntityFormatException {

        // test if the data form is correctly added to the disco info response
       
        ServiceCollector serviceCollector = new ServiceCollector();
        serviceCollector.addInfoRequestListener(new InfoRequestListener() {
            public List<InfoElement> getInfosFor(InfoRequest request) throws ServiceDiscoveryRequestException {

                DataForm form = new DataForm();
                form.setTitle("formtitle");
                form.setType(DataForm.Type.form);
View Full Code Here

        return verifyInnerElementWorker(stanza, "query");
    }

    @Override
    protected Stanza handleGet(IQStanza stanza, ServerRuntimeContext serverRuntimeContext, SessionContext sessionContext) {
        ServiceCollector serviceCollector = null;

        // TODO if the target entity does not exist, return error/cancel/item-not-found
        // TODO more strictly, server can also return error/cancel/service-unavailable

        // retrieve the service collector
        try {
            serviceCollector = (ServiceCollector) serverRuntimeContext
                    .getServerRuntimeContextService(ServiceDiscoveryRequestListenerRegistry.SERVICE_DISCOVERY_REQUEST_LISTENER_REGISTRY);
        } catch (Exception e) {
            logger.error("error retrieving ServiceCollector service {}", e);
            serviceCollector = null;
        }

        if (serviceCollector == null) {
            return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.INTERNAL_SERVER_ERROR,
                    stanza, StanzaErrorType.CANCEL, "cannot retrieve IQ-get-info result from internal components",
                    getErrorLanguage(serverRuntimeContext, sessionContext), null);
        }

        // if "vysper.org" is the server entity, 'to' can either be "vysper.org", "node@vysper.org", "service.vysper.org".
        Entity to = stanza.getTo();
        boolean isServerInfoRequest = false;
        boolean isComponentInfoRequest = false;
        Entity serviceEntity = serverRuntimeContext.getServerEnitity();
        if (to == null || to.equals(serviceEntity)) {
            isServerInfoRequest = true; // this can only be meant to query the server
        } else if (serverRuntimeContext.getComponentStanzaProcessor(to) != null) {
            isComponentInfoRequest = true; // this is a query to a component
        } else if (!to.isNodeSet()) {
            isServerInfoRequest = serviceEntity.equals(to);
            if (!isServerInfoRequest) {
                return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.ITEM_NOT_FOUND, stanza,
                        StanzaErrorType.CANCEL,
                        "server does not handle info query requests for " + to.getFullQualifiedName(),
                        getErrorLanguage(serverRuntimeContext, sessionContext), null);
            }
        }

        XMLElement queryElement = stanza.getFirstInnerElement();
        String node = queryElement != null ? queryElement.getAttributeValue("node") : null;

        // collect all the info response elements
        List<InfoElement> elements = null;
        try {
            if (isServerInfoRequest) {
                elements = serviceCollector.processServerInfoRequest(new InfoRequest(stanza.getFrom(), to, node, stanza
                        .getID()));
            } else if (isComponentInfoRequest) {
                elements = serviceCollector.processComponentInfoRequest(new InfoRequest(stanza.getFrom(), to, node,
                        stanza.getID()));
            } else {
                elements = serviceCollector.processInfoRequest(new InfoRequest(stanza.getFrom(), to, node, stanza
                        .getID()));
            }
        } catch (ServiceDiscoveryRequestException e) {
            // the request yields an error
            StanzaErrorCondition stanzaErrorCondition = e.getErrorCondition();
View Full Code Here

        return verifyInnerElementWorker(stanza, "query");
    }

    @Override
    protected Stanza handleGet(IQStanza stanza, ServerRuntimeContext serverRuntimeContext, SessionContext sessionContext) {
        ServiceCollector serviceCollector = null;

        // retrieve the service collector
        try {
            serviceCollector = (ServiceCollector) serverRuntimeContext
                    .getServerRuntimeContextService(ServiceDiscoveryRequestListenerRegistry.SERVICE_DISCOVERY_REQUEST_LISTENER_REGISTRY);
        } catch (Exception e) {
            logger.error("error retrieving ServiceCollector service {}", e);
            serviceCollector = null;
        }

        if (serviceCollector == null) {
            return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.INTERNAL_SERVER_ERROR,
                    stanza, StanzaErrorType.CANCEL, "cannot retrieve IQ-get-items result from internal components",
                    getErrorLanguage(serverRuntimeContext, sessionContext), null);
        }

        Entity to = stanza.getTo();
        boolean isServerInfoRequest = false;
        boolean isComponentInfoRequest = false;
        if (to == null) {
            isServerInfoRequest = true; // this can only be meant to query the server
        } else if (!to.isNodeSet()) {
            isServerInfoRequest = serverRuntimeContext.getServerEnitity().equals(to);
            isComponentInfoRequest = serverRuntimeContext.getComponentStanzaProcessor(to) != null;
            if (!isServerInfoRequest && !isComponentInfoRequest) {
                return ServerErrorResponses.getInstance().getStanzaError(StanzaErrorCondition.ITEM_NOT_FOUND, stanza,
                        StanzaErrorType.CANCEL,
                        "server does not handle items query requests for " + to.getFullQualifiedName(),
                        getErrorLanguage(serverRuntimeContext, sessionContext), null);
            }
        }

        XMLElement queryElement = stanza.getFirstInnerElement();
        String node = queryElement != null ? queryElement.getAttributeValue("node") : null;

        // collect all the item response elements
        List<Item> items = null;
        try {
            items = serviceCollector.processItemRequest(new InfoRequest(stanza.getFrom(), stanza.getTo(), node, stanza
                    .getID()));
        } catch (ServiceDiscoveryRequestException e) {
            // the request yields an error
            StanzaErrorCondition stanzaErrorCondition = e.getErrorCondition();
            if (stanzaErrorCondition == null)
View Full Code Here

    public void testExtendedInfo() throws EntityFormatException {

        // test if the data form is correctly added to the disco info response

        ServiceCollector serviceCollector = new ServiceCollector();
        serviceCollector.addInfoRequestListener(new InfoRequestListener() {
            public List<InfoElement> getInfosFor(InfoRequest request) throws ServiceDiscoveryRequestException {

                DataForm form = new DataForm();
                form.setTitle("formtitle");
                form.setType(DataForm.Type.form);
View Full Code Here

TOP

Related Classes of org.apache.vysper.xmpp.modules.servicediscovery.collection.ServiceCollector

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.