001: /*
002: * CCLicensePage.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:
045: import org.apache.cocoon.environment.ObjectModelHelper;
046: import org.apache.cocoon.environment.Request;
047: import org.dspace.app.xmlui.utils.UIException;
048: import org.dspace.app.xmlui.aspect.submission.AbstractSubmissionStep;
049: import org.dspace.app.xmlui.wing.Message;
050: import org.dspace.app.xmlui.wing.WingException;
051: import org.dspace.app.xmlui.wing.element.Body;
052: import org.dspace.app.xmlui.wing.element.Division;
053: import org.dspace.app.xmlui.wing.element.List;
054: import org.dspace.app.xmlui.wing.element.Para;
055: import org.dspace.authorize.AuthorizeException;
056: import org.dspace.content.Collection;
057: import org.dspace.content.Item;
058: import org.dspace.license.CreativeCommons;
059: import org.xml.sax.SAXException;
060:
061: /**
062: * This is an optional page of the item submission processes. The Creative
063: * Commons license may be added to an item in addition to the standard distribution
064: * license. This step will allow the user to go off to the creative commons website
065: * select a license and then when returned view what license was added to the item.
066: * <P>
067: * This class is called by org.dspace.app.xmlui.submission.step.LicenseStep
068: * when the Creative Commons license is enabled
069: * <P>
070: * The form is divided into three major divisions: 1) A global div surrounds the
071: * whole page, 2) a specific interactive div displays the button that goes off to the
072: * creative commons website to select a license, and 3) a local division that displays
073: * the selected license and standard action bar.
074: *
075: * @author Scott Phillips
076: * @author Tim Donohue (updated for Configurable Submission)
077: */
078: public class CCLicenseStep extends AbstractSubmissionStep {
079: /** Language Strings **/
080: protected static final Message T_head = message("xmlui.Submission.submit.CCLicenseStep.head");
081: protected static final Message T_info1 = message("xmlui.Submission.submit.CCLicenseStep.info1");
082: protected static final Message T_submit_to_creative_commons = message("xmlui.Submission.submit.CCLicenseStep.submit_to_creative_commons");
083: protected static final Message T_license = message("xmlui.Submission.submit.CCLicenseStep.license");
084: protected static final Message T_submit_remove = message("xmlui.Submission.submit.CCLicenseStep.submit_remove");
085: protected static final Message T_no_license = message("xmlui.Submission.submit.CCLicenseStep.no_license");
086:
087: /**
088: * The creative commons URL, where to send the user off to so that they can select a license.
089: */
090: public final static String CREATIVE_COMMONS_URL = "http://creativecommons.org/license/";
091:
092: /**
093: * Establish our required parameters, abstractStep will enforce these.
094: */
095: public CCLicenseStep() {
096: this .requireSubmission = true;
097: this .requireStep = true;
098: }
099:
100: public void addBody(Body body) throws SAXException, WingException,
101: UIException, SQLException, IOException, AuthorizeException {
102: // Build the url to and from creative commons
103: Item item = submission.getItem();
104: Collection collection = submission.getCollection();
105: String actionURL = contextPath + "/handle/"
106: + collection.getHandle() + "/submit";
107:
108: Request request = ObjectModelHelper.getRequest(objectModel);
109: boolean https = request.isSecure();
110: String server = request.getServerName();
111: int port = request.getServerPort();
112:
113: String exitURL = (https) ? "https://" : "http://";
114: exitURL += server;
115: if (!(port == 80 || port == 443))
116: exitURL += ":" + port;
117:
118: exitURL += actionURL + "?submission-continue=" + knot.getId()
119: + "&cc_license_url=[license_url]";
120:
121: // Division 1:
122: // Global division
123: Division div = body.addDivision("submit-cclicense",
124: "primary submission");
125: div.setHead(T_submission_head);
126:
127: // Division 2:
128: //Progress bar division
129: Division progressDiv = div.addInteractiveDivision(
130: "submit-cclicense-progress", actionURL,
131: Division.METHOD_POST);
132: addSubmissionProgressList(progressDiv);
133: //need 'submission-continue' in order to keep current state
134: progressDiv.addHidden("submission-continue").setValue(
135: knot.getId());
136:
137: // Division 3:
138: // Creative commons offsite division
139: Division offsiteDiv = div.addInteractiveDivision(
140: "submit-cclicense-offsite", CREATIVE_COMMONS_URL,
141: Division.METHOD_POST);
142: offsiteDiv.setHead(T_head);
143: offsiteDiv.addPara(T_info1);
144:
145: offsiteDiv.addHidden("submission-continue").setValue(
146: knot.getId());
147: offsiteDiv.addHidden("partner").setValue("dspace");
148: offsiteDiv.addHidden("exit_url").setValue(exitURL);
149:
150: Para ccPara = offsiteDiv.addPara("creative-commons-button",
151: "creative-commons-button");
152: ccPara.addButton("submit_to_creative_commons").setValue(
153: T_submit_to_creative_commons);
154:
155: // Division 4:
156: // Local onsite division
157: Division onsiteDiv = div.addInteractiveDivision(
158: "submit-cclicense-offsite", actionURL,
159: Division.METHOD_POST);
160: List form = onsiteDiv.addList("submit-review", List.TYPE_FORM);
161:
162: form.addLabel(T_license);
163: if (CreativeCommons.hasLicense(context, item)) {
164: String url = CreativeCommons.getLicenseURL(item);
165: form.addItem().addXref(url, url);
166:
167: form.addItem().addButton("submit_no_cc").setValue(
168: T_submit_remove);
169: form.addItem().addHidden("cc_license_url").setValue(url);
170: } else {
171: form.addItem().addHighlight("italic").addContent(
172: T_no_license);
173: }
174:
175: // add standard control/paging buttons
176: addControlButtons(form);
177:
178: onsiteDiv.addHidden("submission-continue").setValue(
179: knot.getId());
180: }
181:
182: /**
183: * Each submission step must define its own information to be reviewed
184: * during the final Review/Verify Step in the submission process.
185: * <P>
186: * The information to review should be tacked onto the passed in
187: * List object.
188: * <P>
189: * NOTE: To remain consistent across all Steps, you should first
190: * add a sub-List object (with this step's name as the heading),
191: * by using a call to reviewList.addList(). This sublist is
192: * the list you return from this method!
193: *
194: * @param reviewList
195: * The List to which all reviewable information should be added
196: * @return
197: * The new sub-List object created by this step, which contains
198: * all the reviewable information. If this step has nothing to
199: * review, then return null!
200: */
201: public List addReviewSection(List reviewList) throws SAXException,
202: WingException, UIException, SQLException, IOException,
203: AuthorizeException {
204: //nothing to review for CC License step
205: return null;
206: }
207:
208: /**
209: * Recycle
210: */
211: public void recycle() {
212: super.recycle();
213: }
214: }
|