From 21dfb7fec1a9a4ceaca18e17cc66ebd3393747c6 Mon Sep 17 00:00:00 2001 From: jensp Date: Thu, 12 Apr 2012 10:01:39 +0000 Subject: [PATCH] Notes testet jetzt den Bearbeitungsstatus (Ticket #119) git-svn-id: https://svn.libreccm.org/ccm/trunk@1587 8810af33-2d31-482b-a856-94f89814c4df --- .../cms/contentassets/ui/NotesDisplay.java | 188 +++++++++--------- .../cms/contentassets/ui/NotesStep.java | 1 + 2 files changed, 95 insertions(+), 94 deletions(-) diff --git a/ccm-cms-assets-notes/src/com/arsdigita/cms/contentassets/ui/NotesDisplay.java b/ccm-cms-assets-notes/src/com/arsdigita/cms/contentassets/ui/NotesDisplay.java index 26d0da876..5138624a2 100755 --- a/ccm-cms-assets-notes/src/com/arsdigita/cms/contentassets/ui/NotesDisplay.java +++ b/ccm-cms-assets-notes/src/com/arsdigita/cms/contentassets/ui/NotesDisplay.java @@ -1,19 +1,18 @@ /* -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public License -as published by the Free Software Foundation; either version 2.1 of -the License, or (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License + as published by the Free Software Foundation; either version 2.1 of + the License, or (at your option) any later version. -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ package com.arsdigita.cms.contentassets.ui; import com.arsdigita.bebop.PageState; @@ -31,133 +30,134 @@ import com.arsdigita.web.RedirectSignal; import com.arsdigita.xml.Element; import com.arsdigita.cms.contentassets.Note; +import com.arsdigita.cms.util.SecurityConstants; +import com.arsdigita.kernel.Kernel; +import com.arsdigita.kernel.User; +import com.arsdigita.workflow.simple.Workflow; import java.io.IOException; import org.apache.log4j.Logger; public class NotesDisplay extends SimpleComponent { - private static final Logger s_log = Logger.getLogger( NotesDisplay.class ); + private static final Logger s_log = Logger.getLogger(NotesDisplay.class); private static final String DELETE = "delete"; private static final String EDIT = "edit"; private static final String UP = "up"; private static final String DOWN = "down"; - private NotesStep m_step; private ACSObjectSelectionModel m_noteModel; - public NotesDisplay( NotesStep step, - ACSObjectSelectionModel noteModel ) { + public NotesDisplay(NotesStep step, + ACSObjectSelectionModel noteModel) { super(); m_step = step; m_noteModel = noteModel; } - public void respond( PageState ps ) { + public void respond(PageState ps) { String name = ps.getControlEventName(); String value = ps.getControlEventValue(); - if( s_log.isDebugEnabled() ) { - s_log.debug( "Action " + name + " on note " + value ); + if (s_log.isDebugEnabled()) { + s_log.debug("Action " + name + " on note " + value); } - OID oid = OID.valueOf( value ); - Note note = (Note) DomainObjectFactory.newInstance( oid ); + OID oid = OID.valueOf(value); + Note note = (Note) DomainObjectFactory.newInstance(oid); - if( DELETE.equals( name ) ) { + if (DELETE.equals(name)) { note.delete(); - } - - else if( EDIT.equals( name ) ) { - m_noteModel.setSelectedObject( ps, note ); - m_step.showComponent( ps, NotesStep.EDIT ); - } - - else if( UP.equals( name ) ) { - note.setRank( note.getRank() - 1 ); - } - - else if( DOWN.equals( name ) ) { - note.setRank( note.getRank() + 1 ); + } else if (EDIT.equals(name)) { + m_noteModel.setSelectedObject(ps, note); + m_step.showComponent(ps, NotesStep.EDIT); + } else if (UP.equals(name)) { + note.setRank(note.getRank() - 1); + } else if (DOWN.equals(name)) { + note.setRank(note.getRank() + 1); } ps.clearControlEvent(); try { - throw new RedirectSignal( ps.stateAsURL(), true ); - } catch( IOException ex ) { - throw new UncheckedWrapperException( ex ); + throw new RedirectSignal(ps.stateAsURL(), true); + } catch (IOException ex) { + throw new UncheckedWrapperException(ex); } } - public void generateXML( PageState ps, Element parent ) { - Element root = parent.newChildElement( "cms:notesDisplay", - CMS.CMS_XML_NS ); + public void generateXML(PageState ps, Element parent) { + Element root = parent.newChildElement("cms:notesDisplay", + CMS.CMS_XML_NS); - ContentItem item = m_step.getItem( ps ); - DataCollection notes = Note.getNotes( item ); + ContentItem item = m_step.getItem(ps); + DataCollection notes = Note.getNotes(item); - if( s_log.isDebugEnabled() ) { - s_log.debug( "NotesDisplay.generateXML" ); + if (s_log.isDebugEnabled()) { + s_log.debug("NotesDisplay.generateXML"); } - DomainObjectXMLRenderer xr = new DomainObjectXMLRenderer( root ); - xr.setWrapRoot( true ); - xr.setWrapAttributes( true ); - xr.setWrapObjects( true ); + DomainObjectXMLRenderer xr = new DomainObjectXMLRenderer(root); + xr.setWrapRoot(true); + xr.setWrapAttributes(true); + xr.setWrapObjects(true); - while( notes.next() ) { - Note note = new Note( notes.getDataObject() ); + while (notes.next()) { + Note note = new Note(notes.getDataObject()); String oid = note.getOID().toString(); + + if (CMS.getSecurityManager(ps).canAccess(ps.getRequest(), + SecurityConstants.EDIT_ITEM, + item)) { + Element edit = root.newChildElement("cms:notesAction", + CMS.CMS_XML_NS); + edit.addAttribute("action", EDIT); + edit.addAttribute("oid", oid); + ps.setControlEvent(this, EDIT, oid); + try { + edit.addAttribute("href", ps.stateAsURL()); + } catch (IOException ex) { + throw new UncheckedWrapperException(ex); + } - Element edit = root.newChildElement( "cms:notesAction", - CMS.CMS_XML_NS ); - edit.addAttribute( "action", EDIT ); - edit.addAttribute( "oid", oid ); - ps.setControlEvent( this, EDIT, oid ); - try { - edit.addAttribute( "href", ps.stateAsURL() ); - } catch( IOException ex ) { - throw new UncheckedWrapperException( ex ); - } + Element delete = root.newChildElement("cms:notesAction", + CMS.CMS_XML_NS); + delete.addAttribute("action", DELETE); + delete.addAttribute("oid", oid); + ps.setControlEvent(this, DELETE, oid); + try { + delete.addAttribute("href", ps.stateAsURL()); + } catch (IOException ex) { + throw new UncheckedWrapperException(ex); + } - Element delete = root.newChildElement( "cms:notesAction", - CMS.CMS_XML_NS ); - delete.addAttribute( "action", DELETE ); - delete.addAttribute( "oid", oid ); - ps.setControlEvent( this, DELETE, oid ); - try { - delete.addAttribute( "href", ps.stateAsURL() ); - } catch( IOException ex ) { - throw new UncheckedWrapperException( ex ); - } + Element up = root.newChildElement("cms:notesAction", + CMS.CMS_XML_NS); + up.addAttribute("action", UP); + up.addAttribute("oid", oid); + ps.setControlEvent(this, UP, oid); + try { + up.addAttribute("href", ps.stateAsURL()); + } catch (IOException ex) { + throw new UncheckedWrapperException(ex); + } - Element up = root.newChildElement( "cms:notesAction", - CMS.CMS_XML_NS ); - up.addAttribute( "action", UP ); - up.addAttribute( "oid", oid ); - ps.setControlEvent( this, UP, oid ); - try { - up.addAttribute( "href", ps.stateAsURL() ); - } catch( IOException ex ) { - throw new UncheckedWrapperException( ex ); - } - - Element down = root.newChildElement( "cms:notesAction", - CMS.CMS_XML_NS ); - down.addAttribute( "action", DOWN ); - down.addAttribute( "oid", oid ); - ps.setControlEvent( this, DOWN, oid ); - try { - down.addAttribute( "href", ps.stateAsURL() ); - } catch( IOException ex ) { - throw new UncheckedWrapperException( ex ); + Element down = root.newChildElement("cms:notesAction", + CMS.CMS_XML_NS); + down.addAttribute("action", DOWN); + down.addAttribute("oid", oid); + ps.setControlEvent(this, DOWN, oid); + try { + down.addAttribute("href", ps.stateAsURL()); + } catch (IOException ex) { + throw new UncheckedWrapperException(ex); + } } ps.clearControlEvent(); - - xr.walk( note, SimpleXMLGenerator.ADAPTER_CONTEXT ); + + xr.walk(note, SimpleXMLGenerator.ADAPTER_CONTEXT); } } } diff --git a/ccm-cms-assets-notes/src/com/arsdigita/cms/contentassets/ui/NotesStep.java b/ccm-cms-assets-notes/src/com/arsdigita/cms/contentassets/ui/NotesStep.java index 706766356..e050ae4c0 100755 --- a/ccm-cms-assets-notes/src/com/arsdigita/cms/contentassets/ui/NotesStep.java +++ b/ccm-cms-assets-notes/src/com/arsdigita/cms/contentassets/ui/NotesStep.java @@ -55,6 +55,7 @@ public class NotesStep extends SecurityPropertyEditor { return m_itemModel.getSelectedItem( ps ); } + @Override public void register( Page p ) { super.register( p );