Search in sources :

Example 1 with Modulestype

use of de.vitero.schema.licence.Modulestype in project openolat by klemens.

the class ViteroManager method getLicencedRoomSizes.

public List<Integer> getLicencedRoomSizes() throws VmsNotAvailableException {
    List<Integer> roomSizes = new ArrayList<Integer>();
    try {
        GetModulesForCustomerRequest licenceRequest = new GetModulesForCustomerRequest();
        licenceRequest.setCustomerid(viteroModule.getCustomerId());
        Modulestype modules = getLicenceWebService().getModulesForCustomer(licenceRequest);
        Modules modulesType = modules.getModules();
        for (Module module : modulesType.getModule()) {
            if ("ROOM".equals(module.getType())) {
                Integer roomSize = module.getRoomsize();
                if (!roomSizes.contains(roomSize)) {
                    roomSizes.add(roomSize);
                }
            }
        }
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            case invalidAttribut:
                log.error("ids <=0 or invalid attributs", f);
                break;
            default:
                logAxisError("Cannot get licence for customer: " + viteroModule.getCustomerId(), f);
        }
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot get licence for customer: " + viteroModule.getCustomerId(), e);
    }
    return roomSizes;
}
Also used : BigInteger(java.math.BigInteger) WebServiceException(javax.xml.ws.WebServiceException) GetModulesForCustomerRequest(de.vitero.schema.licence.GetModulesForCustomerRequest) Modules(de.vitero.schema.licence.Modulestype.Modules) ArrayList(java.util.ArrayList) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ErrorCode(org.olat.modules.vitero.model.ErrorCode) ViteroModule(org.olat.modules.vitero.ViteroModule) Module(de.vitero.schema.licence.Modulestype.Modules.Module) Modulestype(de.vitero.schema.licence.Modulestype) ConnectException(java.net.ConnectException)

Example 2 with Modulestype

use of de.vitero.schema.licence.Modulestype in project openolat by klemens.

the class ViteroManager method checkConnection.

public boolean checkConnection(final String url, final String login, final String password, final int customerId) throws VmsNotAvailableException {
    try {
        LicenceService ss = new LicenceService();
        ss.setHandlerResolver(new HandlerResolver() {

            @SuppressWarnings("rawtypes")
            @Override
            public List<Handler> getHandlerChain(PortInfo portInfo) {
                List<Handler> handlerList = new ArrayList<Handler>();
                handlerList.add(new ViteroSecurityHandler(login, password));
                return handlerList;
            }
        });
        Licence port = ss.getLicenceSoap11();
        String endPoint = UriBuilder.fromUri(url).path("services").path("LicenseService").build().toString();
        ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endPoint);
        GetModulesForCustomerRequest request = new GetModulesForCustomerRequest();
        request.setCustomerid(customerId);
        Modulestype modulesType = port.getModulesForCustomer(request);
        return modulesType != null;
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            case unsufficientRights:
                log.error("Unsufficient rights", f);
                break;
            default:
                logAxisError("Cannot check connection", f);
        }
        return false;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.warn("Error checking connection", e);
        return false;
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) Handler(javax.xml.ws.handler.Handler) ViteroSecurityHandler(de.vitero.ViteroSecurityHandler) DataHandler(javax.activation.DataHandler) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Modulestype(de.vitero.schema.licence.Modulestype) PortInfo(javax.xml.ws.handler.PortInfo) HandlerResolver(javax.xml.ws.handler.HandlerResolver) GetModulesForCustomerRequest(de.vitero.schema.licence.GetModulesForCustomerRequest) Licence(de.vitero.schema.licence.Licence) ArrayList(java.util.ArrayList) List(java.util.List) ErrorCode(org.olat.modules.vitero.model.ErrorCode) ViteroSecurityHandler(de.vitero.ViteroSecurityHandler) LicenceService(de.vitero.schema.licence.LicenceService) ConnectException(java.net.ConnectException)

Example 3 with Modulestype

use of de.vitero.schema.licence.Modulestype in project OpenOLAT by OpenOLAT.

the class ViteroManager method checkConnection.

public boolean checkConnection(final String url, final String login, final String password, final int customerId) throws VmsNotAvailableException {
    try {
        LicenceService ss = new LicenceService();
        ss.setHandlerResolver(new HandlerResolver() {

            @SuppressWarnings("rawtypes")
            @Override
            public List<Handler> getHandlerChain(PortInfo portInfo) {
                List<Handler> handlerList = new ArrayList<Handler>();
                handlerList.add(new ViteroSecurityHandler(login, password));
                return handlerList;
            }
        });
        Licence port = ss.getLicenceSoap11();
        String endPoint = UriBuilder.fromUri(url).path("services").path("LicenseService").build().toString();
        ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endPoint);
        GetModulesForCustomerRequest request = new GetModulesForCustomerRequest();
        request.setCustomerid(customerId);
        Modulestype modulesType = port.getModulesForCustomer(request);
        return modulesType != null;
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            case unsufficientRights:
                log.error("Unsufficient rights", f);
                break;
            default:
                logAxisError("Cannot check connection", f);
        }
        return false;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.warn("Error checking connection", e);
        return false;
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) Handler(javax.xml.ws.handler.Handler) ViteroSecurityHandler(de.vitero.ViteroSecurityHandler) DataHandler(javax.activation.DataHandler) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Modulestype(de.vitero.schema.licence.Modulestype) PortInfo(javax.xml.ws.handler.PortInfo) HandlerResolver(javax.xml.ws.handler.HandlerResolver) GetModulesForCustomerRequest(de.vitero.schema.licence.GetModulesForCustomerRequest) Licence(de.vitero.schema.licence.Licence) ArrayList(java.util.ArrayList) List(java.util.List) ErrorCode(org.olat.modules.vitero.model.ErrorCode) ViteroSecurityHandler(de.vitero.ViteroSecurityHandler) LicenceService(de.vitero.schema.licence.LicenceService) ConnectException(java.net.ConnectException)

Example 4 with Modulestype

use of de.vitero.schema.licence.Modulestype in project OpenOLAT by OpenOLAT.

the class ViteroManager method getLicencedRoomSizes.

public List<Integer> getLicencedRoomSizes() throws VmsNotAvailableException {
    List<Integer> roomSizes = new ArrayList<Integer>();
    try {
        GetModulesForCustomerRequest licenceRequest = new GetModulesForCustomerRequest();
        licenceRequest.setCustomerid(viteroModule.getCustomerId());
        Modulestype modules = getLicenceWebService().getModulesForCustomer(licenceRequest);
        Modules modulesType = modules.getModules();
        for (Module module : modulesType.getModule()) {
            if ("ROOM".equals(module.getType())) {
                Integer roomSize = module.getRoomsize();
                if (!roomSizes.contains(roomSize)) {
                    roomSizes.add(roomSize);
                }
            }
        }
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            case invalidAttribut:
                log.error("ids <=0 or invalid attributs", f);
                break;
            default:
                logAxisError("Cannot get licence for customer: " + viteroModule.getCustomerId(), f);
        }
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot get licence for customer: " + viteroModule.getCustomerId(), e);
    }
    return roomSizes;
}
Also used : BigInteger(java.math.BigInteger) WebServiceException(javax.xml.ws.WebServiceException) GetModulesForCustomerRequest(de.vitero.schema.licence.GetModulesForCustomerRequest) Modules(de.vitero.schema.licence.Modulestype.Modules) ArrayList(java.util.ArrayList) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ErrorCode(org.olat.modules.vitero.model.ErrorCode) ViteroModule(org.olat.modules.vitero.ViteroModule) Module(de.vitero.schema.licence.Modulestype.Modules.Module) Modulestype(de.vitero.schema.licence.Modulestype) ConnectException(java.net.ConnectException)

Aggregations

GetModulesForCustomerRequest (de.vitero.schema.licence.GetModulesForCustomerRequest)4 Modulestype (de.vitero.schema.licence.Modulestype)4 ConnectException (java.net.ConnectException)4 ArrayList (java.util.ArrayList)4 WebServiceException (javax.xml.ws.WebServiceException)4 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)4 ErrorCode (org.olat.modules.vitero.model.ErrorCode)4 ViteroSecurityHandler (de.vitero.ViteroSecurityHandler)2 Licence (de.vitero.schema.licence.Licence)2 LicenceService (de.vitero.schema.licence.LicenceService)2 Modules (de.vitero.schema.licence.Modulestype.Modules)2 Module (de.vitero.schema.licence.Modulestype.Modules.Module)2 BigInteger (java.math.BigInteger)2 List (java.util.List)2 DataHandler (javax.activation.DataHandler)2 Handler (javax.xml.ws.handler.Handler)2 HandlerResolver (javax.xml.ws.handler.HandlerResolver)2 PortInfo (javax.xml.ws.handler.PortInfo)2 ViteroModule (org.olat.modules.vitero.ViteroModule)2