Package com.volantis.devrep.repository.api.devices.logging

Examples of com.volantis.devrep.repository.api.devices.logging.HeadersEntry


            }
            unknownDevice = true;
            if (unknownDevicesLogger != null) {
                // log unknown device
                try {
                    unknownDevicesLogger.appendEntry(new HeadersEntry(deviceName,
                        UnknownDevicesLogger.DEVICE_TYPE_UNKNOWN, headers));
                } catch (IOException e) {
                    logger.warn("cannot-write-unknown-devices-log-file");
                }
            }
            logger.info("device-name-info", new Object[]{deviceName});
        }

        if (logger.isDebugEnabled()) {
            logger.debug("Primary device name is " + deviceName);
        }

        // Get the device.  Note that this is called using the connection, not
        // the localConnection.
        DefaultDevice dev = getDevice(connection, deviceName, accessor);
        if (dev == null) {
            throw new IllegalStateException(
                "Cannot find device object for name " + deviceName);
        }

        String secondary = dev.getSecondaryIDHeaderName();
        // Follow any secondary paths
        Set cyclicReferenceMap = new HashSet();
        while (secondary != null) {
            String hdr;
            if (secondary.equalsIgnoreCase("NN-Profile")) {
                hdr = null;
                // get the possible profile header names
                final SortedSet profileHeaderNames =
                    getProfileHeaderNames(headers, headersUsed);

                // check if any of them contains a profile URL we can recognise
                for (Iterator iter = profileHeaderNames.iterator();
                        iter.hasNext() && hdr == null; ) {

                    // get the profile URL's stored in the NN-Profile header
                    final String profileHeaderName = (String) iter.next();
                    final List profileUrls =
                        getProfileUrls(headers, profileHeaderName);
                    headersUsed.add(profileHeaderName);

                    // iterate over the profile URL's and see if there is a
                    // matching device
                    String secondaryDeviceName = null;
                    for (Iterator urlsIter = profileUrls.iterator();
                            urlsIter.hasNext() && secondaryDeviceName == null; ) {

                        final String profileUrl = (String) urlsIter.next();
                        secondaryDeviceName = getDeviceName(
                            accessor, secondary, profileUrl, dev.getName());
                        if (deviceName != null) {
                            hdr = profileUrl;
                        }
                    }
                }
            } else {
                headersUsed.add(secondary);
                hdr = headers.getHeader(secondary);
            }
            DefaultDevice newDev = dev.getSecondaryDevice(hdr);
            if (newDev == null) {
                deviceName =
                    getDeviceName(accessor, secondary, hdr, dev.getName());
                if (deviceName != null) {
                    newDev = getDevice(connection, deviceName, accessor);
                    if (newDev != null) {
                        if (!cyclicReferenceMap.add(newDev.getName())) {
                            logger.warn("cyclic-secondary-header",
                                new Object[]{dev.getName(), secondary});
                            // set the secondary to null so that we break out
                            // of the loop
                            secondary = null;
                        } else {
                            dev.addSecondaryDevice(hdr, newDev);
                            dev = newDev;
                            secondary = dev.getSecondaryIDHeaderName();
                            if (logger.isDebugEnabled()) {
                                logger.debug("Secondary device name is " +
                                    dev.getName());
                            }
                        }
                    } else {
                        secondary = null;
                    }
                } else {
                    secondary = null;
                }
            } else {
                if (!cyclicReferenceMap.add(newDev.getName())) {
                    logger.warn("cyclic-secondary-header",
                        new Object[]{dev.getName(), secondary});
                    // set the secondary to null so that we break out
                    // of the loop
                    secondary = null;
                } else {
                    dev = newDev;
                    secondary = dev.getSecondaryIDHeaderName();
                    if (logger.isDebugEnabled()) {
                        logger.debug("Secondary device name is " +
                            dev.getName());
                    }
                }
            }
        }
        if (logger.isDebugEnabled()) {
            logger.debug("Device name is " + dev.getName());
        }

        if (!unknownDevice &&
            "abstract_device".equals(dev.getComputedPolicyValue("entrytype"))) {
            // log abstract device
            if (unknownDevicesLogger != null) {
                try {
                    unknownDevicesLogger.appendEntry(
                        new HeadersEntry(dev.getName(),
                            UnknownDevicesLogger.DEVICE_TYPE_ABSTRACT, headers));
                } catch (IOException e) {
                    logger.warn("cannot-write-unknown-devices-log-file");
                }
            }
View Full Code Here

TOP

Related Classes of com.volantis.devrep.repository.api.devices.logging.HeadersEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.