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);
}
}
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();
}
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);
}
}
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();
}
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);
}
}
}
}
}
Aggregations