⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 itemmapservlet.java

📁 dspace 用j2ee架构的一个数字图书馆.开源程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * ItemMapServlet.java * * Version: $Revision: 1.8 $ * * Date: $Date: 2005/07/26 06:51:09 $ * * Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts * Institute of Technology.  All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * - 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. * * - Neither the name of the Hewlett-Packard Company nor the name of the * Massachusetts Institute of Technology nor the names of their * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. */package org.dspace.app.webui.servlet.admin;import java.util.HashMap;import java.util.Map;import java.util.LinkedList;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.dspace.app.webui.servlet.DSpaceServlet;import org.dspace.app.webui.util.JSPManager;import org.dspace.app.webui.util.UIUtil;import org.dspace.authorize.AuthorizeException;import org.dspace.authorize.AuthorizeManager;import org.dspace.content.Collection;import org.dspace.content.Item;import org.dspace.content.ItemIterator;import org.dspace.core.Constants;import org.dspace.core.Context;import org.dspace.storage.rdbms.DatabaseManager;import org.dspace.storage.rdbms.TableRow;import org.dspace.storage.rdbms.TableRowIterator;/** * Servlet for editing and deleting (expunging) items *  * @version $Revision: 1.8 $ */public class ItemMapServlet extends DSpaceServlet{    protected void doDSGet(Context context, HttpServletRequest request,            HttpServletResponse response) throws java.sql.SQLException,            javax.servlet.ServletException, java.io.IOException,            AuthorizeException    {        doDSPost(context, request, response);    }    protected void doDSPost(Context context, HttpServletRequest request,            HttpServletResponse response) throws java.sql.SQLException,            javax.servlet.ServletException, java.io.IOException,            AuthorizeException    {        String jspPage = null;        // get with a collection ID means put up browse window        int myID = UIUtil.getIntParameter(request, "cid");        // get collection        Collection myCollection = Collection.find(context, myID);        // authorize check        AuthorizeManager.authorizeAction(context, myCollection,                Constants.COLLECTION_ADMIN);        String action = request.getParameter("action");        if (action == null)        {            action = "";        }		// Defined non-empty value shows that 'Cancel' has been pressed	String cancel = request.getParameter("cancel");	if (cancel == null)	{		cancel = "";	}        if (action.equals("") || !cancel.equals(""))        {            // get with no action parameter set means to put up the main page            // which is statistics and some command buttons to add/remove items	    //	    // also holds for interruption by pressing 'Cancel'            int count_native = 0; // # of items owned by this collection            int count_import = 0; // # of virtual items            Map myItems = new HashMap(); // # for the browser            Map myCollections = new HashMap(); // collections for list            Map myCounts = new HashMap(); // counts for each collection            // get all items from that collection, add them to a hash            ItemIterator i = myCollection.getItems();            // iterate through the items in this collection, and count how many            // are native, and how many are imports, and which collections they            // came from            while (i.hasNext())            {                Item myItem = i.next();                // get key for hash                Integer myKey = new Integer(myItem.getID());                if (myItem.isOwningCollection(myCollection))                {                    count_native++;                }                else                {                    count_import++;                }                // is the collection in the hash?                Collection owningCollection = myItem.getOwningCollection();                Integer cKey = new Integer(owningCollection.getID());                if (myCollections.containsKey(cKey))                {                    Integer x = (Integer) myCounts.get(cKey);                    int myCount = x.intValue() + 1;                    // increment count for that collection                    myCounts.put(cKey, new Integer(myCount));                }                else                {                    // store and initialize count                    myCollections.put(cKey, owningCollection);                    myCounts.put(cKey, new Integer(1));                }                // store the item                myItems.put(myKey, myItem);            }            // remove this collection's entry because we already have a native            // count            myCollections.remove(new Integer(myCollection.getID()));            // sort items - later            // show page            request.setAttribute("collection", myCollection);            request.setAttribute("count_native", new Integer(count_native));            request.setAttribute("count_import", new Integer(count_import));            request.setAttribute("items", myItems);            request.setAttribute("collections", myCollections);            request.setAttribute("collection_counts", myCounts);            request                    .setAttribute("all_collections", Collection                            .findAll(context));            // show this page when we're done            jspPage = "itemmap-main.jsp";            // show the page            JSPManager.showJSP(request, response, jspPage);        }        /*         * else if( action.equals("add") ) { int itemID =         * UIUtil.getIntParameter(request, "item_id"); String handle =         * (String)request.getParameter("handle"); boolean error = true; Item         * itemToAdd = null;         *          * if( itemID > 0 ) { itemToAdd = Item.find(context, itemID);         *          * if( itemToAdd != null ) error = false; } else if(handle != null &&         * !handle.equals("")) { DSpaceObject         * dso=HandleManager.resolveToObject(context, handle);         *          * if(dso != null && dso.getType() == Constants.ITEM) { itemToAdd =         * (Item)dso; error = false; } }         *          * //FIXME: error handling! if( !error ) { String myTitle =         * itemToAdd.getDC("title",null,Item.ANY)[0].value; String ownerName =

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -