Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
rhbz912583 relax requirement for non-null project type on put project
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmason committed Feb 21, 2013
1 parent 8b81728 commit abfd586
Showing 1 changed file with 25 additions and 17 deletions.
Expand Up @@ -221,23 +221,28 @@ else if (Objects.equal(hProject.getStatus(), READONLY))
response = Response.ok();
}

if (project.getDefaultType() == null || project.getDefaultType().isEmpty())
// null project type accepted for compatibility with old clients
if (project.getDefaultType() != null)
{
return Response.status(Status.BAD_REQUEST)
.entity("No valid default project type was specified.")
.build();
}
try
{
ProjectType.getValueOf(project.getDefaultType());
}
catch (Exception e)
{
String validTypes = StringUtils.join(ProjectType.values(), ", ");
return Response.status(Status.BAD_REQUEST)
.entity("Project type \"" + project.getDefaultType() + "\" not valid for this server." +
" Valid types: [" + validTypes + "]")
.build();
if (project.getDefaultType().isEmpty())
{
return Response.status(Status.BAD_REQUEST)
.entity("No valid default project type was specified.")
.build();
}

try
{
ProjectType.getValueOf(project.getDefaultType());
}
catch (Exception e)
{
String validTypes = StringUtils.join(ProjectType.values(), ", ");
return Response.status(Status.BAD_REQUEST)
.entity("Project type \"" + project.getDefaultType() + "\" not valid for this server." +
" Valid types: [" + validTypes + "]")
.build();
}
}

transfer(project, hProject);
Expand All @@ -264,7 +269,10 @@ public static void transfer(Project from, HProject to)
{
to.setName(from.getName());
to.setDescription(from.getDescription());
to.setDefaultProjectType(ProjectType.valueOf(from.getDefaultType()));
if (from.getDefaultType() != null)
{
to.setDefaultProjectType(ProjectType.valueOf(from.getDefaultType()));
}
// TODO Currently all Projects are created as Current
// to.setStatus(from.getStatus());

Expand Down

0 comments on commit abfd586

Please sign in to comment.