diff --git a/ccm-docrepo/src/main/java/com/arsdigita/docrepo/ui/BrowsePane.java b/ccm-docrepo/src/main/java/com/arsdigita/docrepo/ui/BrowsePane.java
index f8f3307aa..04a2db25b 100644
--- a/ccm-docrepo/src/main/java/com/arsdigita/docrepo/ui/BrowsePane.java
+++ b/ccm-docrepo/src/main/java/com/arsdigita/docrepo/ui/BrowsePane.java
@@ -67,7 +67,7 @@ import java.util.ArrayList;
*/
public class BrowsePane extends ModalContainer implements Constants, ChangeListener, RequestListener {
- //private static final Logger logger = Logger.getLogger(BrowsePane.class);
+ //private static final Logger log = Logger.getLogger(BrowsePane.class);
private Component m_folderContent;
private Component m_destinationFolderPanel;
diff --git a/ccm-docrepo/src/main/java/com/arsdigita/docrepo/ui/DestinationFolderForm.java b/ccm-docrepo/src/main/java/com/arsdigita/docrepo/ui/DestinationFolderForm.java
index 5ff78c5b4..83055ce36 100644
--- a/ccm-docrepo/src/main/java/com/arsdigita/docrepo/ui/DestinationFolderForm.java
+++ b/ccm-docrepo/src/main/java/com/arsdigita/docrepo/ui/DestinationFolderForm.java
@@ -195,6 +195,7 @@ public class DestinationFolderForm extends Form implements FormInitListener,
Folder folder = (Folder) resourceRepository.findById(folderId);
if (folder == null) {
+ isError = true;
log.error(String.format("Couldn't find folder %d in the " +
"database.", folderId));
}
@@ -205,9 +206,9 @@ public class DestinationFolderForm extends Form implements FormInitListener,
Resource resource = resourceRepository.findById(resourceId);
if (resource == null) {
+ errorList.add(resourceString);
log.debug(String.format("Couldn't find selected resource " +
"%d in the database.", resourceId));
- errorList.add(resourceString);
continue;
}
@@ -220,9 +221,9 @@ public class DestinationFolderForm extends Form implements FormInitListener,
}
}
} catch (CdiLookupException ex) {
- log.error("Failed to find bean for either ResourceRepository or " +
- "ResourceManager", ex);
isError = true;
+ log.error("Failed to find bean for either ResourceRepository or " +
+ "ResourceManager.", ex);
}
if (isError) {
@@ -288,7 +289,7 @@ public class DestinationFolderForm extends Form implements FormInitListener,
sourceFolder = (Folder) resourceRepository.findById
(sourceFolderId);
} catch (CdiLookupException ex) {
- log.error("Failed to find bean for the ResourceRepository", ex);
+ log.error("Failed to find bean for the ResourceRepository.", ex);
}
if (sourceFolder != null) {
@@ -318,7 +319,7 @@ public class DestinationFolderForm extends Form implements FormInitListener,
}
} else {
log.error(String.format("Couldn't find the source folder %d " +
- "in the database", sourceFolderId));
+ "in the database.", sourceFolderId));
}
}
diff --git a/ccm-docrepo/src/main/java/com/arsdigita/docrepo/ui/FileActionPane.java b/ccm-docrepo/src/main/java/com/arsdigita/docrepo/ui/FileActionPane.java
index 4c238ca52..2ba7a3339 100644
--- a/ccm-docrepo/src/main/java/com/arsdigita/docrepo/ui/FileActionPane.java
+++ b/ccm-docrepo/src/main/java/com/arsdigita/docrepo/ui/FileActionPane.java
@@ -81,11 +81,11 @@ public class FileActionPane extends ColumnPanel implements Constants {
file = (File) resourceRepository.findById(fileId);
if (file == null) {
log.error(String.format("Couldn't find the file %d in" +
- " the database", fileId));
+ " the database.", fileId));
}
} catch(CdiLookupException ex) {
log.error("Failed to find bean for the " +
- "ResourceRepository", ex);
+ "ResourceRepository.", ex);
}
return file;
}
@@ -183,7 +183,8 @@ public class FileActionPane extends ColumnPanel implements Constants {
// ex.run();
} catch (CdiLookupException ex) {
- log.error("Failed to find bean for the ResourceRepository.", ex);
+ log.error("Failed to find bean for the " +
+ "ResourceRepository.", ex);
}
try {
diff --git a/ccm-docrepo/src/main/java/com/arsdigita/docrepo/ui/FileEditForm.java b/ccm-docrepo/src/main/java/com/arsdigita/docrepo/ui/FileEditForm.java
new file mode 100644
index 000000000..bd646d182
--- /dev/null
+++ b/ccm-docrepo/src/main/java/com/arsdigita/docrepo/ui/FileEditForm.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
+ *
+ * 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
+ *
+ */
+package com.arsdigita.docrepo.ui;
+
+import com.arsdigita.bebop.ColumnPanel;
+import com.arsdigita.bebop.Form;
+import com.arsdigita.bebop.FormData;
+import com.arsdigita.bebop.Label;
+import com.arsdigita.bebop.PageState;
+import com.arsdigita.bebop.SimpleContainer;
+import com.arsdigita.bebop.event.FormInitListener;
+import com.arsdigita.bebop.event.FormProcessListener;
+import com.arsdigita.bebop.event.FormSectionEvent;
+import com.arsdigita.bebop.event.FormValidationListener;
+import com.arsdigita.bebop.form.Submit;
+import com.arsdigita.bebop.form.TextArea;
+import com.arsdigita.bebop.form.TextField;
+import com.arsdigita.bebop.parameters.NotEmptyValidationListener;
+import com.arsdigita.bebop.parameters.StringParameter;
+import org.apache.log4j.Logger;
+import org.libreccm.cdi.utils.CdiLookupException;
+import org.libreccm.cdi.utils.CdiUtil;
+import org.libreccm.docrepo.File;
+import org.libreccm.docrepo.ResourceRepository;
+
+import javax.servlet.http.HttpServletRequest;
+
+//import com.arsdigita.docrepo.File;
+//import com.arsdigita.docrepo.Folder;
+
+/**
+ * This component allows to change the file name and the description of a
+ * file. It also serves to associate keywords to a file (knowledge object).
+ *
+ * @author Stefan Deusch
+ * @author Tobias Osmers
+ */
+public class FileEditForm extends Form implements FormValidationListener,
+ FormProcessListener, FormInitListener, Constants {
+
+ private static final Logger log = Logger.getLogger(FileEditForm.class);
+
+ // Todo: add strings to package properties
+ private final static String FILE_EDIT = "file-edit";
+ private final static String FILE_EDIT_FNAME = "file-edit-name";
+ private final static String FILE_EDIT_DESCRIPTION = "file-edit-description";
+
+ private StringParameter m_FileName;
+ private StringParameter m_FileDesc;
+ private FileInfoPropertiesPane m_parent;
+
+ /**
+ * Constructor. Initializes the file edit form in the info property pane.
+ *
+ * @param parent The file property pane
+ */
+ public FileEditForm(FileInfoPropertiesPane parent) {
+ super(FILE_EDIT, new ColumnPanel(2));
+
+ m_parent = parent;
+
+ m_FileName = new StringParameter(FILE_EDIT_FNAME);
+ m_FileDesc = new StringParameter(FILE_EDIT_DESCRIPTION);
+
+ add(new Label(FILE_NAME_REQUIRED));
+ TextField fnameEntry = new TextField(m_FileName);
+ fnameEntry.addValidationListener(new NotEmptyValidationListener());
+ add(fnameEntry);
+
+ add(new Label(FILE_DESCRIPTION));
+ TextArea descArea = new TextArea(m_FileDesc);
+ descArea.setRows(10);
+ descArea.setCols(40);
+ add(descArea);
+
+ Submit submit = new Submit("file-edit-save");
+ submit.setButtonLabel(FILE_SAVE);
+ add(new Label());
+
+ SimpleContainer sc = new SimpleContainer();
+ sc.add(submit);
+ sc.add(new CancelButton(CANCEL));
+
+ add(sc);
+
+ addInitListener(this);
+ addProcessListener(this);
+ addValidationListener(this);
+ }
+
+ /**
+ * Initializer to pre-fill name and description after an event has been
+ * triggered.
+ *
+ * @param event The event
+ */
+ public void init(FormSectionEvent event) {
+ PageState state = event.getPageState();
+
+ // Todo: exchange usage of Kernel class
+// if (Kernel.getContext().getParty() == null) {
+// Util.redirectToLoginPage(state);
+// }
+
+ FormData data = event.getFormData();
+
+ Long fileId = (Long) state.getValue(FILE_ID_PARAM);
+ final CdiUtil cdiUtil = new CdiUtil();
+ final ResourceRepository resourceRepository;
+ try {
+ resourceRepository = cdiUtil.findBean(ResourceRepository.class);
+ File file = (File) resourceRepository.findById(fileId);
+ data.put(FILE_EDIT_FNAME, file.getName());
+ data.put(FILE_EDIT_DESCRIPTION, file.getDescription());
+ } catch (CdiLookupException ex) {
+ log.error("Failed to find bean for ResourceRepository.", ex);
+ }
+ }
+
+ /**
+ * Read form and update when event has been triggered.+
+ *
+ * @param event The event
+ */
+ public void process(FormSectionEvent event) {
+ PageState state = event.getPageState();
+ HttpServletRequest req = state.getRequest();
+ FormData data = event.getFormData();
+
+ String fname = (String) data.get(FILE_EDIT_FNAME);
+ String fdesc = (String) data.get(FILE_EDIT_DESCRIPTION);
+
+ Long fileId = (Long) state.getValue(FILE_ID_PARAM);
+ final CdiUtil cdiUtil = new CdiUtil();
+ final ResourceRepository resourceRepository;
+ try {
+ resourceRepository = cdiUtil.findBean(ResourceRepository.class);
+ File file = (File) resourceRepository.findById(fileId);
+ if (file != null) {
+ file.setName(fname);
+ file.setDescription(fdesc);
+ // Todo: How to change?
+ //file.applyTag(FILE_EDIT_ACTION_DESCRIPTION.localize(req).toString());
+ resourceRepository.save(file);
+ } else {
+ log. error(String.format("Couldn't find file %d in the " +
+ "database.", fileId));
+ }
+ } catch (CdiLookupException ex) {
+ log.error("Failed to find bean for ResourceRepository.", ex);
+ }
+ m_parent.displayPropertiesAndActions(state);
+ }
+
+ /**
+ * Tests if the new name already exists in the current folder when event
+ * has been triggered.
+ *
+ * @param event The event
+ */
+ public void validate(FormSectionEvent event) {
+ // Todo: redundant i think
+ }
+}
\ No newline at end of file