Search in sources :

Example 1 with CompleteAvatarWrapper

use of de.vitero.schema.mtom.CompleteAvatarWrapper in project OpenOLAT by OpenOLAT.

the class ViteroManager method storePortrait.

protected boolean storePortrait(Identity identity, int userId) throws VmsNotAvailableException {
    try {
        File portrait = DisplayPortraitManager.getInstance().getBigPortrait(identity.getName());
        if (portrait != null && portrait.exists()) {
            Mtom mtomWs = getMtomWebService();
            CompleteAvatarWrapper avatar = new CompleteAvatarWrapper();
            avatar.setType(BigInteger.ZERO);
            avatar.setUserid(BigInteger.valueOf(userId));
            avatar.setFilename(portrait.getName());
            DataHandler portraitHandler = new DataHandler(new FileDataSource(portrait));
            avatar.setFile(portraitHandler);
            mtomWs.storeAvatar(avatar);
            return true;
        }
        return false;
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            default:
                logAxisError("Cannot store the portrait of " + userId, f);
        }
        return false;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot store the portrait of " + userId, e);
        return false;
    }
}
Also used : CompleteAvatarWrapper(de.vitero.schema.mtom.CompleteAvatarWrapper) Mtom(de.vitero.schema.mtom.Mtom) WebServiceException(javax.xml.ws.WebServiceException) FileDataSource(javax.activation.FileDataSource) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) DataHandler(javax.activation.DataHandler) ErrorCode(org.olat.modules.vitero.model.ErrorCode) File(java.io.File) ConnectException(java.net.ConnectException)

Example 2 with CompleteAvatarWrapper

use of de.vitero.schema.mtom.CompleteAvatarWrapper in project openolat by klemens.

the class ViteroManager method storePortrait.

protected boolean storePortrait(Identity identity, int userId) throws VmsNotAvailableException {
    try {
        File portrait = DisplayPortraitManager.getInstance().getBigPortrait(identity.getName());
        if (portrait != null && portrait.exists()) {
            Mtom mtomWs = getMtomWebService();
            CompleteAvatarWrapper avatar = new CompleteAvatarWrapper();
            avatar.setType(BigInteger.ZERO);
            avatar.setUserid(BigInteger.valueOf(userId));
            avatar.setFilename(portrait.getName());
            DataHandler portraitHandler = new DataHandler(new FileDataSource(portrait));
            avatar.setFile(portraitHandler);
            mtomWs.storeAvatar(avatar);
            return true;
        }
        return false;
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch(code) {
            default:
                logAxisError("Cannot store the portrait of " + userId, f);
        }
        return false;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.error("Cannot store the portrait of " + userId, e);
        return false;
    }
}
Also used : CompleteAvatarWrapper(de.vitero.schema.mtom.CompleteAvatarWrapper) Mtom(de.vitero.schema.mtom.Mtom) WebServiceException(javax.xml.ws.WebServiceException) FileDataSource(javax.activation.FileDataSource) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) DataHandler(javax.activation.DataHandler) ErrorCode(org.olat.modules.vitero.model.ErrorCode) File(java.io.File) ConnectException(java.net.ConnectException)

Aggregations

CompleteAvatarWrapper (de.vitero.schema.mtom.CompleteAvatarWrapper)2 Mtom (de.vitero.schema.mtom.Mtom)2 File (java.io.File)2 ConnectException (java.net.ConnectException)2 DataHandler (javax.activation.DataHandler)2 FileDataSource (javax.activation.FileDataSource)2 WebServiceException (javax.xml.ws.WebServiceException)2 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)2 ErrorCode (org.olat.modules.vitero.model.ErrorCode)2