[Yanel-commits] rev 23594 - public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources

michi at wyona.com michi at wyona.com
Wed Apr 4 14:57:54 CEST 2007


Author: michi
Date: 2007-04-04 14:57:52 +0200 (Wed, 04 Apr 2007)
New Revision: 23594

Added:
   public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/AddRealmResource2.java
Log:
add realm refactored added

Added: public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/AddRealmResource2.java
===================================================================
--- public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/AddRealmResource2.java	2007-04-04 12:56:22 UTC (rev 23593)
+++ public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/AddRealmResource2.java	2007-04-04 12:57:52 UTC (rev 23594)
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2006 Wyona
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.wyona.org/licenses/APACHE-LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.wyona.yanel.impl.resources;
+
+import java.util.Calendar;
+import java.util.HashMap;
+import java.io.StringBufferInputStream;
+
+import javax.servlet.http.HttpServletRequest;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+
+import org.apache.log4j.Category;
+
+import org.wyona.yanel.core.Path;
+import org.wyona.yanel.core.Resource;
+import org.wyona.yanel.core.api.attributes.ViewableV1;
+import org.wyona.yanel.core.attributes.viewable.View;
+import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
+
+/**
+ * 
+ */
+public class AddRealmResource2 extends Resource implements ViewableV1 {
+
+    private static Category log = Category.getInstance(AddRealmResource2.class);
+
+    /**
+     * 
+     */
+    public AddRealmResource2() {
+    }
+
+    /**
+     * 
+     */
+    public ViewDescriptor[] getViewDescriptors() {
+        log.warn("Not implemented yet!");
+        return null;
+    }
+    
+    /**
+     * 
+     */
+    public View getView(Path path, String viewId) {
+        View view = new View();
+        StringBuffer sb = new StringBuffer("Hello Yanel");
+        view.setInputStream(new StringBufferInputStream(sb.toString()));
+        view.setMimeType("text/plain");
+        return view;
+    }
+
+    /**
+     * 
+     */
+    public View getView(HttpServletRequest request, String viewId) throws Exception {
+        String addType = getConfiguration().getProperty("add-type");
+
+        if (addType != null && addType.equals("from-scratch")) {
+            return null;
+        } else if (addType != null && addType.equals("from-existing-website")) {
+            return null;
+        } else {
+        View view = new View();
+        StringBuffer sb = new StringBuffer("<?xml version=\"1.0\"?>");
+        sb.append("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
+        sb.append("<head>");
+        sb.append("<title>Add Realm Resource</title>");
+        sb.append("</head>");
+        sb.append("<body>");
+        sb.append("<div id=\"contenBody\">");
+        sb.append("<h1>No such type: " + addType + "</h1>");
+        sb.append("</div>");
+        sb.append("</body>");
+        sb.append("</html>");
+
+        view.setMimeType("application/xhtml+xml");
+        view.setInputStream(new StringBufferInputStream(sb.toString()));
+        return view;
+        }
+    }
+
+    /**
+     * Get DOM document
+     */
+    public Document getDocument() {
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setNamespaceAware(true);
+        String NAMESPACE = "http://www.wyona.org/yanel/1.0";
+        Document document = null;
+        try {
+            DocumentBuilder parser = dbf.newDocumentBuilder();
+            document = parser.parse(new java.io.StringBufferInputStream("<yanel:add-realm xmlns:yanel=\""+NAMESPACE+"\" xmlns=\""+NAMESPACE+"\"/>"));
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+        return document;
+    }
+}




More information about the Yanel-commits mailing list