You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by gr...@apache.org on 2004/03/20 12:47:01 UTC

cvs commit: cocoon-lenya/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring NewBlogEntryCreator.java

gregor      2004/03/20 03:47:01

  Modified:    src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring
                        NewBlogEntryCreator.java
  Log:
  ASL 2.0
  removed use of DateUtil (thanks to Dale Christ)
  
  Revision  Changes    Path
  1.4       +37 -54    cocoon-lenya/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/NewBlogEntryCreator.java
  
  Index: NewBlogEntryCreator.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/webapp/lenya/pubs/blog/java/src/org/apache/lenya/cms/authoring/NewBlogEntryCreator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- NewBlogEntryCreator.java	13 Nov 2003 16:17:53 -0000	1.3
  +++ NewBlogEntryCreator.java	20 Mar 2004 11:47:01 -0000	1.4
  @@ -1,45 +1,22 @@
   /*
  - * <License>
  - * The Apache Software License
  + * Copyright  1999-2004 The Apache Software Foundation
    *
  - * Copyright (c) 2002 lenya. All rights reserved.
  + *  Licensed under the Apache License, Version 2.0 (the "License");
  + *  you may not use this file except in compliance with the License.
  + *  You may obtain a copy of the License at
  + *
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + *
  + *  Unless required by applicable law or agreed to in writing, software
  + *  distributed under the License is distributed on an "AS IS" BASIS,
  + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + *  See the License for the specific language governing permissions and
  + *  limitations under the License.
    *
  - * Redistribution and use in source and binary forms, with or without modification,
  - * are permitted provided that the following conditions are met:
  - *
  - * 1. Redistributions of source code must retain the above copyright notice, this
  - *    list of conditions and the following disclaimer.
  - *
  - * 2. Redistributions in binary form must reproduce the above copyright notice, this
  - *    list of conditions and the following disclaimer in the documentation and/or
  - *    other materials provided with the distribution.
  - *
  - * 3. All advertising materials mentioning features or use of this software must
  - *    display the following acknowledgment: "This product includes software developed
  - *    by lenya (http://cocoon.apache.org/lenya/)"
  - *
  - * 4. The name "lenya" must not be used to endorse or promote products derived from
  - *    this software without prior written permission. For written permission, please
  - *    contact board@apache.org
  - *
  - * 5. Products derived from this software may not be called "lenya" nor may "lenya"
  - *    appear in their names without prior written permission of lenya.
  - *
  - * 6. Redistributions of any form whatsoever must retain the following acknowledgment:
  - *    "This product includes software developed by lenya (http://cocoon.apache.org/lenya/)"
  - *
  - * THIS SOFTWARE IS PROVIDED BY lenya "AS IS" WITHOUT ANY WARRANTY EXPRESS OR IMPLIED,
  - * INCLUDING THE WARRANTY OF NON-INFRINGEMENT AND THE IMPLIED WARRANTIES OF MERCHANTI-
  - * BILITY AND FITNESS FOR A PARTICULAR PURPOSE. lenya WILL NOT BE LIABLE FOR ANY DAMAGES
  - * SUFFERED BY YOU AS A RESULT OF USING THIS SOFTWARE. IN NO EVENT WILL lenya BE LIABLE
  - * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR LOST PROFITS EVEN IF lenya HAS
  - * BEEN ADVISED OF THE POSSIBILITY OF THEIR OCCURRENCE. lenya WILL NOT BE LIABLE FOR ANY
  - * THIRD PARTY CLAIMS AGAINST YOU.
  - *
  - * Lenya includes software developed by the Apache Software Foundation, W3C,
  - * DOM4J Project, BitfluxEditor and Xopus.
  - * </License>
    */
  +
  +/* $Id$  */
  +
   package org.apache.lenya.cms.authoring;
   
   import org.apache.log4j.Category;
  @@ -50,24 +27,22 @@
   
   import org.apache.lenya.ac.Identity;
   import org.apache.lenya.xml.DOMUtil;
  -import org.apache.lenya.util.DateUtil;
   
   import java.io.File;
  +import java.text.DateFormat;
  +import java.text.SimpleDateFormat;
   import java.util.Calendar;
   import java.util.GregorianCalendar;
   import java.util.Map;
  +import java.util.Date;
   
  -
  -/**
  - * @author Michael Wechner
  - * @version $Id$
  - */
   public class NewBlogEntryCreator extends DefaultBranchCreator {
       private static Category log = Category.getInstance(NewBlogEntryCreator.class);
   
       private String year;
       private String month;
       private String day;
  +    private Date date;
   
       /**
        *
  @@ -75,10 +50,14 @@
       public void init(Configuration conf) {
           super.init(conf);
   
  -        Calendar cal = new GregorianCalendar();
  -        year = Integer.toString(cal.get(Calendar.YEAR));
  -        month = DateUtil.oneToTwoDigits(Integer.toString(cal.get(Calendar.MONTH) + 1));
  -        day = DateUtil.oneToTwoDigits(Integer.toString(cal.get(Calendar.DAY_OF_MONTH)));
  +        DateFormat fmtyyyy = new SimpleDateFormat("yyyy");
  +        DateFormat fmtMM = new SimpleDateFormat("MM");
  +        DateFormat fmtdd = new SimpleDateFormat("dd");
  +        date = new Date();
  +
  +        year = fmtyyyy.format(date);
  +        month = fmtMM.format(date);
  +        day = fmtdd.format(date);
   
           log.error(".init(): Initialize Creator: " + year + "/" + month + "/" + day);
       }
  @@ -95,14 +74,13 @@
       /**
        *
        */
  -    protected void transformXML (Document doc, String childId, short childType, String childName, Map parameters) throws Exception {
  +    protected void transformXML(Document doc, String childId, short childType, String childName, Map parameters) throws Exception {
           log.error(".transformXML(): " + childId);
           DOMUtil du = new DOMUtil();
   
           // Replace id
           du.setElementValue(doc, "/echo:entry/echo:id", year + "/" + month + "/" + day + "/" + childId);
   
  -
           // Replace title 
           du.setElementValue(doc, "/echo:entry/echo:title", (String)parameters.get("title"));
   
  @@ -111,9 +89,14 @@
           du.setElementValue(doc, "/echo:entry/echo:author/echo:name", identity.getUser().getId());
   
           // Replace date created (and issued and modified, FIXME: issued should be set during first time publishing, modified should be set during re-publishing)
  -        String date = org.apache.lenya.util.DateUtil.getCurrentDate();
  -        du.setElementValue(doc, "/echo:entry/echo:created", date);
  -        du.setElementValue(doc, "/echo:entry/echo:issued", date);
  -        du.setElementValue(doc, "/echo:entry/echo:modified", date);
  +        DateFormat datefmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
  +        DateFormat ofsfmt = new SimpleDateFormat("Z");
  +
  +        String dateofs = ofsfmt.format(date);
  +        String datestr = datefmt.format(date) + dateofs.substring(0, 3) + ":" dateofs.substring(3, 5);
  +
  +        du.setElementValue(doc, "/echo:entry/echo:created", datestr);
  +        du.setElementValue(doc, "/echo:entry/echo:issued", datestr);
  +        du.setElementValue(doc, "/echo:entry/echo:modified", datestr);
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org