+ end
+
+ ##
+ # Reopen a note
+ def reopen
+ # Check the arguments are sane
+ fail OSM::APIBadUserInput.new("No id was given") unless params[:id]
+
+ # Extract the arguments
+ id = params[:id].to_i
+ comment = params[:text]
+
+ # Find the note and check it is valid
+ @note = Note.find_by_id(id)
+ fail OSM::APINotFoundError unless @note
+ fail OSM::APIAlreadyDeletedError.new("note", @note.id) unless @note.visible? || @user.moderator?
+ fail OSM::APINoteAlreadyOpenError.new(@note) unless @note.closed? || !@note.visible?
+
+ # Reopen the note and add a comment
+ Note.transaction do
+ @note.reopen
+
+ add_comment(@note, comment, "reopened")
+ end
+
+ # Return a copy of the updated note
+ respond_to do |format|
+ format.xml { render :action => :show }
+ format.json { render :action => :show }
+ end
+ end