01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/metaobj/tags/sakai_2-4-1/metaobj-util/tool-lib/src/java/org/sakaiproject/metaobj/shared/control/StructuredArtifactValidator.java $
03: * $Id: StructuredArtifactValidator.java 17619 2006-10-31 00:55:55Z john.ellis@rsmart.com $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.metaobj.shared.control;
21:
22: import org.sakaiproject.metaobj.shared.model.ElementBean;
23: import org.sakaiproject.metaobj.shared.model.StructuredArtifact;
24: import org.springframework.validation.Errors;
25:
26: /**
27: * Created by IntelliJ IDEA.
28: * User: John Ellis
29: * Date: May 19, 2004
30: * Time: 3:31:16 PM
31: * To change this template use File | Settings | File Templates.
32: */
33: public class StructuredArtifactValidator extends XmlValidator {
34:
35: public boolean supports(Class clazz) {
36: if (super .supports(clazz)) {
37: return true;
38: }
39: return (StructuredArtifact.class.isAssignableFrom(clazz));
40: }
41:
42: public void validate(Object obj, Errors errors) {
43: validateInternal(obj, errors);
44: super .validate(obj, errors);
45: }
46:
47: protected void validateInternal(Object obj, Errors errors) {
48: if (obj instanceof StructuredArtifact) {
49: StructuredArtifact artifact = (StructuredArtifact) obj;
50:
51: if (artifact.getDisplayName() == null
52: || artifact.getDisplayName().length() == 0) {
53: errors.rejectValue("displayName", "required value {0}",
54: new Object[] { "displayName" },
55: "required value displayName");
56: }
57: }
58: }
59:
60: public void validate(Object obj, Errors errors,
61: boolean checkListNumbers) {
62: validateInternal(obj, errors);
63: super.validate(obj, errors, checkListNumbers);
64: }
65:
66: }
|