~ubuntu-branches/ubuntu/lucid/libstruts1.2-java/lucid

« back to all changes in this revision

Viewing changes to contrib/artimus/WEB-INF/src/java/org/apache/artimus/wizard/Store.java

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2006-04-24 12:14:23 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060424121423-naev53qigqgks0sa
Tags: 1.2.9-1
New upstream  release Fixes  three security  problems: CVE-2006-1546,
CVE-2006-1547,  CVE-2006-1548  (closes:  #360551),  thanks  to  Moritz
Muehlenhoff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * $Header: /home/cvs/jakarta-struts/contrib/artimus/WEB-INF/src/java/org/apache/artimus/wizard/Store.java,v 1.3 2004/03/14 07:15:06 sraeburn Exp $
3
 
 * $Revision: 1.3 $
4
 
 * $Date: 2004/03/14 07:15:06 $
5
 
 *
6
 
 * Copyright 2001-2004 The Apache Software Foundation.
7
 
 * 
8
 
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 
 * 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.apache.org/licenses/LICENSE-2.0
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
 
 
21
 
package org.apache.artimus.wizard;
22
 
 
23
 
import java.sql.SQLException;
24
 
 
25
 
import org.apache.scaffold.lang.Tokens;
26
 
import org.apache.scaffold.model.ModelBeanBase;
27
 
import org.apache.scaffold.model.ModelException;
28
 
import org.apache.scaffold.model.ModelResult;
29
 
import org.apache.scaffold.model.ModelResultBase;
30
 
 
31
 
import org.apache.artimus.lang.Messages;
32
 
 
33
 
 
34
 
/**
35
 
 * Insert or update an article.
36
 
 * @version $Revision: 1.3 $ $Date: 2004/03/14 07:15:06 $
37
 
 */
38
 
public class Store extends Bean {
39
 
 
40
 
    // ------------------------------------------------------------ Public Methods
41
 
 
42
 
 
43
 
    /**
44
 
     * Allocate next key for article table.
45
 
     * @return key to use for insertion
46
 
     * @exception SQLException if SQL error occurs
47
 
     */
48
 
    public void allocateKey() throws ModelException {
49
 
 
50
 
        setWizard(Model.allocateKey());
51
 
    }
52
 
 
53
 
 
54
 
    /**
55
 
     * Insert <code>key</code> record.
56
 
     * @returns Number of records inserted.
57
 
     */
58
 
    public void insert() throws ModelException {
59
 
 
60
 
        Model.insert(
61
 
                getId(),
62
 
                getDate(),
63
 
                getAmount(),
64
 
                getCheck(),
65
 
                getPhone(),
66
 
                getZip(),
67
 
                getEmail(),
68
 
                getText(),
69
 
                getWizard()
70
 
        );
71
 
 
72
 
    }
73
 
 
74
 
 
75
 
    /**
76
 
     * Update <code>key</code> record.
77
 
     * @returns Number of records updated.
78
 
     */
79
 
    public void update() throws ModelException {
80
 
 
81
 
        Model.update(
82
 
                getId(),
83
 
                getDate(),
84
 
                getAmount(),
85
 
                getCheck(),
86
 
                getPhone(),
87
 
                getZip(),
88
 
                getEmail(),
89
 
                getText(),
90
 
                getWizard()
91
 
        );
92
 
 
93
 
    }
94
 
 
95
 
 
96
 
    /**
97
 
     * Execute model for this bean, and return outcome in ModelResult.
98
 
     * @exception Collects and returns any Exceptions
99
 
     * @returns Null on success, or a collection of Exceptions
100
 
     */
101
 
    public ModelResult execute(Object source, Object target)
102
 
            throws ModelException {
103
 
 
104
 
        ModelResult modelResult = new ModelResultBase();
105
 
 
106
 
        if (isBlank(getKey())) {
107
 
            allocateKey();
108
 
            insert();
109
 
            modelResult.addMessage(Tokens.DATA_RECORD_INSERTED);
110
 
        }
111
 
        else {
112
 
            update();
113
 
            modelResult.addMessage(Tokens.DATA_RECORD_UPDATED);
114
 
        }
115
 
        modelResult.addMessage(getKey());
116
 
 
117
 
        modelResult.add(target);
118
 
        return modelResult;
119
 
    }
120
 
 
121
 
 }