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

michi at wyona.com michi at wyona.com
Sat May 12 12:06:02 CEST 2007


Author: michi
Date: 2007-05-12 12:06:00 +0200 (Sat, 12 May 2007)
New Revision: 24391

Modified:
   public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/AddRealmResource2.java
Log:
template made configurable

Modified: 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-05-12 10:05:01 UTC (rev 24390)
+++ public/yanel/trunk/src/resources/add-realm/src/java/org/wyona/yanel/impl/resources/AddRealmResource2.java	2007-05-12 10:06:00 UTC (rev 24391)
@@ -282,7 +282,7 @@
         String fsLocationValue = null;
         if (para.setValue != null) {
             if (para.setValue.length() == 0) {
-                fsLocationValue = getYanel().getRealmConfiguration().getRealm("from-scratch-realm-template").getRootDir().getParent();
+                fsLocationValue = getYanel().getRealmConfiguration().getRealm(getTemplateRealmId()).getRootDir().getParent();
             } else {
                 fsLocationValue = para.setValue;
             }
@@ -318,7 +318,7 @@
 
         if (valid && request.getParameter("confirm") != null && request.getParameter("confirm").equals("true")) {
             try {
-                getYanel().getRealmConfiguration().copyRealm("from-scratch-realm-template", realmidip.getValue(), realmnameip.getValue(), "/" + realmidip.getValue() + "/", new File(fsLocationValue));
+                getYanel().getRealmConfiguration().copyRealm(getTemplateRealmId(), realmidip.getValue(), realmnameip.getValue(), "/" + realmidip.getValue() + "/", new File(fsLocationValue));
                 fromScratchElement.appendChild(doc.createElementNS(NAMESPACE, "realm-created"));
             } catch (Exception e) {
                 log.error(e.getMessage(), e);
@@ -367,7 +367,7 @@
         String fsLocationValue = null;
         if (para.setValue != null) {
             if (para.setValue.length() == 0) {
-                fsLocationValue = getYanel().getRealmConfiguration().getRealm("from-scratch-realm-template").getRootDir().getParent();
+                fsLocationValue = getYanel().getRealmConfiguration().getRealm(getTemplateRealmId()).getRootDir().getParent();
             } else {
                 fsLocationValue = para.setValue;
             }
@@ -403,7 +403,7 @@
 
         if (valid && request.getParameter("confirm") != null && request.getParameter("confirm").equals("true")) {
             try {
-                getYanel().getRealmConfiguration().copyRealm("from-scratch-realm-template", realmidip.getValue(), realmnameip.getValue(), "/" + realmidip.getValue() + "/", new File(fsLocationValue));
+                getYanel().getRealmConfiguration().copyRealm(getTemplateRealmId(), realmidip.getValue(), realmnameip.getValue(), "/" + realmidip.getValue() + "/", new File(fsLocationValue));
                 fromScratchElement.appendChild(doc.createElementNS(NAMESPACE, "realm-created"));
             } catch (Exception e) {
                 log.error(e.getMessage(), e);
@@ -495,7 +495,7 @@
         String fsLocationValue = null;
         if (para.setValue != null) {
             if (para.setValue.length() == 0) {
-                fsLocationValue = getYanel().getRealmConfiguration().getRealm("from-scratch-realm-template").getRootDir().getParent();
+                fsLocationValue = getYanel().getRealmConfiguration().getRealm(getTemplateRealmId()).getRootDir().getParent();
             } else {
                 fsLocationValue = para.setValue;
             }
@@ -565,7 +565,7 @@
         if (valid && request.getParameter("confirm") != null && request.getParameter("confirm").equals("true")) {
 
             try {
-                getYanel().getRealmConfiguration().copyRealm("from-scratch-realm-template", realmidip.getValue(), realmnameip.getValue(), "/" + realmidip.getValue() + "/", new File(fsLocationValue));
+                getYanel().getRealmConfiguration().copyRealm(getTemplateRealmId(), realmidip.getValue(), realmnameip.getValue(), "/" + realmidip.getValue() + "/", new File(fsLocationValue));
                 fromExistingWebsiteElement.appendChild(doc.createElementNS(NAMESPACE, "realm-created"));
 
                 importSite(urlip.getValue(), scopeip.getValue(), new Integer(cmpip.getValue()).intValue(), new Integer(cdip.getValue()).intValue(), new Integer(cmsip.getValue()).intValue(), realmidip.getValue());
@@ -688,4 +688,21 @@
             log.warn("Another crawl is already in progress: " + eventLog.getNofDownloads());
         }
     }
+
+    /**
+     *
+     */
+    private String getTemplateRealmId() {
+        String sampleRealmId = null;
+        try {
+            sampleRealmId = getConfiguration().getProperty("template-realm-id");
+        } catch (Exception e) {
+            log.warn(e);
+        }
+        if (sampleRealmId != null) {
+            return sampleRealmId;
+        } else {
+            return "from-scratch-realm-template";
+        }
+    }
 }




More information about the Yanel-commits mailing list