@Override @Deprecated // Creates a profile with empty content. Is this meaningful? public Map<String, Object> createProfile(String versionId, String profileId) { ProfileBuilder builder = ProfileBuilder.Factory.create(versionId, profileId); Profile profile = profileService.createProfile(builder.getProfile()); return getProfile(versionId, profile.getId()); }
public static void renameProfile(FabricService fabricService, String versionId, String sourceId, String targetId, boolean force) { ProfileService profileService = fabricService.adapt(ProfileService.class); Profile sourceProfile = profileService.getRequiredProfile(versionId, sourceId); LOGGER.info("renameProfile: {} => {}", sourceProfile, targetId); // [TODO] delete/create profile must be done in an atomic operation maybeDeleteProfile(fabricService, versionId, targetId, force); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(sourceProfile); Profile targetProfile = profileService.createProfile(builder.identity(targetId).getProfile()); // TODO: what about child profiles ? for (Container container : fabricService.getAssociatedContainers(versionId, sourceId)) { Profile[] containerProfiles = container.getProfiles(); Set<Profile> profileSet = new HashSet<Profile>(Arrays.asList(containerProfiles)); profileSet.remove(sourceProfile); profileSet.add(targetProfile); container.setProfiles(profileSet.toArray(new Profile[profileSet.size()])); } maybeDeleteProfile(fabricService, versionId, sourceId, true); }
ProfileBuilder builder = ProfileBuilder.Factory.create(version.getId(), profileId); ProfileService profileService = fabricService.adapt(ProfileService.class); profile = profileService.createProfile(builder.getProfile());
public static void renameProfile(FabricService fabricService, String versionId, String sourceId, String targetId, boolean force) { ProfileService profileService = fabricService.adapt(ProfileService.class); Profile sourceProfile = profileService.getRequiredProfile(versionId, sourceId); LOGGER.info("renameProfile: {} => {}", sourceProfile, targetId); // [TODO] delete/create profile must be done in an atomic operation maybeDeleteProfile(fabricService, versionId, targetId, force); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(sourceProfile); Profile targetProfile = profileService.createProfile(builder.identity(targetId).getProfile()); // TODO: what about child profiles ? for (Container container : fabricService.getAssociatedContainers(versionId, sourceId)) { Profile[] containerProfiles = container.getProfiles(); Set<Profile> profileSet = new HashSet<Profile>(Arrays.asList(containerProfiles)); profileSet.remove(sourceProfile); profileSet.add(targetProfile); container.setProfiles(profileSet.toArray(new Profile[profileSet.size()])); } maybeDeleteProfile(fabricService, versionId, sourceId, true); }
@Override public Profile createProfile(Profile profile) { Permit<ProfileService> permit = permitManager.get().aquirePermit(ProfileService.PERMIT, false); try { ProfileService service = permit.getInstance(); return service.createProfile(profile); } finally { permit.release(); } }
ProfileBuilder builder = ProfileBuilder.Factory.create(version.getId(), profileId); ProfileService profileService = fabricService.adapt(ProfileService.class); profile = profileService.createProfile(builder.getProfile());
public static void copyProfile(FabricService fabricService, String versionId, String sourceId, String targetId, boolean force) { ProfileService profileService = fabricService.adapt(ProfileService.class); Profile sourceProfile = profileService.getRequiredProfile(versionId, sourceId); LOGGER.info("copyProfile: {} => {}", sourceProfile, targetId); // [TODO] delete/create profile must be done in an atomic operation maybeDeleteProfile(fabricService, versionId, targetId, force); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(sourceProfile); profileService.createProfile(builder.identity(targetId).getProfile()); }
public static void copyProfile(FabricService fabricService, String versionId, String sourceId, String targetId, boolean force) { ProfileService profileService = fabricService.adapt(ProfileService.class); Profile sourceProfile = profileService.getRequiredProfile(versionId, sourceId); LOGGER.info("copyProfile: {} => {}", sourceProfile, targetId); // [TODO] delete/create profile must be done in an atomic operation maybeDeleteProfile(fabricService, versionId, targetId, force); ProfileBuilder builder = ProfileBuilder.Factory.createFrom(sourceProfile); profileService.createProfile(builder.identity(targetId).getProfile()); }
@Override public Map<String, Object> createProfile(String versionId, String profileId, List<String> parents) { ProfileBuilder builder = ProfileBuilder.Factory.create(versionId, profileId).addParents(parents); Profile profile = profileService.createProfile(builder.getProfile()); return getProfile(versionId, profile.getId()); }
builder.setBundles(Collections.singletonList(descriptor.migratorBundle)); profile = profileService.createProfile(builder.getProfile()); Profile defaultProfile = version.getRequiredProfile("default"); List<String> parentIds = new LinkedList<String>();
profileDTO.populateBuilder(fabricService, profileService, builder); Profile profile = builder.getProfile(); profileService.createProfile(profile); return Response.created(location).build();
profileDTO.populateBuilder(fabricService, profileService, builder); Profile profile = builder.getProfile(); profileService.createProfile(profile); return Response.created(location).build();
return create ? profileService.createProfile(profile) : profileService.updateProfile(profile);
@Override protected Object doExecute() throws Exception { try { FabricValidations.validateProfileName(profileId); } catch (IllegalArgumentException e) { // we do not want exception in the server log, so print the error message to the console System.out.println(e.getMessage()); return null; } if (versionId != null) { profileService.getRequiredVersion(versionId); } else { versionId = fabricService.getDefaultVersionId(); } // we can only use existing parent profiles Profile[] parents = FabricCommand.getExistingProfiles(fabricService, versionId, this.parents); ProfileBuilder builder = ProfileBuilder.Factory.create(versionId, profileId); for (Profile parent : parents) { builder.addParent(parent.getId()); } profileService.createProfile(builder.getProfile()); return null; }
private Profile getOrCreateProfile(Version version, ProjectRequirements requirements) { String profileId = getProfileId(requirements); if (Strings.isEmpty(profileId)) { throw new IllegalArgumentException("No profile ID could be deduced for requirements: " + requirements); } // make sure the profileId is valid FabricValidations.validateProfileName(profileId); Profile profile; if (!version.hasProfile(profileId)) { LOG.info("Creating new profile " + profileId + " version " + version + " for requirements: " + requirements); String versionId = version.getId(); ProfileService profileService = fabricService.get().adapt(ProfileService.class); ProfileBuilder builder = ProfileBuilder.Factory.create(versionId, profileId); profile = profileService.createProfile(builder.getProfile()); } else { profile = version.getRequiredProfile(profileId); } return profile; }
return create ? profileService.createProfile(profile) : profileService.updateProfile(profile);