Clover coverage report -
Coverage timestamp: Sun Nov 1 2009 23:08:24 UTC
file stats: LOC: 111   Methods: 2
NCLOC: 73   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 711958 2008-11-06 20:12:54Z natalia $
 18    */
 19   
 20    package org.apache.xindice.webadmin.viewer.components;
 21   
 22    import java.io.IOException;
 23    import java.io.Writer;
 24   
 25    import javax.servlet.ServletException;
 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.util.StringUtilities;
 32    import org.apache.xindice.webadmin.util.CollectionConfigurationHelper;
 33    import org.apache.xindice.webadmin.viewer.HtmlCollectionViewer;
 34    import org.apache.xindice.webadmin.viewer.HtmlViewerComponent;
 35    import org.apache.commons.logging.Log;
 36    import org.apache.commons.logging.LogFactory;
 37   
 38    /**
 39    * Xindice Html Viewer for creating a new collection.
 40    *
 41    * @author <a href="mailto:jmetzner@apache.org">Jan Metzner</a>
 42    * @version $Revision: 711958 $, $Date: 2008-11-06 20:12:54 +0000 (Thu, 06 Nov 2008) $
 43    */
 44    public class CreateCollectionViewer extends HtmlViewerComponent implements HtmlCollectionViewer {
 45    private static final Log log = LogFactory.getLog(CreateCollectionViewer.class);
 46   
 47  0 public void execute(HttpServletRequest req, HttpServletResponse res, Collection col)
 48    throws ServletException, IOException {
 49   
 50  0 String path = col.getCanonicalName();
 51  0 String title = "Create Subcollection in " + path;
 52   
 53  0 Writer output = startViewer(title, path, res);
 54   
 55  0 String name = req.getParameter("name");
 56  0 String inlineMeta = req.getParameter("meta");
 57  0 String compressed = req.getParameter("compressed");
 58  0 String filer = req.getParameter("filer");
 59   
 60  0 if (name == null || name.length() == 0) {
 61  0 printStartTable(title, output);
 62  0 printStartSingleTableBox(output);
 63  0 output.write(CREATE_FORM_START);
 64  0 output.write(Boolean.toString(CollectionConfigurationHelper.getDefaultInlineMetadata()));
 65  0 output.write(CREATE_FORM_META_DEFAULT);
 66  0 output.write(Boolean.toString(!CollectionConfigurationHelper.getDefaultInlineMetadata()));
 67  0 output.write(CREATE_FORM_META_END);
 68  0 output.write(Boolean.toString(CollectionConfigurationHelper.getDefaultCompressed()));
 69  0 output.write(CREATE_FORM_COMPRESSED_DEFAULT);
 70  0 output.write(Boolean.toString(!CollectionConfigurationHelper.getDefaultCompressed()));
 71  0 output.write(CREATE_FORM_COMPRESSED_END);
 72  0 output.write(CollectionConfigurationHelper.getDefaultFilerClass());
 73  0 output.write(CREATE_FORM_FILER);
 74  0 printEndSingleTableBox(output);
 75  0 printEndTable(output);
 76    } else {
 77  0 try {
 78  0 Configuration config = CollectionConfigurationHelper.createConfiguration(name, compressed, inlineMeta, filer);
 79  0 col.createCollection(name, config);
 80   
 81  0 printStartTable(title, output);
 82  0 printStartSingleTableBox(output);
 83  0 output.write("<b>Collection <a href=\"./");
 84  0 output.write(StringUtilities.escapePath(name));
 85  0 output.write("/?viewer=default\"><b>");
 86  0 output.write(name);
 87  0 output.write("</b></a> created!</b>");
 88  0 printEndSingleTableBox(output);
 89  0 printEndTable(output);
 90    } catch (Exception e) {
 91  0 log.error(e);
 92  0 title = "Error while creating new Collection!";
 93  0 printStartTable(title, output);
 94  0 printStartSingleTableBox(output);
 95  0 output.write("<b>Could not create Collection ");
 96  0 output.write(name);
 97  0 output.write("!</b><br />");
 98  0 output.write(e.getMessage());
 99  0 printEndSingleTableBox(output);
 100  0 printEndTable(output);
 101    }
 102    }
 103   
 104  0 finishViewer(output);
 105    }
 106   
 107  0 protected String getName() {
 108  0 return "create";
 109    }
 110   
 111    }