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

Examples of com.volantis.devrep.repository.api.devices.DefaultDevice


        policies.put("flashinpage", "true");
        policies.put("downloadeble.audio.maxsize", "1000");
        policies.put("downloadeble.audio.maxbitrate", "128");

        InternalDevice device = INTERNAL_DEVICE_FACTORY.createInternalDevice(
            new DefaultDevice("Test Device", policies, null));
        return device;
    }
View Full Code Here


     */
    protected DOMProtocol createProtocol() {

        ProtocolBuilder builder = new ProtocolBuilder();

        final DefaultDevice defaultDevice =
            new DefaultDevice("Test Device", new HashMap(), null);
        defaultDevice.setPolicyValue(
            DevicePolicyConstants.SUPPORTS_JAVASCRIPT, "true");
        InternalDevice device =
            INTERNAL_DEVICE_FACTORY.createInternalDevice(defaultDevice);

        DOMProtocol protocol = (DOMProtocol) builder.build(
View Full Code Here

        do {
          tacs.add(new TACValue(rs.getLong(1)));
        } while (rs.next());
      }

      DefaultDevice device =
          new DefaultDevice(deviceName, policies, getPolicyValueFactory());
      device.setPatterns(patterns);
      device.setTACValues(tacs);

      return device;
    } catch (SQLException sqle) {
      logger.error("sql-exception", sqle);
      throw new JDBCRepositoryException(sqle);
View Full Code Here

    }

    protected DefaultDevice retrieveDeviceImpl(RepositoryConnection connection,
                                                String deviceName) throws RepositoryException {

        DefaultDevice device = null;

        // First check in the hierarchy to see if the device exists.
        Hierarchy hierarchy = loadHierarchy();
        final HierarchyEntry entry = hierarchy.find(deviceName);
        if (entry != null) {
            // The device name exists in the hierarchy.

            // Create the device by reading in it's standard and custom
            // polices, and also any device patterns and device TACs.
            device = createDevice(deviceName);

            // We must explicitly add the fallback policy for backward
            // compatibility.
            final HierarchyEntry parent = entry.getParent();
            String fallbackDeviceName;
            if (parent != null) {
                fallbackDeviceName = parent.getDeviceName();
            } else {
                // for backwards compatibility with the old JDOM accessor,
                // we add a fallback of null for Master. Not sure if we
                // really should?
                fallbackDeviceName = null;
            }
            device.setPolicyValue(
                    DeviceRepositoryConstants.FALLBACK_POLICY_NAME,
                    fallbackDeviceName);
        }
        return device;
    }
View Full Code Here

    private DefaultDevice createDevice(String deviceName)
            throws RepositoryException {

        // Create the device and set it's name.
        DefaultDevice device =
            new DefaultDevice(deviceName, new HashMap(), getPolicyValueFactory());

        // First add all the standard policies to the device.
        String standardDeviceFileName = getXMLFilePath(
                DeviceRepositoryConstants.STANDARD_DEVICE_DIRECTORY,
                deviceName);
        PolicySet standardPolicySet =
            (PolicySet) loadZipObject(standardDeviceFileName, PolicySet.class);
        if (standardPolicySet == null) {
            // No standard device. This is bad since this is mandatory.
            throw new RepositoryException(EXCEPTION_LOCALIZER.format(
                    "device-definition-missing", deviceName));
        }
        addPolicySetToDevice(standardPolicySet, device);

        // Then add any custom policies to the device.
        String customDeviceFileName = getXMLFilePath(
                DeviceRepositoryConstants.CUSTOM_DEVICE_DIRECTORY,
                deviceName);
        PolicySet customPolicySet =
            (PolicySet) loadZipObject(customDeviceFileName, PolicySet.class);
        if (customPolicySet != null) {
            // we had some custom polices, add them too.
            addPolicySetToDevice(customPolicySet, device);
        }

        // Add the device patterns to the device.
        Identification identification = loadIdentification();
        final Map patterns = new HashMap();
        IdentificationEntry idEntry = identification.find(deviceName);
        if (idEntry != null) {
            iterateGenericPatterns(idEntry, new GenericPatternIteratee() {
                public void next(String pattern) {
                    // NOTE: yes this is intentional, why this must be a
                    // map I have no idea - a list would be fine.
                    patterns.put(pattern, null);
                }
            });
            if (patterns.size() != 0) {
                device.setPatterns(patterns);
            }
        }
        // Add the device TACs to the device.
        TacIdentification tacIdentification = loadTacIdentification();
        if (tacIdentification != null) {
            TacIdentificationEntry tacEntry = tacIdentification.find(
                    deviceName);
            if (tacEntry != null) {
                Set tacSet = convertTacEntryToTacSet(tacEntry);
                if (tacSet.size() != 0) {
                    device.setTACValues(tacSet);
                }
            }
        }
        return device;
    }
View Full Code Here

                AbstractDeviceRepositoryAccessor accessor =
                        createAccessor(deviceRepositoryFile);

                try {
                    accessor.addDevice(createConnection(),
                            new DefaultDevice("PC-MacOS", new HashMap(), null));

                    fail("Should have had a repository exception");
                } catch (RepositoryException e) {
                    // Expected condition
                }
View Full Code Here

            public void execute(File deviceRepositoryFile) throws Exception {

                AbstractDeviceRepositoryAccessor accessor =
                        createAccessor(deviceRepositoryFile);

                DefaultDevice master = accessor.retrieveDevice(createConnection(),
                        "Master");
                assertEquals("", "Master", master.getName());

                assertNull("No TACs should be defined for Master",
                        master.getTACValues());

                int count = 0;
                for (Iterator iter = master.getPolicyNames(); iter.hasNext(); iter.next()) {
//                    final String name = (String) iter.next();
//                    System.out.println(
//                        name + " -> " + master.getPolicyValue(name));
                    count++;
                }
                assertEquals(289, count);
                assertEquals("Unexpected download value",
                        "false", master.getPolicyValue("download"));
                assertEquals("Unexpected UAProf.CcppAccept value",
                        "text/html,image/jpeg,image/gif",
                        master.getPolicyValue("UAProf.CcppAccept"));
                assertEquals("Unexpected protocol.wml.emulate.cardTitle.enable",
                        "false",
                        master.getPolicyValue("protocol.wml.emulate.cardTitle.enable"));

                // Check a device which is expected to have TACs
                DefaultDevice nokia = accessor.retrieveDevice(createConnection(),
                        "Nokia-6210");
                assertEquals("Name should be as expected",
                        "Nokia-6210", nokia.getName());
                Set tacs = nokia.getTACValues();
                assertEquals("Nokia-6210 should have two TACs",
                        2, tacs.size());
                assertTrue("Nokia-6210 TACs should include 35061220",
                        tacs.contains(new TACValue(35061220)));
                assertTrue("Nokia-6210 TACs should include 350612",
View Full Code Here

                if (deviceName == null) {
                    throw new IllegalArgumentException("test case fault");
                }

                DefaultDevice expectedDevice =
                    getExpectedDevice(deviceName);
                DefaultDevice actualDevice =
                    accessor.retrieveDevice(createConnection(), deviceName);

                assertEquals(expectedDevice, actualDevice);
            }
        });
View Full Code Here

                         "text/html,image/jpeg,image/gif,video/mp4");
        }

        policies.put("fallback", getExpectedDeviceFallback(deviceName));

        DefaultDevice device = new DefaultDevice(deviceName, policies, null);

        // Finally handle the device patterns
        String[] patternStrings = getExpectedDevicePatterns(deviceName);

        if ((patternStrings != null) &&
            (patternStrings.length != 0)) {
            Map patterns = new HashMap();

            for (int j = 0; j < patternStrings.length; j++) {
                patterns.put(patternStrings[j], null);
            }

            device.setPatterns(patterns);
        }

        return device;
    }
View Full Code Here

     */   
    protected DOMProtocol createProtocol() {

        ProtocolBuilder builder = new ProtocolBuilder();

        final DefaultDevice defaultDevice =
            new DefaultDevice("Test Device", new HashMap(), null);
        defaultDevice.setPolicyValue(DevicePolicyConstants.WML_IMAGE_NOSAVE,
                DevicePolicyConstants.WML_IMAGE_NOSAVE__ALT_NO_SAVE);

        InternalDevice device =
            INTERNAL_DEVICE_FACTORY.createInternalDevice(defaultDevice);
        DOMProtocol protocol = (DOMProtocol)builder.build(
View Full Code Here

TOP

Related Classes of com.volantis.devrep.repository.api.devices.DefaultDevice

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.