Source Code Cross Referenced for BasicRightsAssignment.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » content » tool » 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 » ERP CRM Financial » sakai » org.sakaiproject.content.tool 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /**********************************************************************************
0002:         * $URL: https://source.sakaiproject.org/svn/content/tags/sakai_2-4-1/content-tool/tool/src/java/org/sakaiproject/content/tool/BasicRightsAssignment.java $
0003:         * $Id: BasicRightsAssignment.java 10179 2006-06-05 04:31:14Z jimeng@umich.edu $
0004:         ***********************************************************************************
0005:         *
0006:         * Copyright (c) 2006 The Sakai Foundation.
0007:         * 
0008:         * Licensed under the Educational Community License, Version 1.0 (the "License"); 
0009:         * you may not use this file except in compliance with the License. 
0010:         * You may obtain a copy of the License at
0011:         * 
0012:         *      http://www.opensource.org/licenses/ecl1.php
0013:         * 
0014:         * Unless required by applicable law or agreed to in writing, software 
0015:         * distributed under the License is distributed on an "AS IS" BASIS, 
0016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
0017:         * See the License for the specific language governing permissions and 
0018:         * limitations under the License.
0019:         *
0020:         **********************************************************************************/package org.sakaiproject.content.tool;
0021:
0022:        import java.util.Arrays;
0023:        import java.util.Hashtable;
0024:        import java.util.List;
0025:        import java.util.Map;
0026:        import java.util.Stack;
0027:        import java.util.Vector;
0028:
0029:        import org.sakaiproject.entity.api.EntityPropertyNotDefinedException;
0030:        import org.sakaiproject.entity.api.EntityPropertyTypeException;
0031:        import org.sakaiproject.entity.api.ResourceProperties;
0032:        import org.sakaiproject.entity.api.ResourcePropertiesEdit;
0033:        import org.sakaiproject.time.cover.TimeService;
0034:        import org.sakaiproject.user.cover.UserDirectoryService;
0035:        import org.sakaiproject.util.ParameterParser;
0036:        import org.sakaiproject.util.ResourceLoader;
0037:        import org.w3c.dom.Document;
0038:        import org.w3c.dom.Element;
0039:
0040:        /**
0041:         * BasicRightsAssignment can be used to represent a copyright or CreativeCommons designation for a resource.
0042:         * It can be serialized as XML and recreated.  It can be rendered through a Velocity macro or a JSF widget.
0043:         * 
0044:         * TAG
0045:         * KEY
0046:         * KEYLIST
0047:         * LABEL
0048:         */
0049:        public class BasicRightsAssignment {
0050:            /** Resource bundle using current language locale */
0051:            private static ResourceLoader rb = new ResourceLoader("right");
0052:
0053:            public class RightsChoice {
0054:                protected String id;
0055:                protected String renderAs;
0056:                protected String label;
0057:                protected List options;
0058:                protected Map optionMapping;
0059:                protected String moreInfoUrl;
0060:                protected String moreInfoTitle;
0061:                protected String moreInfoText;
0062:
0063:                public RightsChoice(String id, String label, String renderAs,
0064:                        List options, Map optionsMapping) {
0065:                    this .id = id;
0066:                    this .label = label;
0067:                    this .renderAs = renderAs;
0068:                    this .options = new Vector(options);
0069:                    this .optionMapping = new Hashtable(optionMapping);
0070:                }
0071:
0072:                public String getId() {
0073:                    return id;
0074:                }
0075:
0076:                public void setId(String id) {
0077:                    this .id = id;
0078:                }
0079:
0080:                public String getLabel() {
0081:                    return label;
0082:                }
0083:
0084:                public void setLabel(String label) {
0085:                    this .label = label;
0086:                }
0087:
0088:                public String getMoreInfoTitle() {
0089:                    return moreInfoTitle;
0090:                }
0091:
0092:                public void setMoreInfoTitle(String moreInfoLabel) {
0093:                    this .moreInfoTitle = moreInfoLabel;
0094:                }
0095:
0096:                public String getMoreInfoText() {
0097:                    return moreInfoText;
0098:                }
0099:
0100:                public void setMoreInfoText(String moreInfoText) {
0101:                    this .moreInfoText = moreInfoText;
0102:                }
0103:
0104:                public String getMoreInfoUrl() {
0105:                    return moreInfoUrl;
0106:                }
0107:
0108:                public void setMoreInfoUrl(String moreInfoUrl) {
0109:                    this .moreInfoUrl = moreInfoUrl;
0110:                }
0111:
0112:                public Map getOptionMapping() {
0113:                    return optionMapping;
0114:                }
0115:
0116:                public void setOptionMapping(Map optionMapping) {
0117:                    this .optionMapping = optionMapping;
0118:                }
0119:
0120:                public List getOptions() {
0121:                    return options;
0122:                }
0123:
0124:                public void setOptions(List options) {
0125:                    this .options = options;
0126:                }
0127:
0128:                public String getRenderAs() {
0129:                    return renderAs;
0130:                }
0131:
0132:                public void setRenderAs(String renderAs) {
0133:                    this .renderAs = renderAs;
0134:                }
0135:            }
0136:
0137:            public class RightsOption {
0138:                protected String id;
0139:                protected String label;
0140:                protected String moreInfoUrl;
0141:                protected String moreInfoTitle;
0142:                protected String moreInfoText;
0143:
0144:                public RightsOption(String id, String label) {
0145:                    this .id = id;
0146:                    this .label = label;
0147:                }
0148:
0149:                public String getId() {
0150:                    return id;
0151:                }
0152:
0153:                public void setId(String id) {
0154:                    this .id = id;
0155:                }
0156:
0157:                public String getLabel() {
0158:                    return label;
0159:                }
0160:
0161:                public void setLabel(String label) {
0162:                    this .label = label;
0163:                }
0164:
0165:                public String getMoreInfoTitle() {
0166:                    return moreInfoTitle;
0167:                }
0168:
0169:                public void setMoreInfoTitle(String moreInfoLabel) {
0170:                    this .moreInfoTitle = moreInfoLabel;
0171:                }
0172:
0173:                public String getMoreInfoText() {
0174:                    return moreInfoText;
0175:                }
0176:
0177:                public void setMoreInfoText(String moreInfoText) {
0178:                    this .moreInfoText = moreInfoText;
0179:                }
0180:
0181:                public String getMoreInfoUrl() {
0182:                    return moreInfoUrl;
0183:                }
0184:
0185:                public void setMoreInfoUrl(String moreInfoUrl) {
0186:                    this .moreInfoUrl = moreInfoUrl;
0187:                }
0188:
0189:            }
0190:
0191:            protected static final String RENDER_AS_TEXT_INPUT = "text";
0192:            protected static final String RENDER_AS_RADIO_BUTTONS = "radio";
0193:            protected static final String RENDER_AS_TEXTAREA = "textarea";
0194:            protected static final String RENDER_AS_SELECT = "select";
0195:            protected static final String RENDER_AS_DATE_INPUT = "date";
0196:            protected static final String RENDER_AS_CHECKBOX = "checkbox";
0197:            protected static final String RENDER_AS_CHECKBOXES = "checkboxes";
0198:
0199:            protected String[] user = { UserDirectoryService.getCurrentUser()
0200:                    .getDisplayName() };
0201:
0202:            /*
0203:            status.label						= Who owns the rights to this material?
0204:            status.unknown					= Copyright status is not yet determined.
0205:            status.other						= Someone else holds the copyright on this material.
0206:            status.mine						= I hold the copyright on this material.
0207:            status.public_domain				= This material is in the public domain.
0208:
0209:
0210:             */
0211:
0212:            protected static final String USING_CREATIVE_COMMONS = "usingCreativeCommons";
0213:
0214:            protected static final String PD_URL = "http://creativecommons.org/license/publicdomain";
0215:
0216:            protected static final String DELIM = "_";
0217:
0218:            protected static final String FIELD_COMMERCIAL_USE = "myCommercialUse";
0219:
0220:            protected static final String FIELD_DONE = "done";
0221:
0222:            protected static final String FIELD_INFO = "jargon";
0223:
0224:            protected static final String FIELD_MODIFICATIONS = "myModifications";
0225:
0226:            protected static final String FIELD_MORE_INFO = "moreinfo";
0227:
0228:            protected static final String FIELD_MY_CR_OWNER = "myCopyrightOwner";
0229:
0230:            protected static final String FIELD_MY_CR_YEAR = "myCopyrightYear";
0231:
0232:            protected static final String FIELD_OFFER = "offer";
0233:
0234:            protected static final String FIELD_OTHER_OFFER = "otherOffer";
0235:
0236:            protected static final String FIELD_OTHER_COMMERCIAL_USE = "otherCommercialUse";
0237:
0238:            protected static final String FIELD_OTHER_CR_OWNER = "otherCopyrightOwner";
0239:
0240:            protected static final String FIELD_OTHER_CR_YEAR = "otherCopyrightYear";
0241:
0242:            protected static final String FIELD_OTHER_MODIFICATIONS = "otherModifications";
0243:
0244:            protected static final String FIELD_TERMS = "terms";
0245:
0246:            protected static final String FIELD_TITLE = "title";
0247:
0248:            protected static final String KEY_CREATE_CC = "new_creative_commons";
0249:
0250:            protected static final String KEY_CREATE_PD = "new_public_domain";
0251:
0252:            protected static final String KEY_CREATIVE_COMMONS = "creative_commons";
0253:
0254:            protected static final String KEY_FAIR_USE = "fair_use";
0255:
0256:            protected static final String KEY_LABEL = "label";
0257:
0258:            protected static final String KEY_MY_COPYRIGHT = "my_copyright";
0259:
0260:            protected static final String KEY_NO = "no";
0261:
0262:            protected static final String KEY_OTHER_COPYRIGHT = "other_copyright";
0263:
0264:            protected static final String KEY_PUBLIC_DOMAIN = "public_domain";
0265:
0266:            protected static final String KEY_SHARE_ALIKE = "share_alike";
0267:
0268:            protected static final String KEY_YES = "yes";
0269:
0270:            protected static final String[] KEYLIST_TERMS = { KEY_MY_COPYRIGHT,
0271:                    KEY_OTHER_COPYRIGHT, KEY_PUBLIC_DOMAIN };
0272:
0273:            protected String ccCommercialUse;
0274:
0275:            protected String ccModifications;
0276:
0277:            /** Member variable representing the name of the copyright holder (copyright holder is this user) */
0278:            protected String myCopyrightOwner;
0279:
0280:            /** Member variable representing the year of the copyright (copyright holder is this user) */
0281:            protected String myCopyrightYear;
0282:
0283:            /** A unique identifier that can be used in form fields to distinguish this rights obj from others in the same form */
0284:            protected String name;
0285:
0286:            /** Member variable representing user's secondary choice of how their work is offered to users (full copyright, new CC license, new PD dedication) */
0287:            protected String offer;
0288:
0289:            protected String otherCommercialUse;
0290:
0291:            /** Member variable representing the name of the copyright holder (copyright holder is NOT this user) */
0292:            protected String otherCopyrightOwner;
0293:
0294:            /** Member variable representing the year of the copyright (copyright holder is NOT this user) */
0295:            protected String otherCopyrightYear;
0296:
0297:            protected String otherModifications;
0298:
0299:            /** Member variable representing the status of IP rights for this work (user's copyright, someone else's copyright, existing CC license or existing PD status) */
0300:            protected String terms;
0301:
0302:            /** Member variable representing whether we using the new Creative Commons dialog or the old Sakai Copyright dialog */
0303:            protected boolean usingCreativeCommons;
0304:
0305:            /**
0306:             * Construct
0307:             * @param name A name for this instance that can be used as a unique identifier in rendering a set of form fields 
0308:             * 	to input values for this object. Should not contain characters that are not valid in id's and names of html
0309:             * 	form-input elements.
0310:             * @param usingCreativeCommons true if the Creative Commons License should be shown as an option.
0311:             */
0312:            public BasicRightsAssignment(String name,
0313:                    boolean usingCreativeCommons) {
0314:                this .name = name;
0315:                this .usingCreativeCommons = usingCreativeCommons;
0316:
0317:                //terms = KEY_MY_COPYRIGHT;
0318:                //terms = KEY_OTHER_COPYRIGHT;
0319:                //offer = KEY_CREATE_CC;
0320:            }
0321:
0322:            /**
0323:             * Construct from info in XML in a DOM element.
0324:             * 
0325:             * @param el
0326:             *        The XML DOM element.
0327:             */
0328:            public BasicRightsAssignment(Element el) {
0329:                String usingCC = el.getAttribute(USING_CREATIVE_COMMONS);
0330:                this .usingCreativeCommons = Boolean.TRUE.toString().equals(
0331:                        usingCC);
0332:                this .terms = el.getAttribute(FIELD_TERMS);
0333:                if (this .terms == null) {
0334:
0335:                } else if (KEY_MY_COPYRIGHT.equals(terms)) {
0336:                    this .myCopyrightYear = el.getAttribute(FIELD_MY_CR_YEAR);
0337:                    this .myCopyrightOwner = el.getAttribute(FIELD_MY_CR_OWNER);
0338:                    this .offer = el.getAttribute(FIELD_OFFER);
0339:                    if (KEY_FAIR_USE.equals(offer)) {
0340:
0341:                    } else if (KEY_CREATE_CC.equals(offer)) {
0342:                        ccModifications = el.getAttribute(FIELD_MODIFICATIONS);
0343:                        ccCommercialUse = el.getAttribute(FIELD_COMMERCIAL_USE);
0344:                    } else if (KEY_CREATE_PD.equals(offer)) {
0345:
0346:                    }
0347:                } else if (KEY_OTHER_COPYRIGHT.equals(terms)) {
0348:                    otherCopyrightYear = el.getAttribute(FIELD_OTHER_CR_YEAR);
0349:                    otherCopyrightOwner = el.getAttribute(FIELD_OTHER_CR_OWNER);
0350:                } else if (KEY_CREATIVE_COMMONS.equals(terms)) {
0351:                    otherModifications = el
0352:                            .getAttribute(FIELD_OTHER_MODIFICATIONS);
0353:                    otherCommercialUse = el
0354:                            .getAttribute(FIELD_OTHER_COMMERCIAL_USE);
0355:                }
0356:
0357:            } // BasicRightsAssignment
0358:
0359:            /**
0360:             * Construct from info in ResourceProperties.
0361:             * 
0362:             * @param properties
0363:             *        
0364:             */
0365:            public BasicRightsAssignment(String name,
0366:                    ResourceProperties properties) {
0367:                this .name = name;
0368:                try {
0369:                    this .usingCreativeCommons = properties
0370:                            .getBooleanProperty(USING_CREATIVE_COMMONS);
0371:                } catch (Exception e) {
0372:                    this .usingCreativeCommons = false;
0373:                }
0374:
0375:                this .terms = properties.getProperty(FIELD_TERMS);
0376:                if (this .terms == null) {
0377:                    this .terms = KEY_OTHER_COPYRIGHT;
0378:                } else if (KEY_MY_COPYRIGHT.equals(terms)) {
0379:                    this .myCopyrightYear = properties
0380:                            .getProperty(FIELD_MY_CR_YEAR);
0381:                    this .myCopyrightOwner = properties
0382:                            .getProperty(FIELD_MY_CR_OWNER);
0383:                    this .offer = properties.getProperty(FIELD_OFFER);
0384:                    if (KEY_FAIR_USE.equals(offer)) {
0385:
0386:                    } else if (KEY_CREATE_CC.equals(offer)) {
0387:                        ccModifications = properties
0388:                                .getProperty(FIELD_MODIFICATIONS);
0389:                        ccCommercialUse = properties
0390:                                .getProperty(FIELD_COMMERCIAL_USE);
0391:                    } else if (KEY_CREATE_PD.equals(offer)) {
0392:
0393:                    }
0394:                } else if (KEY_OTHER_COPYRIGHT.equals(terms)) {
0395:                    otherCopyrightYear = properties
0396:                            .getProperty(FIELD_OTHER_CR_YEAR);
0397:                    otherCopyrightOwner = properties
0398:                            .getProperty(FIELD_OTHER_CR_OWNER);
0399:                } else if (KEY_CREATIVE_COMMONS.equals(terms)) {
0400:                    otherModifications = properties
0401:                            .getProperty(FIELD_OTHER_MODIFICATIONS);
0402:                    otherCommercialUse = properties
0403:                            .getProperty(FIELD_OTHER_COMMERCIAL_USE);
0404:                }
0405:
0406:            } // BasicRightsAssignment
0407:
0408:            /**
0409:             * Retrieve values for the rights assignment from a Velocity context.
0410:             * @param params 
0411:             */
0412:            public void captureValues(ParameterParser params) {
0413:                if (usingCreativeCommons) {
0414:                    String terms = params.getString(getFieldNameTerms());
0415:                    if (terms != null) {
0416:                        this .setTerms(terms);
0417:                    }
0418:                    String myCopyrightYear = params
0419:                            .getString(getFieldNameMyCopyrightYear());
0420:                    if (myCopyrightYear != null) {
0421:                        this .setMyCopyrightYear(myCopyrightYear);
0422:                    }
0423:                    String myCopyrightOwner = params
0424:                            .getString(getFieldNameMyCopyrightOwner());
0425:                    if (myCopyrightOwner != null) {
0426:                        this .setMyCopyrightOwner(myCopyrightOwner);
0427:                    }
0428:                    String otherCopyrightYear = params
0429:                            .getString(getFieldNameOtherCopyrightYear());
0430:                    if (otherCopyrightYear != null) {
0431:                        this .setOtherCopyrightYear(otherCopyrightYear);
0432:                    }
0433:                    String otherCopyrightOwner = params
0434:                            .getString(getFieldNameOtherCopyrightOwner());
0435:                    if (otherCopyrightOwner != null) {
0436:                        this .setOtherCopyrightOwner(otherCopyrightOwner);
0437:                    }
0438:                    String offer = params.getString(getFieldNameOffer());
0439:                    if (offer != null) {
0440:                        this .setOffer(offer);
0441:                    }
0442:                    String ccModifcations = params
0443:                            .getString(getFieldNameModifications());
0444:                    if (ccModifications != null) {
0445:                        this .setCcModifications(ccModifications);
0446:                    }
0447:                    String otherModifcations = params
0448:                            .getString(getFieldNameOtherModifications());
0449:                    if (otherModifications != null) {
0450:                        this .setOtherModifications(otherModifications);
0451:                    }
0452:                    String ccCommercialUse = params
0453:                            .getString(getFieldNameCommercialUse());
0454:                    if (ccCommercialUse != null) {
0455:                        this .setCcCommercialUse(ccCommercialUse);
0456:                    }
0457:                    String otherCommercialUse = params
0458:                            .getString(getFieldNameOtherCommercialUse());
0459:                    if (otherCommercialUse != null) {
0460:                        this .setOtherCommercialUse(otherCommercialUse);
0461:                    }
0462:                } else {
0463:                }
0464:            }
0465:
0466:            /**
0467:             * @return Returns the ccCommercialUse.
0468:             */
0469:            public String getCcCommercialUse() {
0470:                return ccCommercialUse;
0471:            }
0472:
0473:            /**
0474:             * @return Returns the ccModifications.
0475:             */
0476:            public String getCcModifications() {
0477:                return ccModifications;
0478:            }
0479:
0480:            /** 
0481:             * Access the current user's display name.
0482:             * @return
0483:             */
0484:            public String getDefaultCopyrightOwner() {
0485:                String username = UserDirectoryService.getCurrentUser()
0486:                        .getDisplayName();
0487:                return username;
0488:            }
0489:
0490:            /**
0491:             * Returns the current year.
0492:             * @return
0493:             */
0494:            public String getDefaultCopyrightYear() {
0495:                int year = TimeService.newTime().breakdownLocal().getYear();
0496:                return Integer.toString(year);
0497:
0498:            }
0499:
0500:            public String getFieldNameCommercialUse() {
0501:                return name + DELIM + FIELD_COMMERCIAL_USE;
0502:            }
0503:
0504:            public String getFieldNameModifications() {
0505:                return name + DELIM + FIELD_MODIFICATIONS;
0506:            }
0507:
0508:            /**
0509:             * Returns the field name for the copyright "owner" element.
0510:             */
0511:            public String getFieldNameMyCopyrightOwner() {
0512:                return name + DELIM + FIELD_MY_CR_OWNER;
0513:            }
0514:
0515:            /**
0516:             * Returns the field name for the copyright "year" element.
0517:             */
0518:            public String getFieldNameMyCopyrightYear() {
0519:                return name + DELIM + FIELD_MY_CR_YEAR;
0520:            }
0521:
0522:            /**
0523:             * Returns the field name for the copyright "year" element.
0524:             */
0525:            public String getFieldNameOffer() {
0526:                return name + DELIM + FIELD_OFFER;
0527:            }
0528:
0529:            public String getFieldNameOtherCommercialUse() {
0530:                return name + DELIM + FIELD_OTHER_COMMERCIAL_USE;
0531:            }
0532:
0533:            /**
0534:             * Returns the field name for the copyright "owner" element.
0535:             */
0536:            public String getFieldNameOtherCopyrightOwner() {
0537:                return name + DELIM + FIELD_OTHER_CR_OWNER;
0538:            }
0539:
0540:            /**
0541:             * Returns the field name for the copyright "year" element.
0542:             */
0543:            public String getFieldNameOtherCopyrightYear() {
0544:                return name + DELIM + FIELD_OTHER_CR_YEAR;
0545:            }
0546:
0547:            public String getFieldNameOtherModifications() {
0548:                return name + DELIM + FIELD_OTHER_MODIFICATIONS;
0549:            }
0550:
0551:            /**
0552:             * Returns the field name for the "terms" element.
0553:             */
0554:            public String getFieldNameTerms() {
0555:                return name + DELIM + FIELD_TERMS;
0556:            }
0557:
0558:            /**
0559:             * 
0560:             * @return
0561:             */
0562:            public String getInfoCreativeCommons() {
0563:                return getString(FIELD_INFO, KEY_CREATIVE_COMMONS);
0564:            }
0565:
0566:            /**
0567:             * 
0568:             * @return
0569:             */
0570:            public String getInfoMyCopyright() {
0571:                return getString(FIELD_INFO, KEY_MY_COPYRIGHT);
0572:            }
0573:
0574:            /**
0575:             * 
0576:             * @return
0577:             */
0578:            public String getInfoOtherCopyright() {
0579:                return getString(FIELD_INFO, KEY_OTHER_COPYRIGHT);
0580:            }
0581:
0582:            /**
0583:             * 
0584:             * @return
0585:             */
0586:            public String getInfoPublicDomain() {
0587:                return getString(FIELD_INFO, KEY_PUBLIC_DOMAIN);
0588:            }
0589:
0590:            /**
0591:             * 
0592:             * @return
0593:             */
0594:            public String getKeyCreativeCommons() {
0595:                return KEY_CREATIVE_COMMONS;
0596:            }
0597:
0598:            /**
0599:             * 
0600:             * @return
0601:             */
0602:            public String getKeyFairUse() {
0603:                return KEY_FAIR_USE;
0604:            }
0605:
0606:            public List getKeylistTerms() {
0607:                return getKeys(KEYLIST_TERMS);
0608:            }
0609:
0610:            /**
0611:             * 
0612:             * @return
0613:             */
0614:            public String getKeyMyCopyright() {
0615:                return KEY_MY_COPYRIGHT;
0616:            }
0617:
0618:            /**
0619:             * 
0620:             * @return
0621:             */
0622:            public String getKeyNewCreativeCommons() {
0623:                return KEY_CREATE_CC;
0624:            }
0625:
0626:            /**
0627:             * 
0628:             * @return
0629:             */
0630:            public String getKeyNewPublicDomain() {
0631:                return KEY_CREATE_PD;
0632:            }
0633:
0634:            /**
0635:             * 
0636:             * @return
0637:             */
0638:            public String getKeyNo() {
0639:                return KEY_NO;
0640:            }
0641:
0642:            /**
0643:             * 
0644:             * @return
0645:             */
0646:            public String getKeyOtherCopyright() {
0647:                return KEY_OTHER_COPYRIGHT;
0648:            }
0649:
0650:            /**
0651:             * 
0652:             * @return
0653:             */
0654:            public String getKeyPublicDomain() {
0655:                return KEY_PUBLIC_DOMAIN;
0656:            }
0657:
0658:            /**
0659:             * Return a list of keys.
0660:             * @param array An array of strings containing the keys.
0661:             */
0662:            protected List getKeys(String[] array) {
0663:                return Arrays.asList(array);
0664:            }
0665:
0666:            /**
0667:             * 
0668:             * @return
0669:             */
0670:            public String getKeyShareAlike() {
0671:                return KEY_SHARE_ALIKE;
0672:            }
0673:
0674:            /**
0675:             * 
0676:             * @return
0677:             */
0678:            public String getKeyYes() {
0679:                return KEY_YES;
0680:            }
0681:
0682:            public String getLabelCommercialUse() {
0683:                return getString(FIELD_COMMERCIAL_USE, KEY_LABEL);
0684:            }
0685:
0686:            public String getLabelCommercialUseNo() {
0687:                return getString(FIELD_COMMERCIAL_USE, KEY_NO);
0688:            }
0689:
0690:            public String getLabelCommercialUseYes() {
0691:                return getString(FIELD_COMMERCIAL_USE, KEY_YES);
0692:            }
0693:
0694:            public String getLabelDone() {
0695:                return getString(FIELD_DONE, KEY_LABEL);
0696:            }
0697:
0698:            /**
0699:             * 
0700:             * @return
0701:             */
0702:            public String getLabelFairUse() {
0703:                return getString(FIELD_OFFER, KEY_FAIR_USE);
0704:            }
0705:
0706:            public String getLabelModifications() {
0707:                return getString(FIELD_MODIFICATIONS, KEY_LABEL);
0708:            }
0709:
0710:            public String getLabelModificationsNo() {
0711:                return getString(FIELD_MODIFICATIONS, KEY_NO);
0712:            }
0713:
0714:            public String getLabelModificationsShareAlike() {
0715:                return getString(FIELD_MODIFICATIONS, KEY_SHARE_ALIKE);
0716:            }
0717:
0718:            public String getLabelModificationsYes() {
0719:                return getString(FIELD_MODIFICATIONS, KEY_YES);
0720:            }
0721:
0722:            public String getLabelMoreInfo() {
0723:                return getString(FIELD_MORE_INFO, KEY_LABEL);
0724:            }
0725:
0726:            /**
0727:             * 
0728:             * @return
0729:             */
0730:            public String getLabelMyCopyrightOwner() {
0731:                return getString(FIELD_MY_CR_OWNER, KEY_LABEL);
0732:            }
0733:
0734:            /**
0735:             * 
0736:             * @return
0737:             */
0738:            public String getLabelMyCopyrightYear() {
0739:                return getString(FIELD_MY_CR_YEAR, KEY_LABEL);
0740:            }
0741:
0742:            /**
0743:             * 
0744:             * @return
0745:             */
0746:            public String getLabelNewCreativeCommons() {
0747:                return getString(FIELD_OFFER, KEY_CREATE_CC);
0748:            }
0749:
0750:            /**
0751:             * 
0752:             * @return
0753:             */
0754:            public String getLabelNewPublicDomain() {
0755:                return getString(FIELD_OFFER, KEY_CREATE_PD);
0756:            }
0757:
0758:            public String getLabelOtherCommercialUse() {
0759:                return getString(FIELD_OTHER_COMMERCIAL_USE, KEY_LABEL);
0760:            }
0761:
0762:            public String getLabelOtherCommercialUseNo() {
0763:                return getString(FIELD_OTHER_COMMERCIAL_USE, KEY_NO);
0764:            }
0765:
0766:            public String getLabelOtherCommercialUseYes() {
0767:                return getString(FIELD_OTHER_COMMERCIAL_USE, KEY_YES);
0768:            }
0769:
0770:            /**
0771:             * 
0772:             * @return
0773:             */
0774:            public String getLabelOtherCopyrightOwner() {
0775:                return getString(FIELD_OTHER_CR_OWNER, KEY_LABEL);
0776:            }
0777:
0778:            /**
0779:             * 
0780:             * @return
0781:             */
0782:            public String getLabelOtherCopyrightYear() {
0783:                return getString(FIELD_OTHER_CR_YEAR, KEY_LABEL);
0784:            }
0785:
0786:            public String getLabelOtherModifications() {
0787:                return getString(FIELD_OTHER_MODIFICATIONS, KEY_LABEL);
0788:            }
0789:
0790:            public String getLabelOtherModificationsNo() {
0791:                return getString(FIELD_OTHER_MODIFICATIONS, KEY_NO);
0792:            }
0793:
0794:            public String getLabelOtherModificationsShareAlike() {
0795:                return getString(FIELD_OTHER_MODIFICATIONS, KEY_SHARE_ALIKE);
0796:            }
0797:
0798:            public String getLabelOtherModificationsYes() {
0799:                return getString(FIELD_OTHER_MODIFICATIONS, KEY_YES);
0800:            }
0801:
0802:            protected List getLabels(String[] array) {
0803:                List list = new Vector();
0804:                for (int i = 0; i < array.length; i++) {
0805:                    String label = rb.getString(array[i]);
0806:                    list.add(label);
0807:                }
0808:                return list;
0809:            }
0810:
0811:            /**
0812:             * 
0813:             * @return
0814:             */
0815:            public String getLabelTerms() {
0816:                return getString(FIELD_TERMS, KEY_LABEL);
0817:            }
0818:
0819:            /**
0820:             * @return Returns the copyrightOwner.
0821:             */
0822:            public String getMyCopyrightOwner() {
0823:                return myCopyrightOwner;
0824:            }
0825:
0826:            /**
0827:             * @return Returns the copyrightYear.
0828:             */
0829:            public String getMyCopyrightYear() {
0830:                return myCopyrightYear;
0831:            }
0832:
0833:            /**
0834:             * @return Returns the name.
0835:             */
0836:            public String getName() {
0837:                return name;
0838:            }
0839:
0840:            /**
0841:             * @return Returns the offer.
0842:             */
0843:            public String getOffer() {
0844:                return offer;
0845:            }
0846:
0847:            /**
0848:             * @return Returns the ccCommercialUse.
0849:             */
0850:            public String getOtherCommercialUse() {
0851:                return otherCommercialUse;
0852:            }
0853:
0854:            /**
0855:             * @return Returns the otherCopyrightOwner.
0856:             */
0857:            public String getOtherCopyrightOwner() {
0858:                return otherCopyrightOwner;
0859:            }
0860:
0861:            /**
0862:             * @return Returns the otherCopyrightYear.
0863:             */
0864:            public String getOtherCopyrightYear() {
0865:                return otherCopyrightYear;
0866:            }
0867:
0868:            /**
0869:             * @return Returns the ccModifications.
0870:             */
0871:            public String getOtherModifications() {
0872:                return otherModifications;
0873:            }
0874:
0875:            /**
0876:             * Access a string from the resource bundle identified by a key. 
0877:             * @param key
0878:             * @return
0879:             */
0880:            public String getString(String key) {
0881:                return rb.getString(key);
0882:            }
0883:
0884:            /**
0885:             * Access a string from the resource bundle identified by a key. 
0886:             * @param key
0887:             * @return
0888:             */
0889:            public String getString(String category, String item) {
0890:                return getString(category + "." + item);
0891:            }
0892:
0893:            /**
0894:             * 
0895:             * @param key
0896:             * @return
0897:             */
0898:            public String[] getStrings(String key) {
0899:                return rb.getStrings(key);
0900:            }
0901:
0902:            /**
0903:             * @return Returns the terms.
0904:             */
0905:            public String getTerms() {
0906:                return terms;
0907:            }
0908:
0909:            /**
0910:             * 
0911:             * @return
0912:             */
0913:            public String getTitleCreativeCommons() {
0914:                return getString(FIELD_TITLE, KEY_CREATIVE_COMMONS);
0915:            }
0916:
0917:            /**
0918:             * 
0919:             * @return
0920:             */
0921:            public String getTitleMyCopyright() {
0922:                return getString(FIELD_TITLE, KEY_MY_COPYRIGHT);
0923:            }
0924:
0925:            /**
0926:             * 
0927:             * @return
0928:             */
0929:            public String getTitleOtherCopyright() {
0930:                return getString(FIELD_TITLE, KEY_OTHER_COPYRIGHT);
0931:            }
0932:
0933:            /**
0934:             * 
0935:             * @return
0936:             */
0937:            public String getTitlePublicDomain() {
0938:                return getString(FIELD_TITLE, KEY_PUBLIC_DOMAIN);
0939:            }
0940:
0941:            /**
0942:             * @return Returns the usingCreativeCommons.
0943:             */
0944:            public boolean getUsingCreativeCommons() {
0945:                return usingCreativeCommons;
0946:            }
0947:
0948:            /**
0949:             * @param ccCommercialUse The ccCommercialUse to set.
0950:             */
0951:            public void setCcCommercialUse(String ccCommercialUse) {
0952:                this .ccCommercialUse = ccCommercialUse;
0953:            }
0954:
0955:            /**
0956:             * @param ccModifications The ccModifications to set.
0957:             */
0958:            public void setCcModifications(String ccModifications) {
0959:                this .ccModifications = ccModifications;
0960:            }
0961:
0962:            /**
0963:             * @param copyrightOwner The copyrightOwner to set.
0964:             */
0965:            public void setMyCopyrightOwner(String copyrightOwner) {
0966:                this .myCopyrightOwner = copyrightOwner;
0967:            }
0968:
0969:            /**
0970:             * @param copyrightYear The copyrightYear to set.
0971:             */
0972:            public void setMyCopyrightYear(String copyrightYear) {
0973:                this .myCopyrightYear = copyrightYear;
0974:            }
0975:
0976:            /**
0977:             * @param name The name to set.
0978:             */
0979:            public void setName(String name) {
0980:                this .name = name;
0981:            }
0982:
0983:            /**
0984:             * @param offer The offer to set.
0985:             */
0986:            public void setOffer(String offer) {
0987:                this .offer = offer;
0988:            }
0989:
0990:            /**
0991:             * @param ccCommercialUse The ccCommercialUse to set.
0992:             */
0993:            public void setOtherCommercialUse(String otherCommercialUse) {
0994:                this .otherCommercialUse = otherCommercialUse;
0995:            }
0996:
0997:            /**
0998:             * @param otherCopyrightOwner The otherCopyrightOwner to set.
0999:             */
1000:            public void setOtherCopyrightOwner(String otherCopyrightOwner) {
1001:                this .otherCopyrightOwner = otherCopyrightOwner;
1002:            }
1003:
1004:            /**
1005:             * @param otherCopyrightYear The otherCopyrightYear to set.
1006:             */
1007:            public void setOtherCopyrightYear(String otherCopyrightYear) {
1008:                this .otherCopyrightYear = otherCopyrightYear;
1009:            }
1010:
1011:            /**
1012:             * @param otherModifications The otherModifications to set.
1013:             */
1014:            public void setOtherModifications(String otherModifications) {
1015:                this .otherModifications = otherModifications;
1016:            }
1017:
1018:            /**
1019:             * @param terms The terms to set.
1020:             */
1021:            public void setTerms(String terms) {
1022:                this .terms = terms;
1023:            }
1024:
1025:            /**
1026:             * @param usingCreativeCommons The usingCreativeCommons to set.
1027:             */
1028:            public void setUsingCreativeCommons(boolean usingCreativeCommons) {
1029:                this .usingCreativeCommons = usingCreativeCommons;
1030:            }
1031:
1032:            /**
1033:             * Serialize the rights-assignment into XML, adding an element to the doc under the top of the stack element.
1034:             * 
1035:             * @param doc
1036:             *        The DOM doc to contain the XML (or null for a string return).
1037:             * @param stack
1038:             *        The DOM elements, the top of which is the containing element of the new "rightsAssignment" element.
1039:             * @return The newly added element.
1040:             */
1041:            public Element toXml(Document doc, Stack stack) {
1042:                Element rightsAssignment = doc
1043:                        .createElement("rightsAssignment");
1044:
1045:                if (stack.isEmpty()) {
1046:                    doc.appendChild(rightsAssignment);
1047:                } else {
1048:                    ((Element) stack.peek()).appendChild(rightsAssignment);
1049:                }
1050:
1051:                stack.push(rightsAssignment);
1052:
1053:                if (usingCreativeCommons) {
1054:                    rightsAssignment.setAttribute(USING_CREATIVE_COMMONS,
1055:                            "true");
1056:                } else {
1057:                    rightsAssignment.setAttribute(USING_CREATIVE_COMMONS,
1058:                            "false");
1059:                }
1060:
1061:                rightsAssignment.setAttribute(FIELD_TERMS, terms);
1062:                if (KEY_MY_COPYRIGHT.equals(terms)) {
1063:                    rightsAssignment.setAttribute(FIELD_MY_CR_YEAR,
1064:                            myCopyrightYear);
1065:                    rightsAssignment.setAttribute(FIELD_MY_CR_OWNER,
1066:                            myCopyrightOwner);
1067:                    rightsAssignment.setAttribute(FIELD_OFFER, offer);
1068:                    if (KEY_FAIR_USE.equals(offer)) {
1069:
1070:                    } else if (KEY_CREATE_CC.equals(offer)) {
1071:                        rightsAssignment.setAttribute(FIELD_MODIFICATIONS,
1072:                                ccModifications);
1073:                        rightsAssignment.setAttribute(FIELD_COMMERCIAL_USE,
1074:                                ccCommercialUse);
1075:                    } else if (KEY_CREATE_PD.equals(offer)) {
1076:
1077:                    }
1078:                } else if (KEY_OTHER_COPYRIGHT.equals(terms)) {
1079:                    rightsAssignment.setAttribute(FIELD_OTHER_CR_YEAR,
1080:                            otherCopyrightYear);
1081:                    rightsAssignment.setAttribute(FIELD_OTHER_CR_OWNER,
1082:                            otherCopyrightOwner);
1083:                } else if (KEY_CREATIVE_COMMONS.equals(terms)) {
1084:                    rightsAssignment.setAttribute(FIELD_OTHER_MODIFICATIONS,
1085:                            otherModifications);
1086:                    rightsAssignment.setAttribute(FIELD_OTHER_COMMERCIAL_USE,
1087:                            otherCommercialUse);
1088:                }
1089:
1090:                stack.pop();
1091:
1092:                return rightsAssignment;
1093:
1094:            } // toXml
1095:
1096:            /**
1097:             * .
1098:             * 
1099:             * @param properties
1100:             *
1101:             */
1102:            public void addResourceProperties(ResourcePropertiesEdit properties) {
1103:                properties.removeProperty(FIELD_TERMS);
1104:                properties.removeProperty(FIELD_MY_CR_YEAR);
1105:                properties.removeProperty(FIELD_MY_CR_OWNER);
1106:                properties.removeProperty(FIELD_OFFER);
1107:                properties.removeProperty(FIELD_MODIFICATIONS);
1108:                properties.removeProperty(FIELD_COMMERCIAL_USE);
1109:                properties.removeProperty(FIELD_OTHER_CR_YEAR);
1110:                properties.removeProperty(FIELD_OTHER_CR_OWNER);
1111:                properties.removeProperty(FIELD_OTHER_MODIFICATIONS);
1112:                properties.removeProperty(FIELD_OTHER_COMMERCIAL_USE);
1113:                properties.addProperty(FIELD_TERMS, terms);
1114:                properties.addProperty(USING_CREATIVE_COMMONS, Boolean
1115:                        .toString(usingCreativeCommons));
1116:                if (KEY_MY_COPYRIGHT.equals(terms)) {
1117:                    properties.addProperty(FIELD_MY_CR_YEAR, myCopyrightYear);
1118:                    properties.addProperty(FIELD_MY_CR_OWNER, myCopyrightOwner);
1119:                    properties.addProperty(FIELD_OFFER, offer);
1120:                    if (KEY_FAIR_USE.equals(offer)) {
1121:
1122:                    } else if (KEY_CREATE_CC.equals(offer)) {
1123:                        properties.addProperty(FIELD_MODIFICATIONS,
1124:                                ccModifications);
1125:                        properties.addProperty(FIELD_COMMERCIAL_USE,
1126:                                ccCommercialUse);
1127:                    } else if (KEY_CREATE_PD.equals(offer)) {
1128:
1129:                    }
1130:                } else if (KEY_OTHER_COPYRIGHT.equals(terms)) {
1131:                    properties.addProperty(FIELD_OTHER_CR_YEAR,
1132:                            otherCopyrightYear);
1133:                    properties.addProperty(FIELD_OTHER_CR_OWNER,
1134:                            otherCopyrightOwner);
1135:                } else if (KEY_CREATIVE_COMMONS.equals(terms)) {
1136:                    properties.addProperty(FIELD_OTHER_MODIFICATIONS,
1137:                            otherModifications);
1138:                    properties.addProperty(FIELD_OTHER_COMMERCIAL_USE,
1139:                            otherCommercialUse);
1140:                }
1141:
1142:            } // addResourceProperties
1143:
1144:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.