If, upon inspection or upon completion to the satisfaction of the department of all work that may be ordered, the department finds that the dam or reservoir is safe to impound water, a certificate of approval shall be issued. The owner of the dam or reservoir shall not, through action or inaction, cause the dam or reservoir to impound water following receipt by the owner of a written notice from the department that a certificate will not be issued because the dam or reservoir will not safely impound water. Before such notice is given by the department, the department shall hold a hearing. Written notice of the time and place of the hearing shall be mailed at least 20 days prior to the date set for the hearing, to the owner of the dam or reservoir. Any interested persons may appear at the hearing and present their views and objections to the proposed action. Any petition for a writ of mandate to inquire into the validity of the action of the department shall be commenced within 30 days after receipt by the owner of a written notice from the department that a certificate of approval will not be issued.