The easy Weblog and Wiki Software
[ start | index | login ]
start > comment-ThoMo-27

comment-ThoMo-27 commented ThoMo

Created by ThoMo. Last edited by ThoMo, 2 years and 275 days ago. Viewed 188 times. #2
[diff] [history] [edit] [rdf]
labels
attachments
@csg: Sorry, I don't have a backup of the patch. But you can try to replace the original 1.0b1 "src/org/snipsnap/net/StoreLabelServlet.java" with this one:

/*
 * This file is part of "SnipSnap Wiki/Weblog".
 *
 * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel
 * All Rights Reserved.
 *
 * Please visit >>http://snipsnap.org/ for updates and contact.
 *
 * --LICENSE NOTICE--
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 * --LICENSE NOTICE--
 */
package org.snipsnap.net;

import org.snipsnap.snip.Snip; import org.snipsnap.snip.SnipLink; import org.snipsnap.snip.SnipSpaceFactory; import org.snipsnap.snip.SnipSpace; import org.snipsnap.snip.label.Label; import org.snipsnap.snip.label.LabelManager; import org.snipsnap.config.Configuration; import org.snipsnap.app.Application; import org.snipsnap.container.Components; import org.snipsnap.net.filter.MultipartWrapper; import org.radeox.util.logging.Logger;

import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.Enumeration; import java.util.HashMap; import java.util.Map;

/** * Adding a label to a snip * * @author Stephan J. Schmidt * @version $Id: StoreLabelServlet.java,v 1.13 2004/06/03 20:37:52 leo Exp $ */ public class StoreLabelServlet extends HttpServlet {

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Configuration config = Application.get().getConfiguration(); // If this is not a multipart/form-data request continue String type = request.getHeader("Content-Type"); if (type != null && type.startsWith("multipart/form-data")) { try { request = new MultipartWrapper(request, config.getEncoding() != null ? config.getEncoding() : "UTF-8"); } catch (IllegalArgumentException e) { Logger.warn("AddLabelServlet: multipart/form-data wrapper:" + e.getMessage()); } }

doGet(request, response); }

public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { Configuration config = Application.get().getConfiguration();

String snipName = request.getParameter("snipname");

// cancel pressed if (null != request.getParameter("cancel")) { response.sendRedirect(config.getUrl("/space/" + SnipLink.encode(snipName))); return; }

if(null == request.getParameter("back")) { Snip snip = ((SnipSpace) Components.getComponent(SnipSpace.class)).load(snipName); String labelType = request.getParameter("labeltype"); String labelName = request.getParameter("labelname"); Label label = null; // if(null != labelName) { // label = snip.getLabels().getLabel(labelName); // } // // if(null != label) { // snip.getLabels().removeLabel(label.getName(), label.getValue()); // handleLabel(label, request); // snip.getLabels().addLabel(label); // SnipSpaceFactory.getInstance().store(snip); // } else if(null != labelType) { LabelManager manager = (LabelManager)Components.getComponent(LabelManager.class); label = manager.getLabel(labelType); handleLabel(label, request); snip.getLabels().addLabel(label); SnipSpaceFactory.getInstance().store(snip); } }

response.sendRedirect(config.getUrl("/exec/labels?snipname=" + SnipLink.encode(snipName))); }

private void handleLabel(Label label, HttpServletRequest request) { Map params = new HashMap(); Enumeration enumeration = request.getParameterNames(); while (enumeration.hasMoreElements()) { String name = (String) enumeration.nextElement(); params.put(name, request.getParameter(name)); } label.handleInput(params); } }

29 comments (by michaelk, phobia, GaryPaulson, kool, ThoMo, matt, brent, csg, ahfai, scrooks, Victor Volle, funzel) | post comment

What is SnipSnap?
SnipSnap is a free and easy to install weblog and wiki tool written in Java.

SnipSnap download
Current version: 1.0b3-uttoxeter
Try our >>Web Start Demo!

Resources

5567 Users and 13712 Snips. Installed 6 years and 9 days ago

Logged in Users: (2)
… and 12 Guests.

snipsnap-changed for older changes.

< July 2008 >
SunMonTueWedThuFriSat
12345
6789101112
13141516171819
20212223242526
2728293031

snipsnap
Listed on BlogShares
XHTML 1.0 validated
CSS validated
RSS 2.0 validated
RSS Feed

pico-powered

Powered by SnipSnap 1.0b3-uttoxeter
YourKit >>Java Profiler

Fraunhofer FIRST

snipsnap.org | Copyright 2000-2006 Fraunhofer FIRST