Author: tmortagne
Date: 2007-10-03 17:45:32 +0200 (Wed, 03 Oct 2007)
New Revision: 5253

Modified:
   
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/doc/XWikiApplication.java
   
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/doc/XWikiApplicationClass.java
Log:
* XAAM-10 : Add support for matching string in application descriptor to be 
able, for example, to add in one string all document ending with "Class" in 
specific Space.
* XAAM-8 : Set new application descriptor document default parent to 
XAppManager.WebHome
* Improve javadoc

Modified: 
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/doc/XWikiApplication.java
===================================================================
--- 
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/doc/XWikiApplication.java
      2007-10-03 15:03:53 UTC (rev 5252)
+++ 
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/doc/XWikiApplication.java
      2007-10-03 15:45:32 UTC (rev 5253)
@@ -20,98 +20,210 @@
 
 package com.xpn.xwiki.plugin.applicationmanager.doc;
 
+import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import com.xpn.xwiki.XWikiContext;
 import com.xpn.xwiki.XWikiException;
 import 
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.DefaultSuperDocument;
+import 
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.SuperClass;
 import com.xpn.xwiki.doc.XWikiDocument;
 
+/**
+ * This class manage an XWiki document containing XWiki.XWikiApplicationClass 
object. It add some
+ * specifics methods, getters and setters for this type of object and fields.
+ * 
+ * @see 
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.DefaultSuperDocument
+ */
 public class XWikiApplication extends DefaultSuperDocument
 {
+    /**
+     * Pattern to match that indicate if a document name contains SQL "like" 
matching string.
+     */
+    static private final Pattern extDocNamePattern = 
Pattern.compile("^\\[(.*)\\]$");
+
+    /**
+     * Create new XWikiApplication managing provided XWikiDocument.
+     * 
+     * @param xdoc the encapsulated XWikiDocument
+     * @param context the XWiki context
+     * @throws XWikiException
+     * @see 
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.DefaultSuperDocument#DefaultSuperDocument(SuperClass,
+     *      XWikiDocument, XWikiContext)
+     */
     public XWikiApplication(XWikiDocument xdoc, XWikiContext context) throws 
XWikiException
     {
         super(XWikiApplicationClass.getInstance(context), xdoc, context);
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     * <p>
+     * Add some specifics action for Application Manager descriptors document.
+     * <ul>
+     * <li> Initialize application version to "1.0".
+     * <li> Set descriptor document default parent to Application Manager home 
page :
+     * XAppManager.WebHome.
+     * </ul>
+     * 
+     * @see 
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.DefaultSuperDocument#reload(com.xpn.xwiki.XWikiContext)
+     */
     public void reload(XWikiContext context) throws XWikiException
     {
         super.reload(context);
 
         if (getAppVersion().length() == 0)
             setAppVersion("1.0");
+
+        if (super.isNew())
+            // set Application Manager home as default parent for all 
applications descriptors
+            setParent(sclass.getClassSpacePrefix() + "Manager.WebHome");
     }
 
     // ///
 
+    /**
+     * @return the name of the application
+     * @see #setAppName(String)
+     */
     public String getAppName()
     {
         return getStringValue(XWikiApplicationClass.FIELD_appname);
     }
 
+    /**
+     * Modify the name of the application.
+     * 
+     * @param appname the new name of the application.
+     * @see #getAppName()
+     */
     public void setAppName(String appname)
     {
         setStringValue(XWikiApplicationClass.FIELD_appname, appname);
     }
 
+    /**
+     * @return the description of the application.
+     * @see #setDescription(String)
+     */
     public String getDescription()
     {
         return getStringValue(XWikiApplicationClass.FIELD_description);
     }
 
+    /**
+     * Modify the description of the application.
+     * 
+     * @param description the new description of the application.
+     * @see #getDescription()
+     */
     public void setDescription(String description)
     {
         setStringValue(XWikiApplicationClass.FIELD_description, description);
     }
 
+    /**
+     * @return the version of the application.
+     * @see #setAppVersion(String)
+     */
     public String getAppVersion()
     {
         return getStringValue(XWikiApplicationClass.FIELD_appversion);
     }
 
+    /**
+     * Modify the version of the application.
+     * 
+     * @param appversion
+     * @see #getAppVersion()
+     */
     public void setAppVersion(String appversion)
     {
         setStringValue(XWikiApplicationClass.FIELD_appversion, appversion);
     }
 
+    /**
+     * @return the list of plugins on which application depends.
+     * @see #setDependencies(List)
+     */
     public List getDependencies()
     {
         return getListValue(XWikiApplicationClass.FIELD_dependencies);
     }
 
+    /**
+     * Modify the list of plugins on which application depends.
+     * 
+     * @param dependencies the new list of plugins on which application 
depends.
+     * @see #getDependencies()
+     */
     public void setDependencies(List dependencies)
     {
         setListValue(XWikiApplicationClass.FIELD_dependencies, dependencies);
     }
 
+    /**
+     * @return the list of other applications on which current application 
depends.
+     */
     public List getApplications()
     {
         return getListValue(XWikiApplicationClass.FIELD_applications);
     }
 
+    /**
+     * Modify the list of other applications on which current application 
depends.
+     * 
+     * @param applications the new list of other applications on which current 
application depends.
+     * @see #getApplications()
+     */
     public void setApplications(List applications)
     {
         setListValue(XWikiApplicationClass.FIELD_applications, applications);
     }
 
+    /**
+     * @return the list of documents application contains.
+     * @see #setDocuments(List)
+     */
     public List getDocuments()
     {
         return getListValue(XWikiApplicationClass.FIELD_documents);
     }
 
+    /**
+     * Modify the list of documents application contains.
+     * 
+     * @param documents the new list of documents application contains.
+     * @see #getDocuments()
+     */
     public void setDocuments(List documents)
     {
         setListValue(XWikiApplicationClass.FIELD_documents, documents);
     }
 
+    /**
+     * @return the list of document application contains that will be included 
in place of copy from
+     *         wiki template.
+     * @see #setDocsToInclude(List)
+     */
     public List getDocsToInclude()
     {
         return getListValue(XWikiApplicationClass.FIELD_docstoinclude);
     }
 
+    /**
+     * Modify the list of document application contains that will be included 
in place of copy from
+     * wiki template.
+     * 
+     * @param docstoinclude the new list of document application contains that 
will be included in
+     *            place of copy from wiki template.
+     * @see #getDocsToInclude()
+     */
     public void setDocsToInclude(List docstoinclude)
     {
         setListValue(XWikiApplicationClass.FIELD_docstoinclude, docstoinclude);
@@ -126,12 +238,28 @@
     {
         setListValue(XWikiApplicationClass.FIELD_docstolink, docstolink);
     }
-    
+
+    /**
+     * @return the list of documents containing translations strings.
+     *         <p>
+     *         Theses documents are added to XWiki.XWikiPreferences 
"documentBundles" field at
+     *         application installation.
+     */
     public List getTranslationDocs()
     {
         return getListValue(XWikiApplicationClass.FIELD_translationdocs);
     }
 
+    /**
+     * Modify the list of documents containing translations strings.
+     * <p>
+     * Theses documents are added to XWiki.XWikiPreferences "documentBundles" 
field at application
+     * installation.
+     * 
+     * @param translationdocs the new list of documents containing 
translations strings. Theses
+     *            documents are added to XWiki.XWikiPreferences 
"documentBundles" field at
+     *            application installation.
+     */
     public void setTranslationDocs(List translationdocs)
     {
         setListValue(XWikiApplicationClass.FIELD_translationdocs, 
translationdocs);
@@ -139,8 +267,8 @@
 
     // ///
 
-    /*
-     * (non-Javadoc)
+    /**
+     * [EMAIL PROTECTED]
      * 
      * @see java.lang.Object#toString()
      */
@@ -151,87 +279,252 @@
 
     // ///
 
+    /**
+     * Get set of XWikiApplication containing all applications on which 
current application depend.
+     * 
+     * @param recurse if true it add recursively all applications 
dependencies, if false return only
+     *            direct dependencies.
+     * @param context the XWiki context.
+     * @return the set list of XWikiApplication.
+     * @throws XWikiException
+     * @see #getApplications()
+     */
     public Set getXWikiApplicationSet(boolean recurse, XWikiContext context)
         throws XWikiException
     {
         Set applicationSet = new HashSet();
-        
+
         List applications = getApplications();
         for (Iterator it = applications.iterator(); it.hasNext();) {
-            XWikiApplication app = 
((XWikiApplicationClass)sclass).getApplication((String)it.next(), context, 
true);
+            XWikiApplication app =
+                ((XWikiApplicationClass) sclass)
+                    .getApplication((String) it.next(), context, true);
             applicationSet.add(app);
-            
+
             if (recurse)
                 applicationSet.addAll(app.getXWikiApplicationSet(recurse, 
context));
-            
+
         }
-        
+
         return applicationSet;
     }
 
-    private Set getDocsNameSet(String type, boolean recurse, XWikiContext 
context)
-        throws XWikiException
+    /**
+     * Insert in <code>docsNames</code> all documents names 
<code>docsNamesToResolve</code>
+     * contains.
+     * <p>
+     * For each of these documents names, if are between "[" and "]", are 
considered as SQL matching
+     * string to use with "like".
+     * 
+     * @param docsNames the collection to complete with resolved documents 
names.
+     * @param docsNamesToResolve the documents names to resolve.
+     * @param context the XWiki context.
+     * @throws XWikiException
+     * @see #extDocNamePattern
+     * @see 
com.xpn.xwiki.store.XWikiStoreInterface#searchDocumentsNames(String, 
XWikiContext)
+     */
+    private static void resolveDocumentsNames(Collection docsNames,
+        Collection docsNamesToResolve, XWikiContext context) throws 
XWikiException
     {
-        return getDocsNameSet(type, recurse, false, context);
+        Matcher matcher;
+
+        StringBuffer where = new StringBuffer();
+        for (Iterator it = docsNamesToResolve.iterator(); it.hasNext();) {
+            String docName = (String) it.next();
+
+            matcher = extDocNamePattern.matcher(docName);
+            if (matcher.matches()) {
+                if (where.length() > 0)
+                    where.append(" or ");
+                where.append("doc.fullName like 
'").append(matcher.group(1)).append("'");
+            } else
+                docsNames.add(docName);
+        }
+
+        if (where.length() > 0)
+            
docsNames.addAll(context.getWiki().getStore().searchDocumentsNames("where " + 
where,
+                context));
     }
 
-    private Set getDocsNameSet(String type, boolean recurse, boolean 
includeAppDoc,
+    /**
+     * Insert in <code>docsNames</code> all documents names of type 
<code>type</code>
+     * application contains.
+     * <p>
+     * For each of these documents names, if are between "[" and "]", are 
considered as SQL matching
+     * string to use with "like".
+     * 
+     * @param docsNames the collection to complete with resolved documents 
names.
+     * @param type the XWikiApplicationClass field where to find documents 
names list :
+     *            [EMAIL PROTECTED] XWikiApplicationClass#FIELD_documents},
+     *            [EMAIL PROTECTED] XWikiApplicationClass#FIELD_docstoinclude},
+     *            [EMAIL PROTECTED] XWikiApplicationClass#FIELD_docstolink}.
+     * @param includeAppDesc if true application descriptor document names is 
add to
+     *            <code>docsNames</code>.
+     * @param context the XWiki context.
+     * @throws XWikiException
+     * @see XWikiApplicationClass#FIELD_documents
+     * @see XWikiApplicationClass#FIELD_docstoinclude
+     * @see XWikiApplicationClass#FIELD_docstolink
+     * @see #resolveDocumentsNames(Collection, Collection, XWikiContext)
+     */
+    private void resolveDocumentsNames(Collection docsNames, String type, 
boolean includeAppDesc,
         XWikiContext context) throws XWikiException
     {
-        Set set = new HashSet();
+        if (includeAppDesc)
+            docsNames.add(getFullName());
 
-        if (includeAppDoc)
-            set.add(getFullName());
+        resolveDocumentsNames(docsNames, getListValue(type), context);
+    }
 
-        List list = getListValue(type);
+    /**
+     * Insert in <code>docsNames</code> all documents names of type
+     * <code>type</code> <code>applications</code> XWikiApplication list 
contains.
+     * <p>
+     * For each of these documents names, if are between "[" and "]", are 
considered as SQL matching
+     * string to use with "like".
+     * 
+     * @param docsNames the collection to complete with resolved documents 
names.
+     * @param applications the applications containing documents names to 
resolve and add to
+     *            <code>docsNames</code>.
+     * @param type the XWikiApplicationClass field where to find documents 
names list :
+     *            [EMAIL PROTECTED] XWikiApplicationClass#FIELD_documents},
+     *            [EMAIL PROTECTED] XWikiApplicationClass#FIELD_docstoinclude},
+     *            [EMAIL PROTECTED] XWikiApplicationClass#FIELD_docstolink}.
+     * @param includeAppDesc if true application descriptor document names is 
add to
+     *            <code>docsNames</code>.
+     * @param context the XWiki context.
+     * @throws XWikiException
+     */
+    private static void resolveApplicationsDocsNames(Collection docsNames,
+        Collection applications, String type, boolean includeAppDesc, 
XWikiContext context)
+        throws XWikiException
+    {
+        for (Iterator it = applications.iterator(); it.hasNext();) {
+            XWikiApplication app = (XWikiApplication) it.next();
 
-        if (list.contains("*"))
-            set.add("*");
-        else {
-            set.addAll(list);
+            app.resolveDocumentsNames(docsNames, type, includeAppDesc, 
context);
+        }
+    }
 
-            if (recurse) {
-                for (Iterator it = getXWikiApplicationSet(true, 
context).iterator(); it.hasNext();) {
-                    XWikiApplication app = (XWikiApplication) it.next();
+    /**
+     * Get and resolve all documents names of type <code>type</code> 
application contains.
+     * <p>
+     * For each of these documents names, if are between "[" and "]", are 
considered as SQL matching
+     * string to use with "like".
+     * 
+     * @param type the XWikiApplicationClass field where to find documents 
names list :
+     *            [EMAIL PROTECTED] XWikiApplicationClass#FIELD_documents},
+     *            [EMAIL PROTECTED] XWikiApplicationClass#FIELD_docstoinclude},
+     *            [EMAIL PROTECTED] XWikiApplicationClass#FIELD_docstolink}.
+     * @param recurse if true it follow recursively all applications 
dependencies, if false parse
+     *            only direct dependencies.
+     * @param includeAppDesc if true application descriptor document names is 
add to
+     *            <code>docsNames</code>.
+     * @param context the XWiki context.
+     * @return all documents names of type <code>type</code> application 
contains.
+     * @throws XWikiException
+     */
+    private Set getDocsNameSet(String type, boolean recurse, boolean 
includeAppDesc,
+        XWikiContext context) throws XWikiException
+    {
+        Set documents = new HashSet();
 
-                    if (includeAppDoc)
-                        set.add(app.getDocument().getFullName());
-                    
-                    set.addAll(app.getListValue(type));
-                }
-            }
+        resolveDocumentsNames(documents, type, includeAppDesc, context);
+
+        if (recurse) {
+            resolveApplicationsDocsNames(documents, 
getXWikiApplicationSet(true, context), type,
+                includeAppDesc, context);
         }
 
-        return set;
+        return documents;
     }
 
-    public Set getDocumentsNames(boolean recurse, boolean includeAppDoc, 
XWikiContext context)
+    /**
+     * Get and resolve all documents names application contains.
+     * <p>
+     * For each of these documents names, if are between "[" and "]", are 
considered as SQL matching
+     * string to use with "like".
+     * 
+     * @param recurse if true it follow recursively all applications 
dependencies, if false parse
+     *            only direct dependencies.
+     * @param includeAppDesc if true application descriptor document names is 
add to
+     *            <code>docsNames</code>.
+     * @param context the XWiki context.
+     * @return all documents names application contains.
+     * @throws XWikiException
+     * @see #getDocuments()
+     * @see XWikiApplicationClass#FIELD_documents
+     */
+    public Set getDocumentsNames(boolean recurse, boolean includeAppDesc, 
XWikiContext context)
         throws XWikiException
     {
-        return getDocsNameSet(XWikiApplicationClass.FIELD_documents, recurse, 
includeAppDoc,
+        return getDocsNameSet(XWikiApplicationClass.FIELD_documents, recurse, 
includeAppDesc,
             context);
     }
 
+    /**
+     * Get and resolve all documents names to include application contains.
+     * <p>
+     * For each of these documents names, if are between "[" and "]", are 
considered as SQL matching
+     * string to use with "like".
+     * 
+     * @param recurse if true it follow recursively all applications 
dependencies, if false parse
+     *            only direct dependencies.
+     * @param context the XWiki context.
+     * @return all documents names to include application contains.
+     * @throws XWikiException
+     * @see #getDocsToInclude()
+     * @see XWikiApplicationClass#FIELD_docstoinclude
+     */
     public Set getDocsNameToInclude(boolean recurse, XWikiContext context) 
throws XWikiException
     {
-        return getDocsNameSet(XWikiApplicationClass.FIELD_docstoinclude, 
recurse, context);
+        return getDocsNameSet(XWikiApplicationClass.FIELD_docstoinclude, 
recurse, false, context);
     }
 
-    public static Set getDocsNameToInclude(List applications, boolean recurse,
+    /**
+     * Get and resolve all documents names to include 
<code>applications</code> XWikiApplication
+     * list contains.
+     * <p>
+     * For each of these documents names, if are between "[" and "]", are 
considered as SQL matching
+     * string to use with "like".
+     * 
+     * @param applications the applications containing documents names to 
resolve and add to
+     *            <code>docsNames</code>.
+     * @param recurse if true it follow recursively all applications 
dependencies, if false parse
+     *            only direct dependencies.
+     * @param context the XWiki context.
+     * @return all documents names to include <code>applications</code> 
contains.
+     * @throws XWikiException
+     * @see #getDocsToInclude()
+     * @see XWikiApplicationClass#FIELD_docstoinclude
+     */
+    public static Set getDocsNameToInclude(Collection applications, boolean 
recurse,
         XWikiContext context) throws XWikiException
     {
         Set docsToInclude = new HashSet();
 
-        for (Iterator it = applications.iterator(); it.hasNext();) {
-            docsToInclude.addAll(((XWikiApplication) 
it.next()).getDocsNameToInclude(recurse,
-                context));
-        }
+        resolveApplicationsDocsNames(docsToInclude, applications,
+            XWikiApplicationClass.FIELD_docstoinclude, false, context);
 
         return docsToInclude;
     }
 
+    /**
+     * Get and resolve all documents names to link application contains.
+     * <p>
+     * For each of these documents names, if are between "[" and "]", are 
considered as SQL matching
+     * string to use with "like".
+     * 
+     * @param recurse if true it follow recursively all applications 
dependencies, if false parse
+     *            only direct dependencies.
+     * @param context the XWiki context.
+     * @return all documents names to link application contains.
+     * @throws XWikiException
+     * @see #getDocsToLink()
+     * @see XWikiApplicationClass#FIELD_docstolink
+     */
     public Set getDocsNameToLink(boolean recurse, XWikiContext context) throws 
XWikiException
     {
-        return getDocsNameSet(XWikiApplicationClass.FIELD_docstolink, recurse, 
context);
+        return getDocsNameSet(XWikiApplicationClass.FIELD_docstolink, recurse, 
false, context);
     }
 }

Modified: 
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/doc/XWikiApplicationClass.java
===================================================================
--- 
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/doc/XWikiApplicationClass.java
 2007-10-03 15:03:53 UTC (rev 5252)
+++ 
xwiki-platform/xwiki-plugins/trunk/application-manager/src/main/java/com/xpn/xwiki/plugin/applicationmanager/doc/XWikiApplicationClass.java
 2007-10-03 15:45:32 UTC (rev 5253)
@@ -33,6 +33,12 @@
 import com.xpn.xwiki.objects.classes.BaseClass;
 import com.xpn.xwiki.plugin.applicationmanager.ApplicationManagerException;
 
+/**
+ * [EMAIL PROTECTED] SuperClass} implementation for 
XAppClasses.XWikiApplicationClass class.
+ * 
+ * @see SuperClass
+ * @see AbstractSuperClass
+ */
 public class XWikiApplicationClass extends AbstractSuperClass
 {
     /**
@@ -48,92 +54,113 @@
     // ///
 
     /**
-     * Name of field <code>appname</code>.
+     * Name of field <code>appname</code> for the XWiki class 
XAppClasses.XWikiApplicationClass.
+     * The name of the application.
      */
     public static final String FIELD_appname = "appname";
 
     /**
-     * Pretty name of field <code>appname</code>.
+     * Pretty name of field <code>appname</code> for the XWiki class
+     * XAppClasses.XWikiApplicationClass.
      */
     public static final String FIELDPN_appname = "Application Name";
 
     /**
-     * Name of field <code>description</code>.
+     * Name of field <code>description</code> for the XWiki class
+     * XAppClasses.XWikiApplicationClass. The description of the application.
      */
     public static final String FIELD_description = "description";
 
     /**
-     * Pretty name of field <code>description</code>.
+     * Pretty name of field <code>description</code> for the XWiki class
+     * XAppClasses.XWikiApplicationClass.
      */
     public static final String FIELDPN_description = "Description";
 
     /**
-     * Name of field <code>version</code>.
+     * Name of field <code>version</code> for the XWiki class 
XAppClasses.XWikiApplicationClass.
+     * The version of the application.
      */
     public static final String FIELD_appversion = "appversion";
 
     /**
-     * Pretty name of field <code>version</code>.
+     * Pretty name of field <code>version</code> for the XWiki class
+     * XAppClasses.XWikiApplicationClass.
      */
     public static final String FIELDPN_appversion = "Application Version";
 
     /**
-     * Name of field <code>dependencies</code>.
+     * Name of field <code>dependencies</code> for the XWiki class
+     * XAppClasses.XWikiApplicationClass. The list of plugins on which 
application depends.
      */
     public static final String FIELD_dependencies = "dependencies";
 
     /**
-     * Pretty name of field <code>dependencies</code>.
+     * Pretty name of field <code>dependencies</code> for the XWiki class
+     * XAppClasses.XWikiApplicationClass.
      */
     public static final String FIELDPN_dependencies = "Dependencies";
 
     /**
-     * Name of field <code>applications</code>.
+     * Name of field <code>applications</code> for the XWiki class
+     * XAppClasses.XWikiApplicationClass. The list of other applications on 
which current
+     * application depends.
      */
     public static final String FIELD_applications = "applications";
 
     /**
-     * Pretty name of field <code>applications</code>.
+     * Pretty name of field <code>applications</code> for the XWiki class
+     * XAppClasses.XWikiApplicationClass.
      */
     public static final String FIELDPN_applications = "Applications";
 
     /**
-     * Name of field <code>documents</code>.
+     * Name of field <code>documents</code> for the XWiki class 
XAppClasses.XWikiApplicationClass.
+     * The list of documents application contains.
      */
     public static final String FIELD_documents = "documents";
 
     /**
-     * Pretty name of field <code>documents</code>.
+     * Pretty name of field <code>documents</code> for the XWiki class
+     * XAppClasses.XWikiApplicationClass.
      */
     public static final String FIELDPN_documents = "Documents";
 
     /**
-     * Name of field <code>docstoinclude</code>.
+     * Name of field <code>docstoinclude</code> for the XWiki class
+     * XAppClasses.XWikiApplicationClass. The list of document application 
contains that will be
+     * included in place of copy from wiki template.
      */
     public static final String FIELD_docstoinclude = "docstoinclude";
 
     /**
-     * Pretty name of field <code>docstoinclude</code>.
+     * Pretty name of field <code>docstoinclude</code> for the XWiki class
+     * XAppClasses.XWikiApplicationClass.
      */
     public static final String FIELDPN_docstoinclude = "Documents to include";
 
     /**
-     * Name of field <code>docstolink</code>.
+     * Name of field <code>docstolink</code> for the XWiki class
+     * XAppClasses.XWikiApplicationClass. The list of document application 
contains that will be
+     * linked in place of copy from wiki template.
      */
     public static final String FIELD_docstolink = "docstolink";
 
     /**
-     * Pretty name of field <code>docstolink</code>.
+     * Pretty name of field <code>docstolink</code> for the XWiki class
+     * XAppClasses.XWikiApplicationClass.
      */
     public static final String FIELDPN_docstolink = "Documents to link";
 
     /**
-     * Name of field <code>translationdocs</code>.
+     * Name of field <code>translationdocs</code> for the XWiki class
+     * XAppClasses.XWikiApplicationClass.
      */
     public static final String FIELD_translationdocs = "translationdocs";
 
     /**
-     * Pretty name of field <code>translationdocs</code>.
+     * Pretty name of field <code>translationdocs</code> for the XWiki class
+     * XAppClasses.XWikiApplicationClass.
      */
     public static final String FIELDPN_translationdocs = "Translations 
documents";
 
@@ -145,10 +172,12 @@
     private static XWikiApplicationClass instance = null;
 
     /**
-     * Return unique instance of XWikiApplicationClass and update documents 
for this context.
+     * Return unique instance of XWikiApplicationClass and update documents 
for this context. It
+     * also check if the corresponding Xwiki class/template/sheet exist in 
context's database and
+     * create it if not.
      * 
-     * @param context Context.
-     * @return XWikiApplicationClass Instance of XWikiApplicationClass.
+     * @param context the XWiki context.
+     * @return a unique instance of XWikiApplicationClass.
      * @throws XWikiException
      */
     public static XWikiApplicationClass getInstance(XWikiContext context) 
throws XWikiException
@@ -163,16 +192,14 @@
         return instance;
     }
 
-    /**
-     * Default constructor for XWikiApplicationClass.
-     */
     private XWikiApplicationClass()
     {
         super(CLASS_SPACE_PREFIX, CLASS_PREFIX);
     }
-
+    
     /**
      * [EMAIL PROTECTED]
+     * 
      * @see 
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.AbstractSuperClass#updateBaseClass(com.xpn.xwiki.objects.classes.BaseClass)
      */
     protected boolean updateBaseClass(BaseClass baseClass)
@@ -184,7 +211,7 @@
         needsUpdate |= baseClass.addTextField(FIELD_appversion, 
FIELDPN_appversion, 30);
 
         StaticListClass slc;
-        
+
         if (baseClass.addStaticListField(FIELD_dependencies, 
FIELDPN_dependencies, 80, true, "",
             "input")) {
             // TODO : move into BaseClass.addStaticListField with "separators' 
parameter when/if
@@ -264,6 +291,18 @@
         return needsUpdate;
     }
 
+    /**
+     * Get the XWiki document descriptor of containing 
XAppClasses.XWikiApplication XWiki object
+     * with "appname" field equals to <code>appName</code>.
+     * 
+     * @param appName the name of the application.
+     * @param context the XWiki context.
+     * @param validate indicate if it return new XWikiDocument or throw 
exception if application
+     *            descriptor does not exist.
+     * @return the XWikiDocument representing application descriptor.
+     * @throws XWikiException
+     * @see #getApplication(String, XWikiContext, boolean)
+     */
     private XWikiDocument getApplicationDocument(String appName, XWikiContext 
context,
         boolean validate) throws XWikiException
     {
@@ -285,6 +324,18 @@
         return (XWikiDocument) listApp.get(0);
     }
 
+    /**
+     * Get the XWiki document descriptor of containing 
XAppClasses.XWikiApplication XWiki object
+     * with "appname" field equals to <code>appName</code>.
+     * 
+     * @param appName the name of the application.
+     * @param context the XWiki context.
+     * @param validate indicate if it return new XWikiDocument or throw 
exception if application
+     *            descriptor does not exist.
+     * @return the XWikiDocument representing application descriptor.
+     * @throws XWikiException
+     * @see #getApplicationDocument(String, XWikiContext, boolean)
+     */
     public XWikiApplication getApplication(String appName, XWikiContext 
context, boolean validate)
         throws XWikiException
     {
@@ -292,6 +343,14 @@
             validate), context);
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     * <p>
+     * Override abstract method using [EMAIL PROTECTED] XWikiApplication} as 
[EMAIL PROTECTED] XWikiApplication}
+     * 
+     * @see 
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.AbstractSuperClass#newSuperDocument(com.xpn.xwiki.doc.XWikiDocument,
+     *      com.xpn.xwiki.XWikiContext)
+     */
     public SuperDocument newSuperDocument(XWikiDocument doc, XWikiContext 
context)
     {
         return (SuperDocument) 
doc.newDocument(XWikiApplication.class.getName(), context);

_______________________________________________
notifications mailing list
notifications@xwiki.org
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to