r953 - xwiki/trunk/src/main/java/com/xpn/xwiki/api
Jeremi Joslin
jeremi at users.forge.objectweb.org
Wed Mar 1 17:23:19 CET 2006
Author: jeremi
Date: 2006-03-01 17:23:18 +0100 (Wed, 01 Mar 2006)
New Revision: 953
Modified:
xwiki/trunk/src/main/java/com/xpn/xwiki/api/Api.java
xwiki/trunk/src/main/java/com/xpn/xwiki/api/Attachment.java
xwiki/trunk/src/main/java/com/xpn/xwiki/api/Class.java
xwiki/trunk/src/main/java/com/xpn/xwiki/api/Context.java
Log:
Add javadocs comments
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/api/Api.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/api/Api.java 2006-03-01 09:58:17 UTC (rev 952)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/api/Api.java 2006-03-01 16:23:18 UTC (rev 953)
@@ -1,24 +1,24 @@
-/*
- * Copyright 2006, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * @author sdumitriu
- */
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @author sdumitriu
+ */
package com.xpn.xwiki.api;
@@ -33,20 +33,36 @@
this.context = context;
}
+ /**
+ * check if the current user has the programming right
+ * @return true if he has
+ */
public boolean checkProgrammingRights() {
return hasProgrammingRights();
}
+ /**
+ * check if the current user has the programming right
+ * @return true if he has
+ */
public boolean hasProgrammingRights() {
com.xpn.xwiki.XWiki xwiki = context.getWiki();
return xwiki.getRightService().hasProgrammingRights(context);
}
+ /**
+ * check if the current user has the Admin right
+ * @return true if he has
+ */
public boolean hasAdminRights() {
com.xpn.xwiki.XWiki xwiki = context.getWiki();
return xwiki.getRightService().hasAdminRights(context);
}
+ /**
+ * check if the current user has the given right
+ * @return true if he has
+ */
public boolean hasAccessLevel(String right, String docname) throws XWikiException {
com.xpn.xwiki.XWiki xwiki = context.getWiki();
return xwiki.getRightService().hasAccessLevel(right, context.getUser(), docname, context);
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/api/Attachment.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/api/Attachment.java 2006-03-01 09:58:17 UTC (rev 952)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/api/Attachment.java 2006-03-01 16:23:18 UTC (rev 953)
@@ -1,24 +1,24 @@
-/*
- * Copyright 2006, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * @author sdumitriu
- */
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @author sdumitriu
+ */
package com.xpn.xwiki.api;
@@ -43,62 +43,128 @@
this.attachment = attachment;
}
+ /**
+ *
+ * @return the document the file is attached to
+ */
public Document getDocument() {
return doc;
}
+
+ /**
+ *
+ * @return the document Id of the attachment
+ */
public long getId() {
return attachment.getId();
}
+ /**
+ *
+ * @return the id of the document the file is attached to
+ */
public long getDocId() {
return doc.getId();
}
+
+ /**
+ *
+ * @return the Attachment size
+ */
public int getFilesize() {
return attachment.getFilesize();
}
+ /**
+ *
+ * @return the attachment name
+ */
public String getFilename() {
return attachment.getFilename();
}
+ /**
+ *
+ * @return the login of the person who attach the file
+ */
public String getAuthor() {
return attachment.getAuthor();
}
+ /**
+ *
+ * @return the last version number of the document
+ */
public String getVersion() {
return attachment.getVersion();
}
+ /**
+ *
+ * @return the RCS object version of the document
+ */
public Version getRCSVersion() {
return attachment.getRCSVersion();
}
+ /**
+ *
+ * @return the list of comments
+ */
public String getComment() {
return attachment.getComment();
}
+ /**
+ *
+ * @return the date of the last uploaded version
+ */
public Date getDate() {
return attachment.getDate();
}
+ /**
+ *
+ * @return the content of the attachment
+ * @throws XWikiException
+ */
public byte[] getContent() throws XWikiException {
return attachment.getContent(context);
}
+ /**
+ *
+ * @return the rcs archive of the attachement
+ */
public Archive getArchive() {
return attachment.getArchive();
}
+ /**
+ *
+ * @return a table with all versions object of the attachment
+ */
+
public Version[] getVersions() {
return attachment.getVersions();
}
+ /**
+ *
+ * @return a list of string with all the versions number in String
+ * @throws XWikiException
+ */
public List getVersionList() throws XWikiException {
return attachment.getVersionList();
}
+ /**
+ *
+ * @return the XWikiAttachment object (without the wrapping) if you have the programming right
+ * @see XWikiAttachment
+ */
public XWikiAttachment getAttachment() {
if (checkProgrammingRights())
return attachment;
@@ -106,10 +172,18 @@
return null;
}
+ /**
+ *
+ * @return the mimetype of the attachment
+ */
public String getMimeType() {
return attachment.getMimeType(context);
}
+ /**
+ *
+ * @return true if it's an image
+ */
public boolean isImage() {
return attachment.isImage(context);
}
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/api/Class.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/api/Class.java 2006-03-01 09:58:17 UTC (rev 952)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/api/Class.java 2006-03-01 16:23:18 UTC (rev 953)
@@ -1,26 +1,26 @@
-/*
- * Copyright 2006, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * @author ludovic
- * @author erwan
- * @author sdumitriu
- */
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @author ludovic
+ * @author erwan
+ * @author sdumitriu
+ */
package com.xpn.xwiki.api;
@@ -42,6 +42,10 @@
return (BaseClass) getCollection();
}
+ /**
+ *
+ * @return an array with the properties of the class
+ */
public Element[] getProperties() {
java.util.Collection coll = getCollection().getFieldList();
if (coll==null)
@@ -54,10 +58,21 @@
return properties;
}
+ /**
+ *
+ * @param name the name of the element
+ * @return the PropertyClass for the given name
+ * @see PropertyClass
+ * @see Element
+ */
public Element get(String name) {
return new PropertyClass((com.xpn.xwiki.objects.classes.PropertyClass) getCollection().safeget(name), context);
}
+ /**
+ *
+ * @return the BaseClass (without the wrapping) if you have the programming right.
+ */
public BaseClass getXWikiClass() {
if (checkProgrammingRights())
return (BaseClass) getCollection();
@@ -65,6 +80,11 @@
return null;
}
+ /**
+ *
+ * @return a new object from this class
+ * @throws XWikiException
+ */
public Object newObject() throws XWikiException {
BaseObject obj = (BaseObject)getBaseClass().newObject(context);
return obj.newObjectApi(obj, context);
Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/api/Context.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/api/Context.java 2006-03-01 09:58:17 UTC (rev 952)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/api/Context.java 2006-03-01 16:23:18 UTC (rev 953)
@@ -1,24 +1,24 @@
-/*
- * Copyright 2006, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * @author ludovic
- */
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @author ludovic
+ */
package com.xpn.xwiki.api;
@@ -36,10 +36,18 @@
super(context);
}
+ /**
+ *
+ * @return an object which contains the Request context
+ */
public XWikiRequest getRequest() {
return context.getRequest();
}
+ /**
+ *
+ * @return an object which contains the response object
+ */
public XWikiResponse getResponse() {
return context.getResponse();
}
@@ -48,35 +56,67 @@
return context.getMode();
}
+ /**
+ *
+ * @return the current database name
+ */
public String getDatabase() {
return context.getDatabase();
}
+ /**
+ *
+ * @return the original database
+ */
public String getOriginalDatabase() {
return context.getOriginalDatabase();
}
+ /**
+ * set the database if you have the programming right
+ * @param database the data name
+ */
public void setDatabase(String database) {
if (checkProgrammingRights())
context.setDatabase(database);
}
+ /**
+ *
+ * @return the url Factory
+ */
public XWikiURLFactory getURLFactory() {
- return context. getURLFactory();
+ return context.getURLFactory();
}
+ /**
+ *
+ * @return true if the server is in virtual mode (ie host more than one wiki)
+ */
public boolean isVirtual() {
return context.isVirtual();
}
+ /**
+ *
+ * @return the requested action
+ */
public String getAction() {
return context.getAction();
}
+ /**
+ *
+ * @return the language of the current user
+ */
public String getLanguage() {
return context.getLanguage();
}
+ /**
+ *
+ * @return the XWiki object if you have the programming right
+ */
public com.xpn.xwiki.XWiki getXWiki() {
if (checkProgrammingRights())
return context.getWiki();
@@ -84,6 +124,10 @@
return null;
}
+ /**
+ *
+ * @return the current requested document
+ */
public XWikiDocument getDoc() {
if (checkProgrammingRights())
return context.getDoc();
@@ -91,15 +135,27 @@
return null;
}
+ /**
+ *
+ * @return the current user which made the request
+ */
public String getUser() {
return context.getUser();
}
+ /**
+ * set the document if you have the programming right
+ * @param doc
+ */
public void setDoc(XWikiDocument doc) {
if (checkProgrammingRights())
context.setDoc(doc);
}
+ /**
+ *
+ * @return the unwrapped version of the context if you have the programming right
+ */
public XWikiContext getContext() {
if (checkProgrammingRights())
return context;
@@ -127,10 +183,18 @@
context.setFinished(finished);
}
+ /**
+ *
+ * @return the cache duration
+ */
public int getCacheDuration() {
return context.getCacheDuration();
}
+ /**
+ *
+ * @param duration in second
+ */
public void setCacheDuration(int duration) {
context.setCacheDuration(duration);
}
More information about the Xwiki-notifications
mailing list