Search in sources :

Example 16 with ICallList

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

the class FritzXCallImporter2 method doImport.

public ICallList doImport() {
    long startDate = System.currentTimeMillis();
    try {
        File fritzxfile = new File(m_filename);
        FileInputStream fis = new FileInputStream(fritzxfile);
        DBFReader dbfReader = new DBFReader(fis);
        int size = dbfReader.getRecordCount();
        size = Math.abs(size);
        m_callList = getRuntime().getCallFactory().createCallList(size);
        Object[] rowObjects = null;
        CallCollection cc = null;
        List cc_list = new ArrayList();
        while ((rowObjects = dbfReader.nextRecord()) != null) {
            if (cc != null && cc.getId().equalsIgnoreCase((String) rowObjects[0])) {
                cc.add(rowObjects);
            } else {
                cc = new CallCollection((String) rowObjects[0]);
                cc_list.add(cc);
                cc.add(rowObjects);
            }
        }
        for (int i = 0, j = cc_list.size(); i < j; i++) {
            new MigratorThread(this.m_callList, (CallCollection) cc_list.get(i)).run();
        }
        fis.close();
    } catch (FileNotFoundException ex) {
        this.m_logger.warning("Cannot find call file " + m_filename);
        return this.m_callList;
    } catch (IOException ex) {
        this.m_logger.severe("IOException on file " + m_filename);
        return this.m_callList;
    }
    long endDate = System.currentTimeMillis();
    this.m_logger.info("Successfully imported call file " + m_filename);
    this.m_logger.info("Found " + new Integer(this.m_callList.size()).toString() + " call items in " + new Float((endDate - startDate) / 1000).toString() + " secs.");
    return m_callList;
}
Also used : ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) DBFReader(com.linuxense.javadbf.DBFReader) ICallList(de.janrufmonitor.framework.ICallList) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File)

Example 17 with ICallList

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

the class RemoveCallList method handleWithException.

public void handleWithException(IHttpRequest req, IMutableHttpResponse resp) throws HandlerException {
    ICallManager mgr = null;
    String manager = null;
    boolean isCompression = false;
    try {
        manager = req.getParameter(RemoveCallList.PARAMETER_CALLMANAGER);
        isCompression = (req.getParameter(GetCallList.PARAMETER_COMPRESSION) != null ? req.getParameter(GetCallList.PARAMETER_COMPRESSION).equalsIgnoreCase("true") : false);
    } catch (Exception e) {
        throw new HandlerException(e.getMessage(), 500);
    }
    if (manager == null)
        mgr = this.getRuntime().getCallManagerFactory().getDefaultCallManager();
    if (manager != null && manager.length() > 0)
        mgr = this.getRuntime().getCallManagerFactory().getCallManager(manager);
    if (mgr == null || !mgr.isActive() || !mgr.isSupported(IWriteCallRepository.class)) {
        throw new HandlerException("Requested Callmanager does not exist or is not active.", 404);
    }
    ICallList l;
    try {
        byte[] data = this.getPostData(req).getBytes();
        if (isCompression) {
            data = CompressBase64.decompressBase64Decode(data);
        }
        l = XMLSerializer.toCallList(new String(data));
        if (l != null) {
            this.m_logger.info("Removing call list with " + l.size() + " entries.");
            ((IWriteCallRepository) mgr).removeCalls(l);
            resp.getContentStreamForWrite().close();
        } else {
            this.m_logger.severe("Invalid call list transfered from client.");
            throw new HandlerException("Invalid call list transfered from client.", 500);
        }
    } catch (Exception e) {
        throw new HandlerException(e.getMessage(), 500);
    }
}
Also used : ICallManager(de.janrufmonitor.repository.ICallManager) HandlerException(de.janrufmonitor.service.commons.http.handler.HandlerException) ICallList(de.janrufmonitor.framework.ICallList) HandlerException(de.janrufmonitor.service.commons.http.handler.HandlerException) IWriteCallRepository(de.janrufmonitor.repository.types.IWriteCallRepository)

Example 18 with ICallList

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

the class Journaling method receivedOtherEventCall.

public void receivedOtherEventCall(IEvent event) {
    if (event.getType() == IEventConst.EVENT_TYPE_CALLACCEPTED || event.getType() == IEventConst.EVENT_TYPE_CALLCLEARED || event.getType() == IEventConst.EVENT_TYPE_MANUALCALLACCEPTED || event.getType() == IEventConst.EVENT_TYPE_CALLREJECTED || event.getType() == IEventConst.EVENT_TYPE_CALLMARKEDSPAM || event.getType() == IEventConst.EVENT_TYPE_IDENTIFIED_OUTGOING_CALL_ACCEPTED) {
        // checks wether this service is available for the incoming MSN or not.
        ICall updateCall = (ICall) event.getData();
        if (updateCall == null) {
            this.m_logger.warning("Call reference is null.");
            return;
        }
        if (this.getRuntime().getRuleEngine().validate(this.ID, updateCall.getMSN(), updateCall.getCIP(), updateCall.getCaller().getPhoneNumber())) {
            List callManagerList = this.getRuntime().getCallManagerFactory().getAllCallManagers();
            ICallManager icm = null;
            IEventBroker eventBroker = this.getRuntime().getEventBroker();
            for (int i = 0; i < callManagerList.size(); i++) {
                icm = (ICallManager) callManagerList.get(i);
                // check if the repository manager allows read/write access
                if (icm.isActive() && icm.isSupported(IWriteCallRepository.class)) {
                    // try to keep old attribute information of call and caller
                    if (icm.isSupported(IReadCallRepository.class)) {
                        this.m_logger.info("Call manager <" + icm.getManagerID() + "> is supporting read mode.");
                        ICallList cl = ((IReadCallRepository) icm).getCalls(new UUIDFilter(new String[] { updateCall.getUUID() }));
                        if (cl.size() == 1) {
                            this.m_logger.info("Found exact 1 old call in call manager <" + icm.getManagerID() + "> with UUID " + updateCall.getUUID());
                            ICall oldCall = cl.get(0);
                            if (oldCall != null) {
                                this.m_logger.info("Setting old call info : " + oldCall + " to new call : " + updateCall);
                                oldCall.getCaller().getAttributes().addAll(updateCall.getCaller().getAttributes());
                                oldCall.getAttributes().addAll(updateCall.getAttributes());
                                updateCall = oldCall;
                                this.m_logger.info("Updated new call : " + updateCall);
                            }
                        }
                    }
                    ((IWriteCallRepository) icm).updateCall(updateCall);
                    this.m_logger.info("Call update sent to repository manager <" + icm.getManagerID() + ">: " + updateCall);
                    eventBroker.send(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_UPDATE_CALL, updateCall));
                }
            }
        }
    }
}
Also used : ICallManager(de.janrufmonitor.repository.ICallManager) IReadCallRepository(de.janrufmonitor.repository.types.IReadCallRepository) ICall(de.janrufmonitor.framework.ICall) ICallList(de.janrufmonitor.framework.ICallList) UUIDFilter(de.janrufmonitor.repository.filter.UUIDFilter) ICallList(de.janrufmonitor.framework.ICallList) List(java.util.List) IEventBroker(de.janrufmonitor.framework.event.IEventBroker) IWriteCallRepository(de.janrufmonitor.repository.types.IWriteCallRepository)

Example 19 with ICallList

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

the class ConsoleJournal method execute.

public void execute() {
    isExecuting = true;
    System.out.println("Retrieving journal ...");
    System.out.println("");
    ICallManager m = PIMRuntime.getInstance().getCallManagerFactory().getDefaultCallManager();
    ICallList l = PIMRuntime.getInstance().getCallFactory().createCallList();
    if (m != null && m.isActive() && m.isSupported(IReadCallRepository.class)) {
        l = ((IReadCallRepository) m).getCalls((IFilter) null);
    }
    System.out.println("Sorting journal for date ...");
    System.out.println("");
    l.sort(CallListComparator.ORDER_DATE, false);
    System.out.println("Date                 | Caller                    | Number               | MSN                  | Service (CIP)");
    System.out.println("--------------------------------------------------------------------------------------------------------------------");
    for (int i = 0; i < l.size(); i++) {
        Formatter f = Formatter.getInstance(PIMRuntime.getInstance());
        StringBuffer callLine = new StringBuffer();
        callLine.append(trim(f.parse(IJAMConst.GLOBAL_VARIABLE_CALLTIME, l.get(i).getDate()), 20));
        callLine.append(" | ");
        callLine.append(trim(StringUtils.replaceString(f.parse(IJAMConst.GLOBAL_VARIABLE_CALLERNAME, l.get(i).getCaller()), IJAMConst.CRLF, " "), 25));
        callLine.append(" | ");
        callLine.append(trim(f.parse(IJAMConst.GLOBAL_VARIABLE_CALLERNUMBER, l.get(i).getCaller()), 20));
        callLine.append(" | ");
        callLine.append(trim(l.get(i).getMSN().getMSN() + (l.get(i).getMSN().getAdditional().equalsIgnoreCase("") ? "" : " (" + l.get(i).getMSN().getAdditional() + ")"), 20));
        callLine.append(" | ");
        callLine.append(trim(l.get(i).getCIP().getAdditional(), 18));
        System.out.println(callLine.toString());
    }
    System.out.println("");
    isExecuting = false;
}
Also used : ICallManager(de.janrufmonitor.repository.ICallManager) IReadCallRepository(de.janrufmonitor.repository.types.IReadCallRepository) ICallList(de.janrufmonitor.framework.ICallList) IFilter(de.janrufmonitor.repository.filter.IFilter) Formatter(de.janrufmonitor.util.formatter.Formatter)

Example 20 with ICallList

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

the class FritzBoxCallListImporter method processModifierServices.

private void processModifierServices(ICallList cl) {
    if (cl != null && cl.size() > 0) {
        List msvc = PIMRuntime.getInstance().getServiceFactory().getModifierServices();
        IModifierService s = null;
        for (int k = 0, l = msvc.size(); k < l; k++) {
            s = (IModifierService) msvc.get(k);
            if (s != null && s.isEnabled()) {
                if (m_logger.isLoggable(Level.INFO))
                    m_logger.info("Processing modifier service <" + s.getServiceID() + ">");
                ICall call = null;
                for (int i = 0, j = cl.size(); i < j; i++) {
                    call = cl.get(i);
                    s.modifyObject(call);
                }
            }
        }
    }
}
Also used : ICall(de.janrufmonitor.framework.ICall) IModifierService(de.janrufmonitor.service.IModifierService) ICallList(de.janrufmonitor.framework.ICallList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ICallList (de.janrufmonitor.framework.ICallList)35 ICall (de.janrufmonitor.framework.ICall)13 ICallManager (de.janrufmonitor.repository.ICallManager)11 List (java.util.List)10 IReadCallRepository (de.janrufmonitor.repository.types.IReadCallRepository)8 IWriteCallRepository (de.janrufmonitor.repository.types.IWriteCallRepository)8 ArrayList (java.util.ArrayList)8 IFilter (de.janrufmonitor.repository.filter.IFilter)7 IOException (java.io.IOException)5 Message (de.janrufmonitor.exception.Message)4 File (java.io.File)4 FileNotFoundException (java.io.FileNotFoundException)4 TableViewer (org.eclipse.jface.viewers.TableViewer)4 ICaller (de.janrufmonitor.framework.ICaller)3 ICip (de.janrufmonitor.framework.ICip)3 IPhonenumber (de.janrufmonitor.framework.IPhonenumber)3 DateFilter (de.janrufmonitor.repository.filter.DateFilter)3 HandlerException (de.janrufmonitor.service.commons.http.handler.HandlerException)3 FileInputStream (java.io.FileInputStream)3 Viewer (org.eclipse.jface.viewers.Viewer)3