@Override public final Profile getComponentProfile(String id) throws RegistryException { // TODO use a map instead of a *linear search*... for (Profile p : getComponentProfiles()) if (p.getId().equals(id)) return p; return null; }
@Override public final Profile getComponentProfile(String id) throws RegistryException { // TODO use a map instead of a *linear search*... for (Profile p : getComponentProfiles()) if (p.getId().equals(id)) return p; return null; }
private void updateFamiliesFromRegistry() throws RegistryException { for (Family f : chosenRegistry.getComponentFamilies()) { if (profileFilter == null) { familyMap.put(f.getName(), f); continue; } Profile componentProfile = null; try { componentProfile = f.getComponentProfile(); } catch (Exception e) { logger.error("failed to get profile of component", e); } if (componentProfile != null) { String id = componentProfile.getId(); if ((profileFilter == null) || id.equals(profileFilter.getId())) familyMap.put(f.getName(), f); } else logger.info("Ignoring " + f.getName()); } }
@Override public final Profile addComponentProfile(Profile componentProfile, License license, SharingPolicy sharingPolicy) throws RegistryException { if (componentProfile == null) { throw new RegistryException("componentProfile is null"); } Profile result = null; checkProfileCache(); for (Profile p : getComponentProfiles()) if (p.getId().equals(componentProfile.getId())) { result = p; break; } if (result == null) { result = internalAddComponentProfile(componentProfile, license, sharingPolicy); synchronized (profileCache) { profileCache.add(result); } } return result; }
@Override public final Profile addComponentProfile(Profile componentProfile, License license, SharingPolicy sharingPolicy) throws RegistryException { if (componentProfile == null) { throw new RegistryException("componentProfile is null"); } Profile result = null; checkProfileCache(); for (Profile p : getComponentProfiles()) if (p.getId().equals(componentProfile.getId())) { result = p; break; } if (result == null) { result = internalAddComponentProfile(componentProfile, license, sharingPolicy); synchronized (profileCache) { profileCache.add(result); } } return result; }
@Test public void testAddComponentProfile() throws Exception { List<Profile> componentProfiles = componentRegistry .getComponentProfiles(); boolean contained = false; for (Profile p : componentProfiles) { if (p.getId().equals(componentProfile.getId())) { contained = true; } } assertFalse(contained); int componentProfileCount = componentProfiles.size(); componentRegistry.addComponentProfile(componentProfile, null, null); int newSize = componentRegistry.getComponentProfiles().size(); assertEquals(componentProfileCount + 1, newSize); }
@Test public void testAddComponentProfile() throws Exception { List<Profile> componentProfiles = componentRegistry .getComponentProfiles(); boolean contained = false; for (Profile p : componentProfiles) { if (p.getId().equals(componentProfile.getId())) { contained = true; } } assertFalse(contained); int componentProfileCount = componentProfiles.size(); componentRegistry.addComponentProfile(componentProfile, null, null); int newSize = componentRegistry.getComponentProfiles().size(); assertEquals(componentProfileCount + 1, newSize); }
public static void post() throws Exception { NewComponentRegistry registry = (NewComponentRegistry) getComponentRegistry(componentRegistryUrl); for (Profile p : registry.getComponentProfiles()) registry.client.delete("/file.xml", "id=" + p.getId()); for (Family f : registry.getComponentFamilies()) { for (Component c : f.getComponents()) registry.deleteComponent((NewComponent) c); registry.client.delete("/pack.xml", "id=" + ((NewComponentFamily) f).getId()); } } }
public static void post() throws Exception { NewComponentRegistry registry = (NewComponentRegistry) getComponentRegistry(componentRegistryUrl); for (Profile p : registry.getComponentProfiles()) registry.getClient().delete("/file.xml", "id=" + p.getId()); for (Family f : registry.getComponentFamilies()) { for (Component c : f.getComponents()) registry.deleteComponent((NewComponent) c); registry.getClient().delete("/pack.xml", "id=" + ((NewComponentFamily) f).getId()); } } }