Clover coverage report -
Coverage timestamp: Sun Aug 31 2008 23:05:03 GMT
file stats: LOC: 110   Methods: 2
NCLOC: 72   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
CreateCollectionViewer.java 0% 0% 0% 0%
coverage
 1    /*
 2    * Licensed to the Apache Software Foundation (ASF) under one or more
 3    * contributor license agreements. See the NOTICE file distributed with
 4    * this work for additional information regarding copyright ownership.
 5    * The ASF licenses this file to You under the Apache License, Version 2.0
 6    * (the "License"); you may not use this file except in compliance with
 7    * the License. You may obtain a copy of the License at
 8    *
 9    * http://www.apache.org/licenses/LICENSE-2.0
 10    *
 11    * Unless required by applicable law or agreed to in writing, software
 12    * distributed under the License is distributed on an "AS IS" BASIS,
 13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14    * See the License for the specific language governing permissions and
 15    * limitations under the License.
 16    *
 17    * $Id: CreateCollectionViewer.java 541515 2007-05-25 02:45:06Z vgritsenko $
 18    */
 19   
 20    package org.apache.xindice.webadmin.viewer.components;
 21   
 22    import java.io.IOException;
 23   
 24    import javax.servlet.ServletException;
 25    import javax.servlet.ServletOutputStream;
 26    import javax.servlet.http.HttpServletRequest;
 27    import javax.servlet.http.HttpServletResponse;
 28   
 29    import org.apache.xindice.core.Collection;
 30    import org.apache.xindice.util.Configuration;
 31    import org.apache.xindice.webadmin.util.CollectionConfigurationHelper;
 32    import org.apache.xindice.webadmin.viewer.HtmlCollectionViewer;
 33    import org.apache.xindice.webadmin.viewer.HtmlViewerComponent;
 34    import org.apache.commons.logging.Log;
 35    import org.apache.commons.logging.LogFactory;
 36   
 37    /**
 38    * Xindice Html Viewer for creating a new collection.
 39    *
 40    * @author <a href="mailto:jmetzner@apache.org">Jan Metzner</a>
 41    * @version $Revision: 541515 $, $Date: 2007-05-24 19:45:06 -0700 (Thu, 24 May 2007) $
 42    */
 43    public class CreateCollectionViewer extends HtmlViewerComponent implements HtmlCollectionViewer {
 44    private static final Log log = LogFactory.getLog(CreateCollectionViewer.class);
 45   
 46  0 public void execute(HttpServletRequest req, HttpServletResponse res, Collection col)
 47    throws ServletException, IOException {
 48   
 49  0 String path = col.getCanonicalName();
 50  0 String title = "Create Subcollection in " + path;
 51   
 52  0 ServletOutputStream output = startViewer(title, path, res);
 53   
 54  0 String name = req.getParameter("name");
 55  0 String inlineMeta = req.getParameter("meta");
 56  0 String compressed = req.getParameter("compressed");
 57  0 String filer = req.getParameter("filer");
 58   
 59  0 if (name == null || name.length() == 0) {
 60  0 printStartTable(title, output);
 61  0 printStartSingleTableBox(output);
 62  0 output.print(CREATE_FORM_START);
 63  0 output.print(CollectionConfigurationHelper.getDefaultInlineMetadata());
 64  0 output.print(CREATE_FORM_META_DEFAULT);
 65  0 output.print(!CollectionConfigurationHelper.getDefaultInlineMetadata());
 66  0 output.print(CREATE_FORM_META_END);
 67  0 output.print(CollectionConfigurationHelper.getDefaultCompressed());
 68  0 output.print(CREATE_FORM_COMPRESSED_DEFAULT);
 69  0 output.print(!CollectionConfigurationHelper.getDefaultCompressed());
 70  0 output.print(CREATE_FORM_COMPRESSED_END);
 71  0 output.print(CollectionConfigurationHelper.getDefaultFilerClass());
 72  0 output.print(CREATE_FORM_FILER);
 73  0 printEndSingleTableBox(output);
 74  0 printEndTable(output);
 75    } else {
 76  0 try {
 77  0 Configuration config = CollectionConfigurationHelper.createConfiguration(name, compressed, inlineMeta, filer);
 78  0 col.createCollection(name, config);
 79   
 80  0 printStartTable(title, output);
 81  0 printStartSingleTableBox(output);
 82  0 output.print("<b>Collection <a href=\"./");
 83  0 output.print(name);
 84  0 output.print("/?viewer=default\"><b>");
 85  0 output.print(name);
 86  0 output.print("</b></a> created!</b>");
 87  0 printEndSingleTableBox(output);
 88  0 printEndTable(output);
 89    } catch (Exception e) {
 90  0 log.error(e);
 91  0 title = "Error while creating new Collection!";
 92  0 printStartTable(title, output);
 93  0 printStartSingleTableBox(output);
 94  0 output.print("<b>Could not create Collection ");
 95  0 output.print(name);
 96  0 output.print("!</b><br />");
 97  0 output.print(e.getMessage());
 98  0 printEndSingleTableBox(output);
 99  0 printEndTable(output);
 100    }
 101    }
 102   
 103  0 finishViewer(output);
 104    }
 105   
 106  0 protected String getName() {
 107  0 return "create";
 108    }
 109   
 110    }