@Nullable public ProvisioningTaskInfo getTaskInfo(ProvisioningTaskKey key) { return table.get(getRowKey(key), ProvisioningTaskInfo.class); }
@Nullable public ProvisioningTaskInfo getTaskInfo(ProvisioningTaskKey key) { return table.get(getRowKey(key), ProvisioningTaskInfo.class); }
/** * Get the profile information about the given profile * * @param profileId the id of the profile to look up * @return the profile information about the given profile * @throws NotFoundException if the profile is not found */ public Profile getProfile(ProfileId profileId) throws NotFoundException { Profile profile = table.get(getProfileRowKey(profileId), Profile.class); if (profile == null) { throw new NotFoundException(profileId); } return profile; }
/** * Get the profile information about the given profile * * @param profileId the id of the profile to look up * @return the profile information about the given profile * @throws NotFoundException if the profile is not found */ public Profile getProfile(ProfileId profileId) throws NotFoundException { Profile profile = table.get(getProfileRowKey(profileId), Profile.class); if (profile == null) { throw new NotFoundException(profileId); } return profile; }
/** * Get assignments with the profile. * * @param profileId the profile id * @return the set of entities that the profile is assigned to * @throws NotFoundException if the profile is not found */ public Set<EntityId> getProfileAssignments(ProfileId profileId) throws NotFoundException { Profile profile = table.get(getProfileRowKey(profileId), Profile.class); if (profile == null) { throw new NotFoundException(profileId); } return Collections.unmodifiableSet(new HashSet<>(table.list(getEntityIndexRowKeyPrefix(profileId), EntityId.class))); }
/** * Get assignments with the profile. * * @param profileId the profile id * @return the set of entities that the profile is assigned to * @throws NotFoundException if the profile is not found */ public Set<EntityId> getProfileAssignments(ProfileId profileId) throws NotFoundException { Profile profile = table.get(getProfileRowKey(profileId), Profile.class); if (profile == null) { throw new NotFoundException(profileId); } return Collections.unmodifiableSet(new HashSet<>(table.list(getEntityIndexRowKeyPrefix(profileId), EntityId.class))); }
/** * Remove an assignment from the profile. * * @param profileId the profile id * @param entityId the entity to remove from the assignment * @throws NotFoundException if the profile is not found */ public void removeProfileAssignment(ProfileId profileId, EntityId entityId) throws NotFoundException { Profile profile = table.get(getProfileRowKey(profileId), Profile.class); if (profile == null) { throw new NotFoundException(profileId); } table.delete(getEntityIndexRowKey(profileId, entityId)); }
/** * Remove an assignment from the profile. * * @param profileId the profile id * @param entityId the entity to remove from the assignment * @throws NotFoundException if the profile is not found */ public void removeProfileAssignment(ProfileId profileId, EntityId entityId) throws NotFoundException { Profile profile = table.get(getProfileRowKey(profileId), Profile.class); if (profile == null) { throw new NotFoundException(profileId); } table.delete(getEntityIndexRowKey(profileId, entityId)); }
/** * Add an assignment to the profile. Assignment can only be added if the profile is ENABLED * * @param profileId the profile id * @param entityId the entity to add to the assgiment */ public void addProfileAssignment(ProfileId profileId, EntityId entityId) throws ProfileConflictException, NotFoundException { Profile profile = table.get(getProfileRowKey(profileId), Profile.class); if (profile == null) { throw new NotFoundException(profileId); } if (profile.getStatus() == ProfileStatus.DISABLED) { throw new ProfileConflictException( String.format("Profile %s is DISABLED. No entity can be assigned to it.", profileId.getProfile()), profileId); } table.write(getEntityIndexRowKey(profileId, entityId), entityId); }
/** * Add an assignment to the profile. Assignment can only be added if the profile is ENABLED * * @param profileId the profile id * @param entityId the entity to add to the assgiment */ public void addProfileAssignment(ProfileId profileId, EntityId entityId) throws ProfileConflictException, NotFoundException { Profile profile = table.get(getProfileRowKey(profileId), Profile.class); if (profile == null) { throw new NotFoundException(profileId); } if (profile.getStatus() == ProfileStatus.DISABLED) { throw new ProfileConflictException( String.format("Profile %s is DISABLED. No entity can be assigned to it.", profileId.getProfile()), profileId); } table.write(getEntityIndexRowKey(profileId, entityId), entityId); }
/** * Deletes the profile from the profile store * * @param profileId the id of the profile to delete * @throws NotFoundException if the profile is not found * @throws ProfileConflictException if the profile is enabled */ public void deleteProfile(ProfileId profileId) throws NotFoundException, ProfileConflictException { MDSKey rowKey = getProfileRowKey(profileId); Profile value = table.get(rowKey, Profile.class); if (value == null) { throw new NotFoundException(profileId); } if (value.getStatus() == ProfileStatus.ENABLED) { throw new ProfileConflictException( String.format("Profile %s in namespace %s is currently enabled. A profile can " + "only be deleted if it is disabled", profileId.getProfile(), profileId.getNamespace()), profileId); } table.delete(getProfileRowKey(profileId)); }
/** * Deletes the profile from the profile store * * @param profileId the id of the profile to delete * @throws NotFoundException if the profile is not found * @throws ProfileConflictException if the profile is enabled */ public void deleteProfile(ProfileId profileId) throws NotFoundException, ProfileConflictException { MDSKey rowKey = getProfileRowKey(profileId); Profile value = table.get(rowKey, Profile.class); if (value == null) { throw new NotFoundException(profileId); } if (value.getStatus() == ProfileStatus.ENABLED) { throw new ProfileConflictException( String.format("Profile %s in namespace %s is currently enabled. A profile can " + "only be deleted if it is disabled", profileId.getProfile(), profileId.getNamespace()), profileId); } table.delete(getProfileRowKey(profileId)); }
/** * Add a profile if it does not exist in the store * * @param profileId the id of the profile to add * @param profile the information of the profile */ public void createIfNotExists(ProfileId profileId, Profile profile) { MDSKey rowKey = getProfileRowKey(profileId); Profile oldProfile = table.get(rowKey, Profile.class); if (oldProfile != null) { return; } table.write(rowKey, new Profile(profile.getName(), profile.getLabel(), profile.getDescription(), profile.getScope(), ProfileStatus.ENABLED, profile.getProvisioner())); }
/** * Add a profile if it does not exist in the store * * @param profileId the id of the profile to add * @param profile the information of the profile */ public void createIfNotExists(ProfileId profileId, Profile profile) { MDSKey rowKey = getProfileRowKey(profileId); Profile oldProfile = table.get(rowKey, Profile.class); if (oldProfile != null) { return; } table.write(rowKey, new Profile(profile.getName(), profile.getLabel(), profile.getDescription(), profile.getScope(), ProfileStatus.ENABLED, profile.getProvisioner())); }
private void changeProfileStatus(ProfileId profileId, ProfileStatus expectedStatus) throws NotFoundException, ProfileConflictException { MDSKey rowKey = getProfileRowKey(profileId); Profile oldProfile = table.get(rowKey, Profile.class); if (oldProfile == null) { throw new NotFoundException(profileId); } if (oldProfile.getStatus() == expectedStatus) { throw new ProfileConflictException( String.format("Profile %s already %s", profileId.getProfile(), expectedStatus.toString()), profileId); } table.write(rowKey, new Profile(oldProfile.getName(), oldProfile.getLabel(), oldProfile.getDescription(), oldProfile.getScope(), expectedStatus, oldProfile.getProvisioner(), oldProfile.getCreatedTsSeconds())); }
private void changeProfileStatus(ProfileId profileId, ProfileStatus expectedStatus) throws NotFoundException, ProfileConflictException { MDSKey rowKey = getProfileRowKey(profileId); Profile oldProfile = table.get(rowKey, Profile.class); if (oldProfile == null) { throw new NotFoundException(profileId); } if (oldProfile.getStatus() == expectedStatus) { throw new ProfileConflictException( String.format("Profile %s already %s", profileId.getProfile(), expectedStatus.toString()), profileId); } table.write(rowKey, new Profile(oldProfile.getName(), oldProfile.getLabel(), oldProfile.getDescription(), oldProfile.getScope(), expectedStatus, oldProfile.getProvisioner(), oldProfile.getCreatedTsSeconds())); }
/** * Save the profile to the profile store. By default the profile status will be enabled. * * @param profileId the id of the profile to save * @param profile the information of the profile */ public void saveProfile(ProfileId profileId, Profile profile) { MDSKey rowKey = getProfileRowKey(profileId); Profile oldProfile = table.get(rowKey, Profile.class); table.write( rowKey, new Profile(profile.getName(), profile.getLabel(), profile.getDescription(), profile.getScope(), oldProfile == null ? ProfileStatus.ENABLED : oldProfile.getStatus(), profile.getProvisioner(), oldProfile == null ? profile.getCreatedTsSeconds() : oldProfile.getCreatedTsSeconds())); }
/** * Save the profile to the profile store. By default the profile status will be enabled. * * @param profileId the id of the profile to save * @param profile the information of the profile */ public void saveProfile(ProfileId profileId, Profile profile) { MDSKey rowKey = getProfileRowKey(profileId); Profile oldProfile = table.get(rowKey, Profile.class); table.write( rowKey, new Profile(profile.getName(), profile.getLabel(), profile.getDescription(), profile.getScope(), oldProfile == null ? ProfileStatus.ENABLED : oldProfile.getStatus(), profile.getProvisioner(), oldProfile == null ? profile.getCreatedTsSeconds() : oldProfile.getCreatedTsSeconds())); }