Source Code Cross Referenced for UploadStep.java in  » Content-Management-System » dspace » org » dspace » app » xmlui » aspect » submission » submit » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » dspace » org.dspace.app.xmlui.aspect.submission.submit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * UploadStep.java
003:         *
004:         * Version: $Revision: 1.4 $
005:         *
006:         * Date: $Date: 2006/07/13 23:20:54 $
007:         *
008:         * Copyright (c) 2002, Hewlett-Packard Company and Massachusetts
009:         * Institute of Technology.  All rights reserved.
010:         *
011:         * Redistribution and use in source and binary forms, with or without
012:         * modification, are permitted provided that the following conditions are
013:         * met:
014:         *
015:         * - Redistributions of source code must retain the above copyright
016:         * notice, this list of conditions and the following disclaimer.
017:         *
018:         * - Redistributions in binary form must reproduce the above copyright
019:         * notice, this list of conditions and the following disclaimer in the
020:         * documentation and/or other materials provided with the distribution.
021:         *
022:         * - Neither the name of the Hewlett-Packard Company nor the name of the
023:         * Massachusetts Institute of Technology nor the names of their
024:         * contributors may be used to endorse or promote products derived from
025:         * this software without specific prior written permission.
026:         *
027:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
028:         * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
029:         * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
030:         * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
031:         * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
032:         * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
033:         * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
034:         * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
035:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
036:         * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
037:         * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
038:         * DAMAGE.
039:         */
040:        package org.dspace.app.xmlui.aspect.submission.submit;
041:
042:        import java.io.IOException;
043:        import java.sql.SQLException;
044:        import java.util.Map;
045:
046:        import org.apache.avalon.framework.parameters.Parameters;
047:        import org.apache.cocoon.ProcessingException;
048:        import org.apache.cocoon.environment.SourceResolver;
049:        import org.apache.log4j.Logger;
050:        import org.dspace.app.xmlui.utils.UIException;
051:        import org.dspace.app.xmlui.aspect.submission.AbstractSubmissionStep;
052:        import org.dspace.app.xmlui.wing.Message;
053:        import org.dspace.app.xmlui.wing.WingException;
054:        import org.dspace.app.xmlui.wing.element.Body;
055:        import org.dspace.app.xmlui.wing.element.Button;
056:        import org.dspace.app.xmlui.wing.element.Cell;
057:        import org.dspace.app.xmlui.wing.element.CheckBox;
058:        import org.dspace.app.xmlui.wing.element.Division;
059:        import org.dspace.app.xmlui.wing.element.File;
060:        import org.dspace.app.xmlui.wing.element.List;
061:        import org.dspace.app.xmlui.wing.element.Row;
062:        import org.dspace.app.xmlui.wing.element.Table;
063:        import org.dspace.app.xmlui.wing.element.Text;
064:        import org.dspace.authorize.AuthorizeException;
065:        import org.dspace.content.Bitstream;
066:        import org.dspace.content.BitstreamFormat;
067:        import org.dspace.content.Bundle;
068:        import org.dspace.content.Collection;
069:        import org.dspace.content.Item;
070:        import org.dspace.workflow.WorkflowItem;
071:        import org.xml.sax.SAXException;
072:
073:        /**
074:         * This is a step of the item submission processes. The upload
075:         * stages allows the user to upload files into the submission. The
076:         * form is optimized for one file, but allows the user to upload
077:         * more if needed.
078:         * <P>
079:         * The form is brokenup into three sections:
080:         * <P>
081:         * Part A: Ask the user to upload a file
082:         * Part B: List previously uploaded files
083:         * Part C: The standard action bar
084:         * 
085:         * @author Scott Phillips
086:         * @author Tim Donohue (updated for Configurable Submission)
087:         */
088:        public class UploadStep extends AbstractSubmissionStep {
089:            private static Logger log = Logger.getLogger(UploadStep.class);
090:
091:            /** Language Strings for Uploading **/
092:            protected static final Message T_head = message("xmlui.Submission.submit.UploadStep.head");
093:            protected static final Message T_file = message("xmlui.Submission.submit.UploadStep.file");
094:            protected static final Message T_file_help = message("xmlui.Submission.submit.UploadStep.file_help");
095:            protected static final Message T_file_error = message("xmlui.Submission.submit.UploadStep.file_error");
096:            protected static final Message T_description = message("xmlui.Submission.submit.UploadStep.description");
097:            protected static final Message T_description_help = message("xmlui.Submission.submit.UploadStep.description_help");
098:            protected static final Message T_submit_upload = message("xmlui.Submission.submit.UploadStep.submit_upload");
099:            protected static final Message T_head2 = message("xmlui.Submission.submit.UploadStep.head2");
100:            protected static final Message T_column1 = message("xmlui.Submission.submit.UploadStep.column1");
101:            protected static final Message T_column2 = message("xmlui.Submission.submit.UploadStep.column2");
102:            protected static final Message T_column3 = message("xmlui.Submission.submit.UploadStep.column3");
103:            protected static final Message T_column4 = message("xmlui.Submission.submit.UploadStep.column4");
104:            protected static final Message T_column5 = message("xmlui.Submission.submit.UploadStep.column5");
105:            protected static final Message T_column6 = message("xmlui.Submission.submit.UploadStep.column6");
106:            protected static final Message T_unknown_name = message("xmlui.Submission.submit.UploadStep.unknown_name");
107:            protected static final Message T_unknown_format = message("xmlui.Submission.submit.UploadStep.unknown_format");
108:            protected static final Message T_supported = message("xmlui.Submission.submit.UploadStep.supported");
109:            protected static final Message T_known = message("xmlui.Submission.submit.UploadStep.known");
110:            protected static final Message T_unsupported = message("xmlui.Submission.submit.UploadStep.unsupported");
111:            protected static final Message T_submit_edit = message("xmlui.Submission.submit.UploadStep.submit_edit");
112:            protected static final Message T_checksum = message("xmlui.Submission.submit.UploadStep.checksum");
113:            protected static final Message T_submit_remove = message("xmlui.Submission.submit.UploadStep.submit_remove");
114:
115:            /** 
116:             * Global reference to edit file page
117:             * (this is used when a user requests to edit a bitstream)
118:             **/
119:            private EditFileStep editFile = null;
120:
121:            /**
122:             * Establish our required parameters, abstractStep will enforce these.
123:             */
124:            public UploadStep() {
125:                this .requireSubmission = true;
126:                this .requireStep = true;
127:            }
128:
129:            /**
130:             * Check if user has requested to edit information about an
131:             * uploaded file
132:             */
133:            public void setup(SourceResolver resolver, Map objectModel,
134:                    String src, Parameters parameters)
135:                    throws ProcessingException, SAXException, IOException {
136:                super .setup(resolver, objectModel, src, parameters);
137:
138:                //If this page for editing an uploaded file's information
139:                //was requested, then we need to load EditFileStep instead!
140:                if (this .errorFlag == org.dspace.submit.step.UploadStep.STATUS_EDIT_BITSTREAM) {
141:                    this .editFile = new EditFileStep();
142:                    this .editFile.setup(resolver, objectModel, src, parameters);
143:                } else
144:                    this .editFile = null;
145:            }
146:
147:            public void addBody(Body body) throws SAXException, WingException,
148:                    UIException, SQLException, IOException, AuthorizeException {
149:                //If we are actually editing an uploaded file's information,
150:                //then display that body instead!
151:                if (this .editFile != null) {
152:                    editFile.addBody(body);
153:                    return;
154:                }
155:
156:                // Get a list of all files in the original bundle
157:                Item item = submission.getItem();
158:                Collection collection = submission.getCollection();
159:                String actionURL = contextPath + "/handle/"
160:                        + collection.getHandle() + "/submit";
161:                boolean workflow = submission instanceof  WorkflowItem;
162:                Bundle[] bundles = item.getBundles("ORIGINAL");
163:                Bitstream[] bitstreams = new Bitstream[0];
164:                if (bundles.length > 0) {
165:                    bitstreams = bundles[0].getBitstreams();
166:                }
167:
168:                // Part A: 
169:                //  First ask the user if they would like to upload a new file (may be the first one)
170:                Division div = body.addInteractiveDivision("submit-upload",
171:                        actionURL, Division.METHOD_MULTIPART,
172:                        "primary submission");
173:                div.setHead(T_submission_head);
174:                addSubmissionProgressList(div);
175:
176:                List upload = null;
177:                if (!workflow) {
178:                    // Only add the upload capabilities for new item submissions
179:                    upload = div.addList("submit-upload-new", List.TYPE_FORM);
180:                    upload.setHead(T_head);
181:
182:                    File file = upload.addItem().addFile("file");
183:                    file.setLabel(T_file);
184:                    file.setHelp(T_file_help);
185:                    file.setRequired();
186:
187:                    //if no files found error was thrown by processing class, display it!
188:                    if (this .errorFlag == org.dspace.submit.step.UploadStep.STATUS_NO_FILES_ERROR)
189:                        file.addError(T_file_error);
190:
191:                    Text description = upload.addItem().addText("description");
192:                    description.setLabel(T_description);
193:                    description.setHelp(T_description_help);
194:
195:                    Button uploadSubmit = upload.addItem().addButton(
196:                            "submit_upload");
197:                    uploadSubmit.setValue(T_submit_upload);
198:                }
199:
200:                // Part B:
201:                //  If the user has allready uploaded files provide a list for the user.
202:                if (bitstreams.length > 0 || workflow) {
203:                    Table summary = div.addTable("submit-upload-summary",
204:                            (bitstreams.length * 2) + 2, 7);
205:                    summary.setHead(T_head2);
206:
207:                    Row header = summary.addRow(Row.ROLE_HEADER);
208:                    header.addCellContent(T_column1); // select checkbox
209:                    header.addCellContent(T_column2); // file name
210:                    header.addCellContent(T_column3); // size
211:                    header.addCellContent(T_column4); // description
212:                    header.addCellContent(T_column5); // format
213:                    header.addCellContent(T_column6); // edit button
214:
215:                    for (Bitstream bitstream : bitstreams) {
216:                        int id = bitstream.getID();
217:                        String name = bitstream.getName();
218:                        String url = contextPath + "/bitstream/item/"
219:                                + item.getID() + "/" + name;
220:                        long bytes = bitstream.getSize();
221:                        String desc = bitstream.getDescription();
222:                        String algorithm = bitstream.getChecksumAlgorithm();
223:                        String checksum = bitstream.getChecksum();
224:                        BitstreamFormat format = bitstream.getFormat();
225:                        int support = format.getSupportLevel();
226:
227:                        Row row = summary.addRow();
228:
229:                        if (!workflow) {
230:                            // Workflow users can not remove files.
231:                            CheckBox remove = row.addCell().addCheckBox(
232:                                    "remove");
233:                            remove.setLabel("remove");
234:                            remove.addOption(id);
235:                        } else {
236:                            row.addCell();
237:                        }
238:
239:                        row.addCell().addXref(url, name);
240:                        row.addCellContent(bytes + " bytes");
241:                        if (desc == null || desc.length() == 0)
242:                            row.addCellContent(T_unknown_name);
243:                        else
244:                            row.addCellContent(desc);
245:
246:                        if (format == null) {
247:                            row.addCellContent(T_unknown_format);
248:                        } else {
249:                            Cell cell = row.addCell();
250:                            cell.addContent(format.getMIMEType());
251:                            cell.addContent(" ");
252:                            switch (support) {
253:                            case 1:
254:                                cell.addContent(T_supported);
255:                                break;
256:                            case 2:
257:                                cell.addContent(T_known);
258:                                break;
259:                            case 3:
260:                                cell.addContent(T_unsupported);
261:                                break;
262:                            }
263:                        }
264:
265:                        Button edit = row.addCell().addButton(
266:                                "submit_edit_" + id);
267:                        edit.setValue(T_submit_edit);
268:
269:                        Row checksumRow = summary.addRow();
270:                        checksumRow.addCell();
271:                        Cell checksumCell = checksumRow.addCell(null, null, 0,
272:                                6, null);
273:                        checksumCell.addHighlight("bold")
274:                                .addContent(T_checksum);
275:                        checksumCell.addContent(" ");
276:                        checksumCell.addContent(algorithm + ":" + checksum);
277:                    }
278:
279:                    if (!workflow) {
280:                        // Workflow user's can not remove files.
281:                        Row actionRow = summary.addRow();
282:                        actionRow.addCell();
283:                        Button removeSeleceted = actionRow.addCell(null, null,
284:                                0, 6, null).addButton("submit_remove_selected");
285:                        removeSeleceted.setValue(T_submit_remove);
286:                    }
287:
288:                    upload = div.addList("submit-upload-new-part2",
289:                            List.TYPE_FORM);
290:                }
291:
292:                // Part C:
293:                // add standard control/paging buttons
294:                addControlButtons(upload);
295:
296:                div.addHidden("submission-continue").setValue(knot.getId());
297:
298:            }
299:
300:            /** 
301:             * Each submission step must define its own information to be reviewed
302:             * during the final Review/Verify Step in the submission process.
303:             * <P>
304:             * The information to review should be tacked onto the passed in 
305:             * List object.
306:             * <P>
307:             * NOTE: To remain consistent across all Steps, you should first
308:             * add a sub-List object (with this step's name as the heading),
309:             * by using a call to reviewList.addList().   This sublist is
310:             * the list you return from this method!
311:             * 
312:             * @param reviewList
313:             *      The List to which all reviewable information should be added
314:             * @return 
315:             *      The new sub-List object created by this step, which contains
316:             *      all the reviewable information.  If this step has nothing to
317:             *      review, then return null!   
318:             */
319:            public List addReviewSection(List reviewList) throws SAXException,
320:                    WingException, UIException, SQLException, IOException,
321:                    AuthorizeException {
322:                // Create a new list section for this step (and set its heading)
323:                List uploadSection = reviewList.addList("submit-review-"
324:                        + this .stepAndPage, List.TYPE_FORM);
325:                uploadSection.setHead(T_head);
326:
327:                //Review all uploaded files
328:                Bundle[] bundles = submission.getItem().getBundles("ORIGINAL");
329:                Bitstream[] bitstreams = new Bitstream[0];
330:                if (bundles.length > 0) {
331:                    bitstreams = bundles[0].getBitstreams();
332:                }
333:
334:                for (Bitstream bitstream : bitstreams) {
335:                    BitstreamFormat bitstreamFormat = bitstream.getFormat();
336:
337:                    int id = bitstream.getID();
338:                    String name = bitstream.getName();
339:                    String url = contextPath + "/retrieve/" + id + "/" + name;
340:                    String format = bitstreamFormat.getShortDescription();
341:                    Message support = ReviewStep.T_unknown;
342:                    if (bitstreamFormat.getSupportLevel() == BitstreamFormat.KNOWN)
343:                        support = T_known;
344:                    else if (bitstreamFormat.getSupportLevel() == BitstreamFormat.SUPPORTED)
345:                        support = T_supported;
346:
347:                    org.dspace.app.xmlui.wing.element.Item file = uploadSection
348:                            .addItem();
349:                    file.addXref(url, name);
350:                    file.addContent(" - " + format + " ");
351:                    file.addContent(support);
352:
353:                }
354:
355:                //return this new "upload" section
356:                return uploadSection;
357:            }
358:        }
ww_w___._j___a___v__a2__s_._c_o_m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.