Search in sources :

Example 86 with IAttribute

use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.

the class XMLCallHandler method startElement.

public void startElement(String uri, String name, String qname, Attributes attributes) throws SAXException {
    if (this.m_multi && qname.equalsIgnoreCase(TAG_CALLLIST)) {
        this.m_calllist = this.getRuntime().getCallFactory().createCallList();
    }
    if (qname.equalsIgnoreCase(TAG_CALL)) {
        this.m_call = this.getRuntime().getCallFactory().createCall(null, this.getRuntime().getCallFactory().createMsn("", ""), this.getRuntime().getCallFactory().createCip("", ""));
    }
    if (qname.equalsIgnoreCase(TAG_CALLER)) {
        this.m_iscaller = true;
    }
    if (this.m_iscaller) {
        super.startElement(uri, name, qname, attributes);
        return;
    }
    if (qname.equalsIgnoreCase(TAG_UUID)) {
        this.m_call.setUUID(attributes.getValue(ATTRIBUTE_VALUE));
    }
    if (qname.equalsIgnoreCase(TAG_DATE)) {
        this.m_call.setDate(new Date(Long.parseLong(attributes.getValue(ATTRIBUTE_VALUE))));
    }
    if (qname.equalsIgnoreCase(TAG_CIP)) {
        ICip cip = this.m_call.getCIP();
        cip.setCIP(attributes.getValue(ATTRIBUTE_VALUE));
        cip.setAdditional(this.getRuntime().getCipManager().getCipLabel(cip, this.getLanguage()));
        this.m_call.setCIP(cip);
    }
    if (qname.equalsIgnoreCase(TAG_MSN)) {
        IMsn msn = this.m_call.getMSN();
        msn.setMSN(attributes.getValue(ATTRIBUTE_VALUE));
        msn.setAdditional(decode(attributes.getValue(ATTRIBUTE_ADDITIONAL)));
        this.m_call.setMSN(msn);
    }
    if (qname.equalsIgnoreCase(TAG_ATTRIBUTE)) {
        IAttribute att = this.getRuntime().getCallerFactory().createAttribute(attributes.getValue(ATTRIBUTE_NAME), decode(attributes.getValue(ATTRIBUTE_VALUE)));
        this.m_call.setAttribute(att);
    }
}
Also used : ICip(de.janrufmonitor.framework.ICip) IAttribute(de.janrufmonitor.framework.IAttribute) IMsn(de.janrufmonitor.framework.IMsn) Date(java.util.Date)

Example 87 with IAttribute

use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.

the class XMLSerializer method toXML.

private static synchronized String toXML(IAttributeMap l) {
    StringBuffer c = new StringBuffer();
    c.append("<attributes>");
    Iterator i = l.iterator();
    IAttribute a = null;
    while (i.hasNext()) {
        a = ((IAttribute) i.next());
        c.append("<attribute name=\"" + encode(a.getName()) + "\" value=\"" + encode(a.getValue()) + "\" />");
    }
    c.append("</attributes>");
    return c.toString();
}
Also used : Iterator(java.util.Iterator) IAttribute(de.janrufmonitor.framework.IAttribute)

Example 88 with IAttribute

use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.

the class XMLCallerHandler method startElement.

public void startElement(String uri, String name, String qname, Attributes attributes) throws SAXException {
    if (this.m_multi && qname.equalsIgnoreCase(TAG_CALLERLIST)) {
        this.m_callerList = this.getRuntime().getCallerFactory().createCallerList();
    }
    if (qname.equalsIgnoreCase(TAG_CALLER)) {
        List phns = new ArrayList();
        this.m_caller = this.getRuntime().getCallerFactory().createCaller(this.getRuntime().getCallerFactory().createName("", ""), phns);
        this.m_caller.getPhonenumbers().clear();
    }
    if (qname.equalsIgnoreCase(TAG_UUID)) {
        this.m_caller.setUUID(attributes.getValue(ATTRIBUTE_VALUE));
    }
    if (qname.equalsIgnoreCase(TAG_IMAGE_CONTENT)) {
        this.m_image_content = attributes.getValue(ATTRIBUTE_VALUE);
    }
    if (qname.equalsIgnoreCase(TAG_FIRSTNAME)) {
        IName cname = this.m_caller.getName();
        cname.setFirstname(decode(attributes.getValue(ATTRIBUTE_VALUE)));
        this.m_caller.setName(cname);
    }
    if (qname.equalsIgnoreCase(TAG_LASTNAME)) {
        IName cname = this.m_caller.getName();
        cname.setLastname(decode(attributes.getValue(ATTRIBUTE_VALUE)));
        this.m_caller.setName(cname);
    }
    if (qname.equalsIgnoreCase(TAG_ADDITIONAL)) {
        IName cname = this.m_caller.getName();
        cname.setAdditional(decode(attributes.getValue(ATTRIBUTE_VALUE)));
        this.m_caller.setName(cname);
    }
    if (qname.equalsIgnoreCase(TAG_PHONENUMBER)) {
        List pns = new ArrayList(this.m_caller.getPhonenumbers());
        String iarea = attributes.getValue(TAG_INTAREA);
        String area = attributes.getValue(TAG_AREA);
        String cn = attributes.getValue(TAG_CALLNUMBER);
        String tn = attributes.getValue(TAG_TELEPHONENUMBER);
        if (iarea != null && iarea.length() > 0 && area != null && cn != null && cn.length() > 0) {
            IPhonenumber n = getRuntime().getCallerFactory().createPhonenumber(iarea, area, cn);
            n.setTelephoneNumber(tn);
            if (pns.size() == 0) {
                this.m_caller.setPhoneNumber(n);
            } else {
                pns.add(n);
                this.m_caller.setPhonenumbers(pns);
            }
        }
    }
    if (qname.equalsIgnoreCase(TAG_INTAREA)) {
        IPhonenumber pn = this.m_caller.getPhoneNumber();
        pn.setIntAreaCode(attributes.getValue(ATTRIBUTE_VALUE));
        this.m_caller.setPhoneNumber(pn);
    }
    if (qname.equalsIgnoreCase(TAG_AREA)) {
        IPhonenumber pn = this.m_caller.getPhoneNumber();
        pn.setAreaCode(attributes.getValue(ATTRIBUTE_VALUE));
        this.m_caller.setPhoneNumber(pn);
    }
    if (qname.equalsIgnoreCase(TAG_CALLNUMBER)) {
        IPhonenumber pn = this.m_caller.getPhoneNumber();
        pn.setCallNumber(attributes.getValue(ATTRIBUTE_VALUE));
        this.m_caller.setPhoneNumber(pn);
    }
    if (qname.equalsIgnoreCase(TAG_TELEPHONENUMBER)) {
        IPhonenumber pn = this.m_caller.getPhoneNumber();
        pn.setTelephoneNumber(attributes.getValue(ATTRIBUTE_VALUE));
        this.m_caller.setPhoneNumber(pn);
    }
    if (qname.equalsIgnoreCase(TAG_ATTRIBUTE)) {
        IAttribute att = this.getRuntime().getCallerFactory().createAttribute(attributes.getValue(ATTRIBUTE_NAME), decode(attributes.getValue(ATTRIBUTE_VALUE)));
        this.m_caller.setAttribute(att);
    }
}
Also used : ArrayList(java.util.ArrayList) IAttribute(de.janrufmonitor.framework.IAttribute) ArrayList(java.util.ArrayList) ICallerList(de.janrufmonitor.framework.ICallerList) List(java.util.List) IName(de.janrufmonitor.framework.IName) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 89 with IAttribute

use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.

the class LdapRepository method getCallers.

public ICallerList getCallers(IFilter filter) {
    try {
        if (filter != null && filter.getType().equals(FilterType.ATTRIBUTE)) {
            IAttributeMap m = ((AttributeFilter) filter).getAttributeMap();
            if (m.contains(IJAMConst.ATTRIBUTE_NAME_CATEGORY)) {
                IAttribute a = m.get(IJAMConst.ATTRIBUTE_NAME_CATEGORY);
                return getProxy().getContacts(a.getValue());
            }
        }
        if (filter != null && filter.getType().equals(FilterType.PHONENUMBER)) {
            ICallerList cl = getProxy().getContacts(null);
            this.applyFilters(cl, new IFilter[] { filter });
            return cl;
        }
        if (filter != null && filter.getType().equals(FilterType.CHARACTER)) {
            ICallerList cl = getProxy().getContacts(null);
            this.applyFilters(cl, new IFilter[] { filter });
            return cl;
        }
        return getProxy().getContacts(null);
    } catch (LdapContactsException e) {
        this.m_logger.log(Level.SEVERE, e.getMessage(), e);
        PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "loginerror", e));
    }
    return getRuntime().getCallerFactory().createCallerList();
}
Also used : ICallerList(de.janrufmonitor.framework.ICallerList) Message(de.janrufmonitor.exception.Message) AttributeFilter(de.janrufmonitor.repository.filter.AttributeFilter) IAttribute(de.janrufmonitor.framework.IAttribute) IAttributeMap(de.janrufmonitor.framework.IAttributeMap)

Example 90 with IAttribute

use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.

the class MacAddressBookMappingManager method setPictureAttribute.

private void setPictureAttribute(ICaller macCaller, Map contact) {
    if (contact.containsKey(IMacAddressBookConst.HAS_PICTURE)) {
        long pic = ((Long) contact.get(IMacAddressBookConst.HAS_PICTURE)).longValue();
        if (pic == 1) {
            // picture is assigned
            byte[] imgdata = MacAddressBookProxy.getInstance().getUserImage((String) contact.get(IMacAddressBookConst.UID));
            if (imgdata != null) {
                String imagepath = MSO_IMAGE_CACHE_PATH + macCaller.getUUID() + ".jpg";
                File f = new File(imagepath);
                f.getParentFile().mkdirs();
                try {
                    FileOutputStream fos = new FileOutputStream(f);
                    ByteArrayInputStream bin = new ByteArrayInputStream(imgdata);
                    Stream.copy(bin, fos, true);
                    IAttribute img = getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_IMAGEPATH, PathResolver.getInstance().encode(imagepath));
                    macCaller.setAttribute(img);
                    return;
                } catch (FileNotFoundException e) {
                    this.m_logger.log(Level.WARNING, e.toString(), e);
                } catch (IOException e) {
                    this.m_logger.log(Level.WARNING, e.toString(), e);
                }
            }
        }
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) FileOutputStream(java.io.FileOutputStream) IAttribute(de.janrufmonitor.framework.IAttribute) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) File(java.io.File)

Aggregations

IAttribute (de.janrufmonitor.framework.IAttribute)111 ICaller (de.janrufmonitor.framework.ICaller)44 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)40 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)39 List (java.util.List)34 ICallerList (de.janrufmonitor.framework.ICallerList)31 ArrayList (java.util.ArrayList)29 Iterator (java.util.Iterator)25 ICall (de.janrufmonitor.framework.ICall)19 IMultiPhoneCaller (de.janrufmonitor.framework.IMultiPhoneCaller)15 SQLException (java.sql.SQLException)15 File (java.io.File)14 AttributeFilter (de.janrufmonitor.repository.filter.AttributeFilter)12 IOException (java.io.IOException)12 Message (de.janrufmonitor.exception.Message)11 ComFailException (com.jacob.com.ComFailException)10 Date (java.util.Date)10 IMsn (de.janrufmonitor.framework.IMsn)9 Dispatch (com.jacob.com.Dispatch)8 UUID (de.janrufmonitor.util.uuid.UUID)8