@Test public void testExists() { AssertJUnit.assertTrue(SolarisUtil.exists(ObjectClass.ACCOUNT, new SolarisEntry.Builder( "root").build(), getConnection())); AssertJUnit.assertFalse(SolarisUtil.exists(ObjectClass.ACCOUNT, new SolarisEntry.Builder( "batmans").build(), getConnection())); AssertJUnit.assertTrue(SolarisUtil.exists(ObjectClass.GROUP, new SolarisEntry.Builder( "root").build(), getConnection())); AssertJUnit.assertFalse(SolarisUtil.exists(ObjectClass.GROUP, new SolarisEntry.Builder( "batmans").build(), getConnection())); }
public static boolean exists(ObjectClass entryType, SolarisEntry entry, SolarisConnection conn) { Iterator<SolarisEntry> result = null; if (entryType.is(ObjectClass.ACCOUNT_NAME)) { return SolarisEntries.getAccount(entry.getName(), EnumSet.of(NativeAttribute.NAME), conn) != null; } else if (entryType.is(ObjectClass.GROUP_NAME)) { result = SolarisEntries.getAllGroups(EnumSet.of(NativeAttribute.NAME), conn); } else { throw new ConnectorException("Non existing object class: " + entryType.toString()); } while (result != null && result.hasNext()) { SolarisEntry it = result.next(); if (it.getName().equals(entry.getName())) { return true; } } return false; }
SolarisUtil { public static boolean exists(ObjectClass entryType, SolarisEntry entry, SolarisConnection conn) { Iterator<SolarisEntry> result = null; if (entryType.is(ObjectClass.ACCOUNT_NAME)) { return SolarisEntries.getAccount(entry.getName(), EnumSet.of(NativeAttribute.NAME), conn) != null; } else if (entryType.is(ObjectClass.GROUP_NAME)) { result = SolarisEntries.getAllGroups(EnumSet.of(NativeAttribute.NAME), conn); } else { throw new ConnectorException("Non existing object class: " + entryType.toString()); } while (result != null && result.hasNext()) { SolarisEntry it = result.next(); if (it.getName().equals(entry.getName())) { return true; } } return false; } }
SolarisUtil { public static boolean exists(ObjectClass entryType, SolarisEntry entry, SolarisConnection conn) { Iterator<SolarisEntry> result = null; if (entryType.is(ObjectClass.ACCOUNT_NAME)) { return SolarisEntries.getAccount(entry.getName(), EnumSet.of(NativeAttribute.NAME), conn) != null; } else if (entryType.is(ObjectClass.GROUP_NAME)) { result = SolarisEntries.getAllGroups(EnumSet.of(NativeAttribute.NAME), conn); } else { throw new ConnectorException("Non existing object class: " + entryType.toString()); } while (result != null && result.hasNext()) { SolarisEntry it = result.next(); if (it.getName().equals(entry.getName())) { return true; } } return false; } private  SolarisUtil(); }
SolarisUtil { public static boolean exists(ObjectClass entryType, SolarisEntry entry, SolarisConnection conn) { Iterator<SolarisEntry> result = null; if (entryType.is(ObjectClass.ACCOUNT_NAME)) { return SolarisEntries.getAccount(entry.getName(), EnumSet.of(NativeAttribute.NAME), conn) != null; } else if (entryType.is(ObjectClass.GROUP_NAME)) { result = SolarisEntries.getAllGroups(EnumSet.of(NativeAttribute.NAME), conn); } else { throw new ConnectorException("Non existing object class: " + entryType.toString()); } while (result != null && result.hasNext()) { SolarisEntry it = result.next(); if (it.getName().equals(entry.getName())) { return true; } } return false; } private  SolarisUtil(); static String limitString(StringBuilder data); static void controlObjectClassValidity(ObjectClass oclass,
            ObjectClass[] acceptedObjectClasses, Class<? extends AbstractOp> operation,
            final SolarisConfiguration configuration); static SolarisEntry convertIcfAttributesToSolarisEntry(String entryName, ObjectClass objectClass,
            Set<Attribute> attributes, SolarisConfiguration config); static ConnectorObject convertToConnectorObject(SolarisEntry entry, String[] attrsToGet, 
    		ObjectClass oclass, SolarisConfiguration config); static boolean exists(ObjectClass entryType, SolarisEntry entry, SolarisConnection conn); }
SolarisUtil { public static boolean exists(ObjectClass entryType, SolarisEntry entry, SolarisConnection conn) { Iterator<SolarisEntry> result = null; if (entryType.is(ObjectClass.ACCOUNT_NAME)) { return SolarisEntries.getAccount(entry.getName(), EnumSet.of(NativeAttribute.NAME), conn) != null; } else if (entryType.is(ObjectClass.GROUP_NAME)) { result = SolarisEntries.getAllGroups(EnumSet.of(NativeAttribute.NAME), conn); } else { throw new ConnectorException("Non existing object class: " + entryType.toString()); } while (result != null && result.hasNext()) { SolarisEntry it = result.next(); if (it.getName().equals(entry.getName())) { return true; } } return false; } private  SolarisUtil(); static String limitString(StringBuilder data); static void controlObjectClassValidity(ObjectClass oclass,
            ObjectClass[] acceptedObjectClasses, Class<? extends AbstractOp> operation,
            final SolarisConfiguration configuration); static SolarisEntry convertIcfAttributesToSolarisEntry(String entryName, ObjectClass objectClass,
            Set<Attribute> attributes, SolarisConfiguration config); static ConnectorObject convertToConnectorObject(SolarisEntry entry, String[] attrsToGet, 
    		ObjectClass oclass, SolarisConfiguration config); static boolean exists(ObjectClass entryType, SolarisEntry entry, SolarisConnection conn); static final int DEFAULT_LIMIT; }