Search in sources :

Example 6 with IName

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

the class PIMCapiData method createCallObject.

private ICall createCallObject(String number, String msn, int cip) {
    IPhonenumber phone = PhonenumberAnalyzer.getInstance(getRuntime()).toClirPhonenumber(number);
    if (phone == null)
        phone = PhonenumberAnalyzer.getInstance(getRuntime()).toInternalPhonenumber(number, msn);
    if (phone == null)
        phone = PhonenumberAnalyzer.getInstance(getRuntime()).toPhonenumber("0" + number, msn);
    IName name = this.getRuntime().getCallerFactory().createName("", "");
    ICaller aCaller = this.getRuntime().getCallerFactory().createCaller(name, phone);
    ICip cipObj = this.getRuntime().getCallFactory().createCip(Integer.toString(cip), "");
    IMsn msnObj = this.getRuntime().getCallFactory().createMsn(msn, "");
    ICall c = this.getRuntime().getCallFactory().createCall(aCaller, msnObj, cipObj);
    c.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_BCHANNEL, this.m_plci.toString()));
    c.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_RAW_NUMBER, number));
    c.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_MISSED));
    return c;
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) ICip(de.janrufmonitor.framework.ICip) ICall(de.janrufmonitor.framework.ICall) IName(de.janrufmonitor.framework.IName) IMsn(de.janrufmonitor.framework.IMsn) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 7 with IName

use of de.janrufmonitor.framework.IName 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)) {
        this.m_caller = this.getRuntime().getCallerFactory().createCaller(this.getRuntime().getCallerFactory().createName("", ""), this.getRuntime().getCallerFactory().createPhonenumber(false));
    }
    if (qname.equalsIgnoreCase(TAG_UUID)) {
        this.m_caller.setUUID(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_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 : IAttribute(de.janrufmonitor.framework.IAttribute) IName(de.janrufmonitor.framework.IName) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 8 with IName

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

the class OutgoingCall method handleWithException.

public void handleWithException(IHttpRequest req, IMutableHttpResponse resp) throws HandlerException {
    IPhonenumber pn = null;
    try {
        String phone = req.getParameter(OutgoingCall.PARAMETER_NUMBER);
        if (phone == null || phone.length() == 0)
            pn = PIMRuntime.getInstance().getCallerFactory().createPhonenumber(true);
        else
            pn = PIMRuntime.getInstance().getCallerFactory().createPhonenumber(phone);
        IName name = PIMRuntime.getInstance().getCallerFactory().createName("", "");
        ICaller c = PIMRuntime.getInstance().getCallerFactory().createCaller(name, pn);
        ICip cip = PIMRuntime.getInstance().getCallFactory().createCip(req.getParameter(OutgoingCall.PARAMETER_CIP), "");
        IMsn msn = PIMRuntime.getInstance().getCallFactory().createMsn(req.getParameter(OutgoingCall.PARAMETER_MSN), "");
        Date date = new Date(Long.parseLong(req.getParameter(OutgoingCall.PARAMETER_DATE)));
        ICall call = PIMRuntime.getInstance().getCallFactory().createCall(c, msn, cip, date);
        call.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_STARTRING, Long.toString(new Date().getTime())));
        call.setAttribute(this.getRuntime().getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_OUTGOING));
        ClientCallMap.getInstance().setCall((pn.isClired() ? IJAMConst.CLIRED_CALL : pn.getTelephoneNumber()) + "/" + msn.getMSN(), call);
        Thread sender = new Thread(new HandlerThread(call, this));
        sender.start();
        resp.getContentStreamForWrite().close();
    } catch (Exception e) {
        throw new HandlerException(e.getMessage(), 500);
    }
}
Also used : ICaller(de.janrufmonitor.framework.ICaller) HandlerException(de.janrufmonitor.service.commons.http.handler.HandlerException) ICip(de.janrufmonitor.framework.ICip) ICall(de.janrufmonitor.framework.ICall) IName(de.janrufmonitor.framework.IName) IMsn(de.janrufmonitor.framework.IMsn) Date(java.util.Date) HandlerException(de.janrufmonitor.service.commons.http.handler.HandlerException) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Example 9 with IName

use of de.janrufmonitor.framework.IName 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 10 with IName

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

the class VcfParser30 method parse.

public ICallerList parse() throws VcfParserException {
    if (this.m_buffer == null)
        this.read();
    if (this.m_buffer.length() < 64)
        throw new VcfParserException("VCF file contains only " + this.m_buffer.length() + " characters.");
    ICallerList cl = PIMRuntime.getInstance().getCallerFactory().createCallerList();
    String[] entries = this.m_buffer.toString().split(BEGIN_VCARD);
    this.m_logger.info("Entries in generic VcfParser vcf file: " + entries.length);
    this.m_total = entries.length;
    for (int i = 0; i < entries.length; i++) {
        try {
            this.m_current++;
            IAttributeMap private_attributes = PIMRuntime.getInstance().getCallerFactory().createAttributeMap();
            IAttributeMap bussiness_attributes = PIMRuntime.getInstance().getCallerFactory().createAttributeMap();
            List private_phones = new ArrayList();
            List bussiness_phones = new ArrayList();
            String[] lines = entries[i].split(IJAMConst.CRLF);
            // parse single entry
            String line = null;
            String[] value = null;
            for (int j = 0; j < lines.length; j++) {
                line = lines[j];
                // check name
                if (line.toLowerCase().startsWith(N) || line.toLowerCase().startsWith(N2)) {
                    value = line.substring(line.indexOf(":") + 1).split(";");
                    if (value.length >= 2) {
                        this.m_logger.info("Set attribute name.");
                        private_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_LASTNAME, value[0]));
                        bussiness_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_LASTNAME, value[0]));
                        private_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_FIRSTNAME, value[1]));
                        bussiness_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_FIRSTNAME, value[1]));
                    }
                    if (value.length == 1) {
                        private_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_LASTNAME, value[0]));
                        bussiness_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_LASTNAME, value[0]));
                    }
                }
                if (line.toLowerCase().startsWith(ORG) || line.toLowerCase().startsWith(ORG2)) {
                    value = line.split(":");
                    if (value.length >= 2) {
                        this.m_logger.info("Set attribute organization.");
                        private_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_ADDITIONAL, value[1]));
                        bussiness_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_ADDITIONAL, value[1]));
                    }
                }
                if (line.toLowerCase().startsWith(ADR)) {
                    String[] tokens = line.split(":");
                    if (tokens.length == 2) {
                        boolean isBusiness = false;
                        String[] attributes = tokens[0].split(";");
                        for (int k = 0; k < attributes.length; k++) {
                            if (attributes[k].toLowerCase().startsWith(ATTRIBUTE_TYPE)) {
                                String[] values = attributes[k].toLowerCase().substring(ATTRIBUTE_TYPE.length()).split(";");
                                for (int l = 0; l < values.length; l++) {
                                    if (values[l].equalsIgnoreCase(ADR_TYPES[1])) {
                                        isBusiness = true;
                                    }
                                }
                            }
                            if (attributes[k].toLowerCase().startsWith(ADR_TYPES[1])) {
                                isBusiness = true;
                            }
                        }
                        value = tokens[1].split(";");
                        if (value.length >= 6 && (value.length > 6 ? value[6].trim().length() > 0 : true) && value[3].trim().length() > 0) {
                            if (isBusiness) {
                                this.m_logger.info("Set attribute work address.");
                                bussiness_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_STREET, value[2]));
                                bussiness_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_POSTAL_CODE, value[5]));
                                bussiness_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CITY, value[3] + (value[4].trim().length() > 0 ? ", " + value[4] : "")));
                                bussiness_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_COUNTRY, (value.length > 6 ? value[6] : "")));
                            } else {
                                this.m_logger.info("Set attribute home address.");
                                private_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_STREET, value[2]));
                                private_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_POSTAL_CODE, value[5]));
                                private_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CITY, value[3] + (value[4].trim().length() > 0 ? ", " + value[4] : "")));
                                private_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_COUNTRY, (value.length > 6 ? value[6] : "")));
                            }
                        }
                    }
                }
                if (line.toLowerCase().startsWith(TEL)) {
                    value = line.split(":");
                    if (value.length == 2 && value[1].trim().length() > 0) {
                        boolean isBusiness = false;
                        boolean isFax = false;
                        boolean isCell = false;
                        String[] attributes = value[0].split(";");
                        for (int k = 0; k < attributes.length; k++) {
                            if (attributes[k].toLowerCase().startsWith(ATTRIBUTE_TYPE)) {
                                String[] values = attributes[k].toLowerCase().substring(ATTRIBUTE_TYPE.length()).split(",");
                                for (int l = 0; l < values.length; l++) {
                                    if (values[l].equalsIgnoreCase(TEL_TYPES[1])) {
                                        isBusiness = true;
                                    }
                                    if (values[l].equalsIgnoreCase(TEL_TYPES[3])) {
                                        isFax = true;
                                    }
                                    if (values[l].equalsIgnoreCase(TEL_TYPES[2])) {
                                        isCell = true;
                                    }
                                }
                            }
                            if (attributes[k].toLowerCase().startsWith(TEL_TYPES[1])) {
                                isBusiness = true;
                            }
                            if (attributes[k].toLowerCase().startsWith(TEL_TYPES[3])) {
                                isFax = true;
                            }
                            if (attributes[k].toLowerCase().startsWith(TEL_TYPES[2])) {
                                isCell = true;
                            }
                        }
                        try {
                            IPhonenumber pn = parsePhonenumber(value[1]);
                            if (pn != null && !bussiness_phones.contains(pn)) {
                                if (isBusiness) {
                                    this.m_logger.info("Set attribute work");
                                    bussiness_phones.add(pn);
                                    bussiness_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_NUMBER_TYPE + pn.getTelephoneNumber(), (isFax ? IJAMConst.ATTRIBUTE_VALUE_FAX_TYPE : (isCell ? IJAMConst.ATTRIBUTE_VALUE_MOBILE_TYPE : IJAMConst.ATTRIBUTE_VALUE_LANDLINE_TYPE))));
                                } else {
                                    this.m_logger.info("Set attribute home");
                                    private_phones.add(pn);
                                    private_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_NUMBER_TYPE + pn.getTelephoneNumber(), (isFax ? IJAMConst.ATTRIBUTE_VALUE_FAX_TYPE : (isCell ? IJAMConst.ATTRIBUTE_VALUE_MOBILE_TYPE : IJAMConst.ATTRIBUTE_VALUE_LANDLINE_TYPE))));
                                }
                            }
                        } catch (Exception ex) {
                            this.m_logger.log(Level.SEVERE, ex.getMessage(), ex);
                        }
                    }
                }
                if (line.toLowerCase().startsWith(EMAIL)) {
                    value = line.split(":");
                    if (value.length == 2 && value[1].trim().length() > 0) {
                        boolean isBusiness = false;
                        String[] attributes = value[0].split(";");
                        for (int k = 0; k < attributes.length; k++) {
                            if (attributes[k].toLowerCase().startsWith(ATTRIBUTE_TYPE)) {
                                String[] values = attributes[k].toLowerCase().substring(ATTRIBUTE_TYPE.length()).split(",");
                                for (int l = 0; l < values.length; l++) {
                                    if (values[l].equalsIgnoreCase(EMAIL_TYPES[1])) {
                                        isBusiness = true;
                                    }
                                }
                            }
                            if (attributes[k].toLowerCase().startsWith(EMAIL_TYPES[1])) {
                                isBusiness = true;
                            }
                        }
                        if (isBusiness) {
                            this.m_logger.info("Set attribute work");
                            bussiness_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_EMAIL, value[1]));
                        } else {
                            this.m_logger.info("Set attribute home");
                            private_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_EMAIL, value[1]));
                        }
                    }
                }
                if (line.toLowerCase().startsWith(GEO)) {
                    value = line.split(":");
                    if (value.length == 2) {
                        value = value[1].split(";");
                        if (value.length == 2) {
                            bussiness_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_LAT, value[0]));
                            bussiness_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_LNG, value[1]));
                            private_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_LAT, value[0]));
                            private_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_LNG, value[1]));
                        }
                    }
                }
                if (line.toLowerCase().startsWith(PHOTO) || line.toLowerCase().startsWith(MS_CARDPICTURE)) {
                    value = new String[2];
                    value[0] = line.substring(0, line.indexOf(":"));
                    value[1] = line.substring(line.indexOf(":") + 1);
                    if (value.length == 2) {
                        boolean isUrl = false;
                        boolean isEncoding = false;
                        String img_type = null;
                        String[] attributes = value[0].split(";");
                        for (int k = 0; k < attributes.length; k++) {
                            if (attributes[k].toLowerCase().startsWith(PHOTO_TYPES[0]) || attributes[k].toLowerCase().startsWith(PHOTO_TYPES[1])) {
                                isUrl = true;
                            }
                            if (attributes[k].toLowerCase().startsWith(PHOTO_TYPES[2])) {
                                isEncoding = true;
                            }
                            if (attributes[k].toLowerCase().startsWith(PHOTO_TYPES[3])) {
                                img_type = attributes[k].split("=")[1].toLowerCase();
                            }
                        }
                        if (isUrl) {
                            String img = getImageFromURL(value[1]);
                            if (img != null) {
                                this.m_logger.info("Set attribute photo.");
                                private_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_IMAGEPATH, PathResolver.getInstance().encode(img)));
                                bussiness_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_IMAGEPATH, PathResolver.getInstance().encode(img)));
                                private_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_IMAGEURL, value[1]));
                                bussiness_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_IMAGEURL, value[1]));
                            }
                        }
                        if (isEncoding) {
                            try {
                                if (img_type == null || img_type.trim().length() == 0)
                                    img_type = "jpg";
                                StringBuffer img_content = new StringBuffer();
                                img_content.append(value[1]);
                                img_content.append("\n");
                                do {
                                    j++;
                                    value[1] = lines[j];
                                    if (value[1].startsWith(" "))
                                        value[1] = value[1].substring(1);
                                    img_content.append(value[1]);
                                    img_content.append("\n");
                                } while (value[1].indexOf("=") < 0);
                                String img = getImageFromBase64(img_content.toString(), img_type);
                                if (img != null) {
                                    this.m_logger.info("Set attribute photo.");
                                    private_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_IMAGEPATH, PathResolver.getInstance().encode(img)));
                                    bussiness_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_IMAGEPATH, PathResolver.getInstance().encode(img)));
                                    private_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_IMAGEURL, value[1]));
                                    bussiness_attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_IMAGEURL, value[1]));
                                }
                            } catch (Exception ex) {
                                this.m_logger.log(Level.SEVERE, "VCF parsing error: PHOTO: " + ex.getMessage(), ex);
                            }
                        }
                    }
                }
            }
            // create ICaller objects
            IName name = PIMRuntime.getInstance().getCallerFactory().createName("", "");
            if (private_phones.size() > 0 && private_attributes.size() > 0) {
                ICaller c = PIMRuntime.getInstance().getCallerFactory().createCaller(name, private_phones);
                c.setAttributes(private_attributes);
                cl.add(c);
            }
            if (bussiness_phones.size() > 0 && bussiness_attributes.size() > 0) {
                ICaller c = PIMRuntime.getInstance().getCallerFactory().createCaller(name, bussiness_phones);
                c.setAttributes(bussiness_attributes);
                cl.add(c);
            }
        } catch (Exception e) {
            this.m_logger.log(Level.SEVERE, "VCF parsing error: " + e.getMessage(), e);
        // throw new VcfParserException("parsing error: "+e.getMessage(), e);
        }
    }
    return cl;
}
Also used : ArrayList(java.util.ArrayList) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ICaller(de.janrufmonitor.framework.ICaller) ICallerList(de.janrufmonitor.framework.ICallerList) IAttributeMap(de.janrufmonitor.framework.IAttributeMap) ArrayList(java.util.ArrayList) ICallerList(de.janrufmonitor.framework.ICallerList) List(java.util.List) IName(de.janrufmonitor.framework.IName) IPhonenumber(de.janrufmonitor.framework.IPhonenumber)

Aggregations

IName (de.janrufmonitor.framework.IName)15 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)12 ICaller (de.janrufmonitor.framework.ICaller)11 ICall (de.janrufmonitor.framework.ICall)6 ICip (de.janrufmonitor.framework.ICip)6 IMsn (de.janrufmonitor.framework.IMsn)6 IAttribute (de.janrufmonitor.framework.IAttribute)5 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 List (java.util.List)4 StringTokenizer (java.util.StringTokenizer)4 IAttributeMap (de.janrufmonitor.framework.IAttributeMap)3 ICallerList (de.janrufmonitor.framework.ICallerList)3 IEvent (de.janrufmonitor.framework.event.IEvent)2 IEventBroker (de.janrufmonitor.framework.event.IEventBroker)2 HandlerException (de.janrufmonitor.service.commons.http.handler.HandlerException)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 SQLException (java.sql.SQLException)2 CallerNotFoundException (de.janrufmonitor.repository.CallerNotFoundException)1