Author: tmortagne
Date: 2007-10-13 16:04:18 +0200 (Sat, 13 Oct 2007)
New Revision: 5389
Modified:
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/WikiManager.java
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/WikiManagerException.java
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/WikiManagerPlugin.java
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/WikiManagerPluginApi.java
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/doc/XWikiServer.java
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/doc/XWikiServerClass.java
Log:
Improve code style the Checkstyle xwiki plugin way.
Modified:
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/WikiManager.java
===================================================================
---
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/WikiManager.java
2007-10-13 13:12:59 UTC (rev 5388)
+++
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/WikiManager.java
2007-10-13 14:04:18 UTC (rev 5389)
@@ -49,32 +49,39 @@
*
* @version $Id: $
*/
-public class WikiManager
+public final class WikiManager
{
+ /**
+ * The logging tool.
+ */
protected static final Log LOG = LogFactory.getLog(WikiManager.class);
//
////////////////////////////////////////////////////////////////////////////
+ /**
+ * Unique instance of WikiManager.
+ */
+ private static WikiManager instance;
+
+ /**
+ * Hidden constructor of WikiManager only access via getInstance().
+ */
private WikiManager()
{
}
/**
- * Unique instance of WikiManager.
- */
- private static WikiManager _instance = null;
-
- /**
* @return a unique instance of WikiManager. Thread safe.
*/
public static WikiManager getInstance()
{
synchronized (WikiManager.class) {
- if (_instance == null)
- _instance = new WikiManager();
+ if (instance == null) {
+ instance = new WikiManager();
+ }
}
- return _instance;
+ return instance;
}
//
////////////////////////////////////////////////////////////////////////////
@@ -88,7 +95,8 @@
* @param doc the document to save.
* @param comment the comment to use when saving document.
* @param context the XWiki Context.
- * @throws XWikiException
+ * @throws XWikiException error when calling
+ * [EMAIL PROTECTED] XWiki#saveDocument(XWikiDocument, String,
XWikiContext)}.
* @see com.xpn.xwiki.XWiki#saveDocument(XWikiDocument, XWikiContext)
*/
public void saveDocument(String wikiName, XWikiDocument doc, String
comment,
@@ -112,7 +120,7 @@
* @param context the XWiki context.
* @return the document with full name equals to <code>fullname</code> and
wiki
* <code>wikiName</code>. If it dos not exist return new
XWikiDocument.
- * @throws XWikiException
+ * @throws XWikiException error when calling [EMAIL PROTECTED]
XWiki#getDocument(String, XWikiContext)}}.
* @see com.xpn.xwiki.XWiki#getDocument(String, XWikiContext)
*/
public XWikiDocument getDocument(String wikiName, String fullname,
XWikiContext context)
@@ -137,7 +145,8 @@
* @param context the XWiki context.
* @return the list of documents that match the <code>wheresql</code>
conditions. If nothing
* found return empty List.
- * @throws XWikiException
+ * @throws XWikiException error when calling
+ * [EMAIL PROTECTED]
XWikiStoreInterface#searchDocuments(String, XWikiContext)}}.
* @see XWikiStoreInterface#searchDocuments(String, XWikiContext)
*/
public List searchDocuments(String wikiName, String wheresql, XWikiContext
context)
@@ -164,8 +173,9 @@
(ApplicationManagerPluginApi) context.getWiki().getPluginApi(
ApplicationManagerPlugin.PLUGIN_NAME, context);
- if (appmanager == null)
+ if (appmanager == null) {
return null;
+ }
// //////////////////////////////////
// Get documents to include
@@ -179,12 +189,13 @@
XWikiApplication rootApp = appmanager.getRootApplication();
- if (rootApp != null)
+ if (rootApp != null) {
docsToInclude = rootApp.getDocsNameToInclude(true);
- else
+ } else {
docsToInclude =
XWikiApplication
.getDocsNameToInclude(appmanager.getApplicationDocumentList());
+ }
} finally {
context.setDatabase(database);
}
@@ -199,8 +210,9 @@
(ApplicationManagerPluginApi) context.getWiki().getPluginApi(
ApplicationManagerPlugin.PLUGIN_NAME, context);
- if (appmanager == null)
+ if (appmanager == null) {
return null;
+ }
// //////////////////////////////////
// Get documents to link
@@ -214,11 +226,12 @@
XWikiApplication rootApp = appmanager.getRootApplication();
- if (rootApp != null)
+ if (rootApp != null) {
docsToLink = rootApp.getDocsNameToLink(true);
- else
+ } else {
docsToLink =
XWikiApplication.getDocsNameToLink(appmanager.getApplicationDocumentList());
+ }
} finally {
context.setDatabase(database);
}
@@ -327,15 +340,17 @@
String templateWikiName, String packageName, String comment,
XWikiContext context)
throws XWikiException
{
- if (userWikiSuperDoc.getOwner().length() == 0)
+ if (userWikiSuperDoc.getOwner().length() == 0) {
throw new
WikiManagerException(WikiManagerException.ERROR_XWIKI_USER_INACTIVE,
"Invalid user \"" + userWikiSuperDoc.getOwner() + "\"");
+ }
XWiki xwiki = context.getWiki();
- if (!xwiki.isVirtual())
+ if (!xwiki.isVirtual()) {
throw new
WikiManagerException(WikiManagerException.ERROR_WIKIMANAGER_XWIKI_NOT_VIRTUAL,
"XWiki is not in virtual mode. Make sure property
\"xwiki.virtual\" is setted to \"xwiki.virtual=1\" in xwiki.cfg file");
+ }
XWikiServerClass wikiClass = XWikiServerClass.getInstance(context);
@@ -352,18 +367,22 @@
// User does not exist
if (userdoc.isNew()) {
- if (LOG.isErrorEnabled())
+ if (LOG.isErrorEnabled()) {
LOG.error("Wiki creation (" + userWikiSuperDoc + ")
failed: "
+ "user does not exist");
+ }
+
throw new
WikiManagerException(WikiManagerException.ERROR_XWIKI_USER_DOES_NOT_EXIST,
"User \"" + userWikiSuperDoc.getOwner() + "\" does not
exist");
}
// User is not active
if (!(userdoc.getIntValue("XWiki.XWikiUsers", "active") == 1)) {
- if (LOG.isErrorEnabled())
+ if (LOG.isErrorEnabled()) {
LOG.error("Wiki creation (" + userWikiSuperDoc + ")
failed: "
+ "user is not active");
+ }
+
throw new
WikiManagerException(WikiManagerException.ERROR_XWIKI_USER_INACTIVE,
"User \"" + userWikiSuperDoc.getOwner() + "\" is not
active");
}
@@ -371,9 +390,11 @@
// Wiki name forbidden
String wikiForbiddenList =
xwiki.Param("xwiki.virtual.reserved_wikis");
if (Util.contains(newWikiName, wikiForbiddenList, ", ")) {
- if (LOG.isErrorEnabled())
+ if (LOG.isErrorEnabled()) {
LOG.error("Wiki creation (" + userWikiSuperDoc + ")
failed: "
+ "wiki name is forbidden");
+ }
+
throw new
WikiManagerException(WikiManagerException.ERROR_WIKIMANAGER_WIKI_NAME_FORBIDDEN,
"Wiki name \"" + newWikiName + "\" forbidden");
}
@@ -389,15 +410,18 @@
if (!docToSave.isNew() && wikiClass.isInstance(docToSave)) {
// If we are not allowed to continue if server page
already exists
if (failOnExist) {
- if (LOG.isErrorEnabled())
+ if (LOG.isErrorEnabled()) {
LOG.error("Wiki creation (" + userWikiSuperDoc +
") failed: "
+ "wiki server page already exists");
+ }
+
throw new
WikiManagerException(WikiManagerException.ERROR_WIKIMANAGER_WIKISERVER_ALREADY_EXISTS,
"Wiki \"" + userWikiSuperDoc.getFullName()
+ "\" document already exist");
- } else if (LOG.isWarnEnabled())
+ } else if (LOG.isWarnEnabled()) {
LOG.warn("Wiki creation (" + userWikiSuperDoc + ")
failed: "
+ "wiki server page already exists");
+ }
}
@@ -406,27 +430,30 @@
docToSave, context);
// clear entry in virtual wiki cache
- if
(!wikiSuperDocToSave.getServer().equals(userWikiSuperDoc.getServer()))
+ if
(!wikiSuperDocToSave.getServer().equals(userWikiSuperDoc.getServer())) {
xwiki.getVirtualWikiMap().flushEntry(userWikiSuperDoc.getServer());
+ }
wikiSuperDocToSave.mergeBaseObject(userWikiSuperDoc);
- } else
+ } else {
wikiSuperDocToSave = userWikiSuperDoc;
+ }
// Create wiki database
try {
xwiki.getStore().createWiki(newWikiName, context);
} catch (XWikiException e) {
if (LOG.isErrorEnabled()) {
- if (e.getCode() == 10010)
+ if (e.getCode() == 10010) {
LOG.error("Wiki creation (" + userWikiSuperDoc + ")
failed: "
+ "wiki database already exists");
- else if (e.getCode() == 10011)
+ } else if (e.getCode() == 10011) {
LOG.error("Wiki creation (" + userWikiSuperDoc + ")
failed: "
+ "wiki database creation failed");
- else
+ } else {
LOG.error("Wiki creation (" + userWikiSuperDoc + ")
failed: "
+ "wiki database creation threw exception", e);
+ }
}
} catch (Exception e) {
LOG.error("Wiki creation (" + userWikiSuperDoc + ") failed: "
@@ -442,8 +469,9 @@
}
String language = userWikiSuperDoc.getLanguage();
- if (language.length() == 0)
+ if (language.length() == 0) {
language = null;
+ }
// Copy base wiki
if (templateWikiName != null) {
@@ -456,9 +484,10 @@
XWikiAttachment packFile = doc.getAttachment(packageName);
- if (packFile == null)
+ if (packFile == null) {
throw new
WikiManagerException(WikiManagerException.ERROR_WIKIMANAGER_CANNOT_CREATE_WIKI,
"Package " + packageName + " does not exists.");
+ }
// Import
PackageAPI importer =
@@ -474,9 +503,10 @@
context.setDatabase(newWikiName);
- if (importer.install() == DocumentInfo.INSTALL_IMPOSSIBLE)
+ if (importer.install() == DocumentInfo.INSTALL_IMPOSSIBLE) {
throw new
WikiManagerException(WikiManagerException.ERROR_WIKIMANAGER_CANNOT_CREATE_WIKI,
"Fail to install package " + packageName);
+ }
}
// Create user page in his wiki
@@ -621,7 +651,7 @@
public List getWikiTemplateList(XWikiContext context) throws XWikiException
{
return
XWikiServerClass.getInstance(context).searchItemDocumentsByField(
- XWikiServerClass.FIELD_visibility,
XWikiServerClass.FIELDL_visibility_template,
+ XWikiServerClass.FIELD_VISIBILITY,
XWikiServerClass.FIELDL_VISIBILITY_TEMPLATE,
"StringProperty", context);
}
@@ -641,7 +671,7 @@
public void createWikiTemplate(XWikiServer wikiSuperDocument, String
packageName,
String comment, XWikiContext context) throws XWikiException
{
-
wikiSuperDocument.setVisibility(XWikiServerClass.FIELDL_visibility_template);
+
wikiSuperDocument.setVisibility(XWikiServerClass.FIELDL_VISIBILITY_TEMPLATE);
// Create empty wiki
WikiManager.getInstance().createNewWikiFromPackage(wikiSuperDocument,
packageName, false,
Modified:
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/WikiManagerException.java
===================================================================
---
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/WikiManagerException.java
2007-10-13 13:12:59 UTC (rev 5388)
+++
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/WikiManagerException.java
2007-10-13 14:04:18 UTC (rev 5389)
@@ -22,52 +22,96 @@
import com.xpn.xwiki.plugin.PluginException;
+/**
+ * Wiki Manager plugin base exception.
+ *
+ * @version $Id: $
+ */
public class WikiManagerException extends PluginException
{
// TODO : move in XWikiException
public static final int ERROR_XWIKI_USER_DOES_NOT_EXIST = 50091;
-
- ////////
+ // //////
+
+ /**
+ * Wiki Manager plugin error identifier.
+ */
public static final int MODULE_PLUGIN_WIKIMANAGER = 50;
-
+
public static final int ERROR_WIKIMANAGER_CANNOT_CREATE_WIKI = 50032;
-
+
public static final int ERROR_WIKIMANAGER_SERVER_DOES_NOT_EXIST = 50034;
+
public static final int ERROR_WIKIMANAGER_WIKISERVER_ALREADY_EXISTS =
50020;
-
+
public static final int ERROR_WIKIMANAGER_WIKI_NAME_FORBIDDEN = 50035;
-
+
public static final int ERROR_WIKIMANAGER_XWIKI_NOT_VIRTUAL = 50036;
-
- ////////
-
+
+ // //////
+
+ /**
+ * The default WikiManagerException.
+ */
+ private static final WikiManagerException DEFAULT_EXCEPTION = new
WikiManagerException();
+
+ // //////
+
+ /**
+ * Create an WikiManagerException.
+ *
+ * @param code the error code.
+ * @param message a literal message about this error.
+ */
public WikiManagerException(int code, String message)
{
super(WikiManagerPlugin.class, code, message);
}
+ /**
+ * Create an WikiManagerException. Replace any parameters found in the
<code>message</code> by
+ * the passed <code>args</code> parameters. The format is the one used by
+ * [EMAIL PROTECTED] java.text.MessageFormat}.
+ *
+ * @param code the error code.
+ * @param message a literal message about this error.
+ * @param e the exception this exception wrap.
+ * @param args the array of parameters to use for replacing "{N}" elements
in the string. See
+ * [EMAIL PROTECTED] java.text.MessageFormat} for the full
syntax
+ */
public WikiManagerException(int code, String message, Throwable e,
Object[] args)
{
super(WikiManagerPlugin.class, code, message, e, args);
}
+ /**
+ * Create an WikiManagerException.
+ *
+ * @param code the error code.
+ * @param message a literal message about this error.
+ * @param e the exception this exception wrap.
+ */
public WikiManagerException(int code, String message, Throwable e)
{
super(WikiManagerPlugin.class, code, message, e);
}
-
- ////////
-
+
+ // //////
+
+ /**
+ * Create default WikiManagerException.
+ */
private WikiManagerException()
{
super(WikiManagerPlugin.class, 0, "No error");
}
-
- private static final WikiManagerException _defaultException = new
WikiManagerException();
-
+
+ /**
+ * @return unique instance of the default ApplicationManagerException.
+ */
public static WikiManagerException getDefaultException()
{
- return _defaultException;
+ return DEFAULT_EXCEPTION;
}
}
Modified:
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/WikiManagerPlugin.java
===================================================================
---
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/WikiManagerPlugin.java
2007-10-13 13:12:59 UTC (rev 5388)
+++
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/WikiManagerPlugin.java
2007-10-13 14:04:18 UTC (rev 5389)
@@ -27,24 +27,42 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+/**
+ * Entry point of the Wiki Manager plugin.
+ *
+ * @version $Id: $
+ */
public class WikiManagerPlugin extends XWikiDefaultPlugin
{
- protected static final Log LOG =
LogFactory.getLog(WikiManagerPlugin.class);
+ /**
+ * Identifier of Wiki Manager plugin.
+ */
+ public static final String PLUGIN_NAME = "wikimanager";
//
////////////////////////////////////////////////////////////////////////////
- private static final String PLUGIN_NAME = "wikimanager";
+ /**
+ * The logging tool.
+ */
+ protected static final Log LOG =
LogFactory.getLog(WikiManagerPlugin.class);
//
////////////////////////////////////////////////////////////////////////////
+ /**
+ * Construction the entry point of the Wiki Manager plugin.
+ *
+ * @param name the identifier of the plugin.
+ * @param className the class name of the entry point of the plugin.
+ * @param context the XWiki context.
+ */
public WikiManagerPlugin(String name, String className, XWikiContext
context)
{
super(name, className, context);
init(context);
}
- /*
- * (non-Javadoc)
+ /**
+ * [EMAIL PROTECTED]
*
* @see com.xpn.xwiki.plugin.XWikiDefaultPlugin#getName()
*/
@@ -53,8 +71,8 @@
return PLUGIN_NAME;
}
- /*
- * (non-Javadoc)
+ /**
+ * [EMAIL PROTECTED]
*
* @see
com.xpn.xwiki.plugin.XWikiDefaultPlugin#getPluginApi(com.xpn.xwiki.plugin.XWikiPluginInterface,
* com.xpn.xwiki.XWikiContext)
@@ -64,8 +82,8 @@
return new WikiManagerPluginApi((WikiManagerPlugin) plugin, context);
}
- /*
- * (non-Javadoc)
+ /**
+ * [EMAIL PROTECTED]
*
* @see
com.xpn.xwiki.plugin.XWikiDefaultPlugin#init(com.xpn.xwiki.XWikiContext)
*/
Modified:
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/WikiManagerPluginApi.java
===================================================================
---
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/WikiManagerPluginApi.java
2007-10-13 13:12:59 UTC (rev 5388)
+++
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/WikiManagerPluginApi.java
2007-10-13 14:04:18 UTC (rev 5389)
@@ -50,7 +50,7 @@
protected static final Log LOG =
LogFactory.getLog(WikiManagerPluginApi.class);
private XWikiExceptionApi defaultException;
-
+
private XWikiPluginMessageTool messageTool;
public WikiManagerPluginApi(WikiManagerPlugin plugin, XWikiContext context)
@@ -59,8 +59,8 @@
this.defaultException =
new XWikiExceptionApi(WikiManagerException.getDefaultException(),
this.context);
-
- // Message Tool
+
+ // Message Tool
Locale locale = (Locale) context.get("locale");
ResourceBundle bundle =
ResourceBundle.getBundle(getPlugin().getName() +
"/ApplicationResources", locale);
@@ -84,24 +84,39 @@
public int createNewWiki(String wikiname, String templateWiki, String pkg,
XWikiServer wikiSuperDocument, boolean failOnExist) throws
XWikiException
{
- if (!hasAdminRights())
+ if (!hasAdminRights()) {
return XWikiException.ERROR_XWIKI_ACCESS_DENIED;
+ }
int returncode = XWikiExceptionApi.ERROR_NOERROR;
wikiSuperDocument.setWikiName(wikiname);
// Some initializations dues to Velocity
- if ("".equals(templateWiki))
+ if ("".equals(templateWiki)) {
templateWiki = null;
+ }
try {
- if (templateWiki != null)
-
WikiManager.getInstance().createNewWikiFromTemplate(wikiSuperDocument,
templateWiki, failOnExist,
this.messageTool.get("wikimanager.plugin.createwikifromtemplate.comment", new
String[] {wikiname, templateWiki}), this.context);
- else if (pkg != null)
-
WikiManager.getInstance().createNewWikiFromPackage(wikiSuperDocument, pkg,
failOnExist,
this.messageTool.get("wikimanager.plugin.createwikifrompackage.comment", new
String[] {wikiname, pkg}), this.context);
- else
- WikiManager.getInstance().createNewWiki(wikiSuperDocument,
failOnExist, this.messageTool.get("wikimanager.plugin.createwiki.comment",
wikiname), this.context);
+ if (templateWiki != null) {
+ WikiManager.getInstance().createNewWikiFromTemplate(
+ wikiSuperDocument,
+ templateWiki,
+ failOnExist,
+
this.messageTool.get("wikimanager.plugin.createwikifromtemplate.comment",
+ new String[] {wikiname, templateWiki}), this.context);
+ } else if (pkg != null) {
+ WikiManager.getInstance().createNewWikiFromPackage(
+ wikiSuperDocument,
+ pkg,
+ failOnExist,
+
this.messageTool.get("wikimanager.plugin.createwikifrompackage.comment",
+ new String[] {wikiname, pkg}), this.context);
+ } else {
+ WikiManager.getInstance().createNewWiki(wikiSuperDocument,
failOnExist,
+
this.messageTool.get("wikimanager.plugin.createwiki.comment", wikiname),
+ this.context);
+ }
} catch (WikiManagerException e) {
LOG.error("Try to create wiki \"" + wikiSuperDocument + "\"", e);
@@ -116,8 +131,9 @@
public int deleteWiki(String wikiName) throws XWikiException
{
- if (!hasAdminRights())
+ if (!hasAdminRights()) {
return XWikiException.ERROR_XWIKI_ACCESS_DENIED;
+ }
int returncode = XWikiExceptionApi.ERROR_NOERROR;
@@ -140,8 +156,7 @@
XWikiServer doc = null;
try {
- doc =
- WikiManager.getInstance().getWiki(wikiName, this.context,
true);
+ doc = WikiManager.getInstance().getWiki(wikiName, this.context,
true);
} catch (WikiManagerException e) {
LOG.error("Try to get wiki \"" + wikiName + "\" document", e);
@@ -153,7 +168,7 @@
}
/**
- * Get the list of wiki associated to a given username
+ * Get the list of wiki associated to a given username.
*
* @param username the name of the user that own the wikis to be retrieved
* @return the list of wikis owned by the user
@@ -164,12 +179,13 @@
List listDocument = Collections.EMPTY_LIST;
try {
- listDocument = WikiManager.getInstance().getWikiList(/*username,
*/this.context);
+ listDocument = WikiManager.getInstance().getWikiList(/* username,
*/this.context);
} catch (WikiManagerException e) {
- if (username != null)
+ if (username != null) {
LOG.error("Try to get wikis documents for user \"" + username
+ "\"", e);
- else
+ } else {
LOG.error("Try to get all wikis documents", e);
+ }
this.context.put("lasterrorcode", new Integer(e.getCode()));
this.context.put("lastexception", new XWikiExceptionApi(e,
this.context));
@@ -179,7 +195,7 @@
}
/**
- * Get all wikis
+ * Get all wikis.
*
* @return a list of all the wikis
* @throws XWikiException
@@ -190,19 +206,19 @@
}
/**
- * Create empty wiki document
+ * Create empty wiki document.
*
* @return Document Empty wiki document
* @throws XWikiException
*/
public XWikiServer createWikiDocument() throws XWikiException
{
- return
(XWikiServer)XWikiServerClass.getInstance(context).newSuperDocument(context);
+ return (XWikiServer)
XWikiServerClass.getInstance(context).newSuperDocument(context);
}
/**
* Check if a Server of the given name exists in the master Wiki by
checking if the
- * "XWiki.XWikiServer{serverName}" document is new
+ * "XWiki.XWikiServer{serverName}" document is new.
*
* @param wikiName the name of the server to be checked
* @return true if server exists, false otherwise
@@ -256,23 +272,28 @@
public int createWikiTemplate(String templateName, String
templateDescription,
String packageName) throws XWikiException
{
- if (!hasAdminRights())
+ if (!hasAdminRights()) {
return XWikiException.ERROR_XWIKI_ACCESS_DENIED;
+ }
int returncode = XWikiExceptionApi.ERROR_NOERROR;
- XWikiServer wikiSuperDocument =
(XWikiServer)XWikiServerClass.getInstance(context).newSuperDocument(context);
+ XWikiServer wikiSuperDocument =
+ (XWikiServer)
XWikiServerClass.getInstance(context).newSuperDocument(context);
wikiSuperDocument.setWikiName(templateName);
wikiSuperDocument.setDescription(templateDescription);
wikiSuperDocument.setServer(templateName + ".template.local");
- wikiSuperDocument.setState(XWikiServerClass.FIELDL_state_active);
+ wikiSuperDocument.setState(XWikiServerClass.FIELDL_STATE_ACTIVE);
wikiSuperDocument.setOwner(this.context.getUser());
try {
- WikiManager.getInstance().createWikiTemplate(wikiSuperDocument,
packageName,
this.messageTool.get("wikimanager.plugin.createwikitemplate.comment", new
String[] {templateName, packageName}),
- this.context);
+ WikiManager.getInstance().createWikiTemplate(
+ wikiSuperDocument,
+ packageName,
+
this.messageTool.get("wikimanager.plugin.createwikitemplate.comment",
+ new String[] {templateName, packageName}), this.context);
} catch (WikiManagerException e) {
LOG.error("Try to create wiki template \"" + wikiSuperDocument +
"\"", e);
@@ -290,8 +311,7 @@
XWikiServer doc = null;
try {
- doc =
- WikiManager.getInstance().getWikiTemplate(wikiName,
this.context, true);
+ doc = WikiManager.getInstance().getWikiTemplate(wikiName,
this.context, true);
} catch (WikiManagerException e) {
LOG.error("Try to get wiki \"" + wikiName + "\" document", e);
@@ -302,7 +322,7 @@
return doc;
}
- /**
+ /**
* @return all the template wiki. Wiki with "visibility" field equals to
"template".
* @throws XWikiException
*/
@@ -312,7 +332,7 @@
try {
List listXWikiDocument =
WikiManager.getInstance().getWikiTemplateList(this.context);
-
+
for (Iterator it = listXWikiDocument.iterator(); it.hasNext();) {
XWikiDocument doc = (XWikiDocument) it.next();
listDocument.add(doc.newDocument(this.context));
Modified:
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/doc/XWikiServer.java
===================================================================
---
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/doc/XWikiServer.java
2007-10-13 13:12:59 UTC (rev 5388)
+++
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/doc/XWikiServer.java
2007-10-13 14:04:18 UTC (rev 5389)
@@ -48,62 +48,62 @@
public String getOwner()
{
- return getStringValue(XWikiServerClass.FIELD_owner);
+ return getStringValue(XWikiServerClass.FIELD_OWNER);
}
public void setOwner(String owner)
{
- setStringValue(XWikiServerClass.FIELD_owner, owner);
+ setStringValue(XWikiServerClass.FIELD_OWNER, owner);
}
public String getDescription()
{
- return getStringValue(XWikiServerClass.FIELD_description);
+ return getStringValue(XWikiServerClass.FIELD_DESCRIPTION);
}
public void setDescription(String description)
{
- setLargeStringValue(XWikiServerClass.FIELD_description, description);
+ setLargeStringValue(XWikiServerClass.FIELD_DESCRIPTION, description);
}
public String getServer()
{
- return getStringValue(XWikiServerClass.FIELD_server);
+ return getStringValue(XWikiServerClass.FIELD_SERVER);
}
public void setServer(String server)
{
- setStringValue(XWikiServerClass.FIELD_server, server);
+ setStringValue(XWikiServerClass.FIELD_SERVER, server);
}
public String getVisibility()
{
- return getStringValue(XWikiServerClass.FIELD_visibility);
+ return getStringValue(XWikiServerClass.FIELD_VISIBILITY);
}
public void setVisibility(String visibility)
{
- setStringValue(XWikiServerClass.FIELD_visibility, visibility);
+ setStringValue(XWikiServerClass.FIELD_VISIBILITY, visibility);
}
public String getLanguage()
{
- return getStringValue(XWikiServerClass.FIELD_language);
+ return getStringValue(XWikiServerClass.FIELD_LANGUAGE);
}
public void setLanguage(String language)
{
- setStringValue(XWikiServerClass.FIELD_language, language);
+ setStringValue(XWikiServerClass.FIELD_LANGUAGE, language);
}
public String getState()
{
- return getStringValue(XWikiServerClass.FIELD_state);
+ return getStringValue(XWikiServerClass.FIELD_STATE);
}
public void setState(String state)
{
- setStringValue(XWikiServerClass.FIELD_state, state);
+ setStringValue(XWikiServerClass.FIELD_STATE, state);
}
/**
Modified:
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/doc/XWikiServerClass.java
===================================================================
---
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/doc/XWikiServerClass.java
2007-10-13 13:12:59 UTC (rev 5388)
+++
xwiki-platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager/doc/XWikiServerClass.java
2007-10-13 14:04:18 UTC (rev 5389)
@@ -28,115 +28,131 @@
import com.xpn.xwiki.objects.classes.BaseClass;
import com.xpn.xwiki.plugin.wikimanager.WikiManagerException;
+/**
+ * [EMAIL PROTECTED]
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.SuperClass}
+ * implementation for XWiki.XWikiServerClass class.
+ *
+ * @version $Id: $
+ * @see
com.xpn.xwiki.plugin.applicationmanager.core.doc.objects.classes.SuperClass
+ * @see AbstractSuperClass
+ */
public class XWikiServerClass extends AbstractSuperClass
{
/**
- * Space of class document.
- */
- private static final String CLASS_SPACE = "XWiki";
-
- /**
- * Prefix of class document.
- */
- private static final String CLASS_PREFIX = "XWikiServer";
-
- // ///
-
- /**
* Name of field <code>owner</code>.
*/
- public static final String FIELD_owner = "owner";
+ public static final String FIELD_OWNER = "owner";
/**
* Pretty name of field <code>owner</code>.
*/
- public static final String FIELDPN_owner = "Owner";
+ public static final String FIELDPN_OWNER = "Owner";
/**
* Name of field <code>description</code>.
*/
- public static final String FIELD_description = "description";
+ public static final String FIELD_DESCRIPTION = "description";
/**
* Pretty name of field <code>description</code>.
*/
- public static final String FIELDPN_description = "Description";
+ public static final String FIELDPN_DESCRIPTION = "Description";
/**
* Name of field <code>server</code>.
*/
- public static final String FIELD_server = "server";
+ public static final String FIELD_SERVER = "server";
/**
* Pretty name of field <code>server</code>.
*/
- public static final String FIELDPN_server = "Server";
+ public static final String FIELDPN_SERVER = "Server";
/**
* Name of field <code>visibility</code>.
*/
- public static final String FIELD_visibility = "visibility";
+ public static final String FIELD_VISIBILITY = "visibility";
- public static final String FIELDL_visibility_public = "public";
+ public static final String FIELDL_VISIBILITY_PUBLIC = "public";
- public static final String FIELDL_visibility_private = "private";
+ public static final String FIELDL_VISIBILITY_PRIVATE = "private";
- public static final String FIELDL_visibility_template = "template";
+ public static final String FIELDL_VISIBILITY_TEMPLATE = "template";
/**
* List of possible values for <code>visibility</code>.
*/
- public static final String FIELDL_visibility =
- FIELDL_visibility_public + "|" + FIELDL_visibility_private + "|"
- + FIELDL_visibility_template;
+ public static final String FIELDL_VISIBILITY =
+ FIELDL_VISIBILITY_PUBLIC + "|" + FIELDL_VISIBILITY_PRIVATE + "|"
+ + FIELDL_VISIBILITY_TEMPLATE;
/**
* Pretty name of field <code>visibility</code>.
*/
- public static final String FIELDPN_visibility = "Visibility";
+ public static final String FIELDPN_VISIBILITY = "Visibility";
/**
* Name of field <code>state</code>.
*/
- public static final String FIELD_state = "state";
+ public static final String FIELD_STATE = "state";
- public static final String FIELDL_state_active = "active";
+ public static final String FIELDL_STATE_ACTIVE = "active";
- public static final String FIELDL_state_inactive = "inactive";
+ public static final String FIELDL_STATE_INACTIVE = "inactive";
- public static final String FIELDL_state_locked = "locked";
+ public static final String FIELDL_STATE_LOCKED = "locked";
/**
* List of possible values for <code>state</code>.
*/
- public static final String FIELDL_state =
- FIELDL_state_active + "|" + FIELDL_state_inactive + "|" +
FIELDL_state_locked;
+ public static final String FIELDL_STATE =
+ FIELDL_STATE_ACTIVE + "|" + FIELDL_STATE_INACTIVE + "|" +
FIELDL_STATE_LOCKED;
/**
* Pretty name of field <code>state</code>.
*/
- public static final String FIELDPN_state = "State";
+ public static final String FIELDPN_STATE = "State";
/**
* Name of field <code>language</code>.
*/
- public static final String FIELD_language = "language";
+ public static final String FIELD_LANGUAGE = "language";
/**
* List of possible values for <code>language</code>.
*/
- public static final String FIELDL_language = "en|fr";
+ public static final String FIELDL_LANGUAGE = "en|fr";
/**
* Pretty name of field <code>language</code>.
*/
- public static final String FIELDPN_language = "Language";
+ public static final String FIELDPN_LANGUAGE = "Language";
// ///
- private static XWikiServerClass instance = null;
+ /**
+ * Space of class document.
+ */
+ private static final String CLASS_SPACE = "XWiki";
/**
+ * Prefix of class document.
+ */
+ private static final String CLASS_PREFIX = "XWikiServer";
+
+ // ///
+
+ private static XWikiServerClass instance;
+
+ /**
+ * Default constructor for XWikiServerClass.
+ */
+ protected XWikiServerClass()
+ {
+ super(CLASS_SPACE, CLASS_PREFIX, false);
+ }
+
+ /**
* Return unique instance of XWikiServerClass and update documents for
this context.
*
* @param context Context.
@@ -146,8 +162,9 @@
public static XWikiServerClass getInstance(XWikiContext context) throws
XWikiException
{
synchronized (XWikiServerClass.class) {
- if (instance == null)
+ if (instance == null) {
instance = new XWikiServerClass();
+ }
}
instance.check(context);
@@ -156,15 +173,8 @@
}
/**
- * Default constructor for XWikiServerClass.
- */
- private XWikiServerClass()
- {
- super(CLASS_SPACE, CLASS_PREFIX, false);
- }
-
- /**
* [EMAIL PROTECTED]
+ *
* @see
com.xpn.xwiki.util.AbstractSuperClass#updateBaseClass(com.xpn.xwiki.objects.classes.BaseClass)
*/
protected boolean updateBaseClass(BaseClass baseClass)
@@ -173,18 +183,18 @@
baseClass.setName(getClassFullName());
- needsUpdate |= baseClass.addUsersField(FIELD_owner, FIELDPN_owner,
false);
- needsUpdate |= baseClass.addTextAreaField(FIELD_description,
FIELDPN_description, 40, 5);
- needsUpdate |= baseClass.addTextField(FIELD_server, FIELDPN_server,
30);
+ needsUpdate |= baseClass.addUsersField(FIELD_OWNER, FIELDPN_OWNER,
false);
+ needsUpdate |= baseClass.addTextAreaField(FIELD_DESCRIPTION,
FIELDPN_DESCRIPTION, 40, 5);
+ needsUpdate |= baseClass.addTextField(FIELD_SERVER, FIELDPN_SERVER,
30);
needsUpdate |=
- baseClass.addStaticListField(FIELD_visibility, FIELDPN_visibility,
FIELDL_visibility);
- needsUpdate |= baseClass.addStaticListField(FIELD_state,
FIELDPN_state, FIELDL_state);
+ baseClass.addStaticListField(FIELD_VISIBILITY, FIELDPN_VISIBILITY,
FIELDL_VISIBILITY);
+ needsUpdate |= baseClass.addStaticListField(FIELD_STATE,
FIELDPN_STATE, FIELDL_STATE);
needsUpdate |=
- baseClass.addStaticListField(FIELD_language, FIELDPN_language,
FIELDL_language);
+ baseClass.addStaticListField(FIELD_LANGUAGE, FIELDPN_LANGUAGE,
FIELDL_LANGUAGE);
return needsUpdate;
}
-
+
/**
* [EMAIL PROTECTED]
*
@@ -207,9 +217,10 @@
{
XWikiDocument doc = getItemDocument(wikiName, context);
- if (validate && doc.isNew())
+ if (validate && doc.isNew()) {
throw new
WikiManagerException(WikiManagerException.ERROR_WIKIMANAGER_SERVER_DOES_NOT_EXIST,
wikiName + " wiki server does not exist");
+ }
return doc;
}
@@ -220,12 +231,15 @@
XWikiDocument doc = getItemDocument(wikiName, context);
if (validate) {
- if (doc.isNew())
+ if (doc.isNew()) {
throw new
WikiManagerException(WikiManagerException.ERROR_WIKIMANAGER_SERVER_DOES_NOT_EXIST,
wikiName + " wiki server does not exist");
- if
(!doc.getStringValue(FIELD_visibility).equals(FIELDL_visibility_template))
+ }
+
+ if
(!doc.getStringValue(FIELD_VISIBILITY).equals(FIELDL_VISIBILITY_TEMPLATE)) {
throw new
WikiManagerException(WikiManagerException.ERROR_WIKIMANAGER_SERVER_DOES_NOT_EXIST,
wikiName + " wiki server template does not exist");
+ }
}
return doc;
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications