bug 8477: introducing logic to update a SO from private to public

staut 8477: resolved fixed
This commit is contained in:
abhishek 2011-02-08 10:12:56 -08:00
parent deadcd54af
commit dcdb276295
2 changed files with 18 additions and 4 deletions

View File

@ -39,11 +39,14 @@ public class UpdateServiceOfferingCmd extends BaseCmd {
@Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="the display text of the service offering to be updated")
private String displayText;
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the service offering to be updated")
private Long id;
@Parameter(name=ApiConstants.IS_PUBLIC, type=CommandType.BOOLEAN, description="if the service offering needs to be made public , we can only go from private to public and not vice versa")
private Boolean isPublic;
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the service offering to be updated")
private String serviceOfferingName;
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the service offering to be updated")
private Long id;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -61,7 +64,9 @@ public class UpdateServiceOfferingCmd extends BaseCmd {
return serviceOfferingName;
}
public Boolean getIsPublic() {
return isPublic;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////

View File

@ -1304,7 +1304,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
Long id = cmd.getId();
String name = cmd.getServiceOfferingName();
Long userId = UserContext.current().getCallerUserId();
Boolean isPublic = cmd.getIsPublic();
if (userId == null) {
userId = Long.valueOf(User.UID_SYSTEM);
}
@ -1316,6 +1317,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
}
boolean updateNeeded = (name != null || displayText != null);
if(isPublic != null && isPublic)
updateNeeded = true;
if (!updateNeeded) {
return _serviceOfferingDao.findById(id);
}
@ -1329,6 +1334,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
if (displayText != null) {
offering.setDisplayText(displayText);
}
if(isPublic != null && isPublic) {
offering.setDomainId(null);
}
//Note: tag editing commented out for now; keeping the code intact, might need to re-enable in next releases
// if (tags != null)