(resending, meant to send to the dev list.)
Sorry to drag up old commits but I have a couple of questions.
vmassol (SVN) wrote:
> Author: vmassol
> Date: 2010-01-07 23:02:51 +0100 (Thu, 07 Jan 2010)
> New Revision: 26074
>
> Modified:
> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java
> platform/core/trunk/xwiki-core/src/test/java/com/xpn/xwiki/doc/XWikiDocumentTest.java
> Log:
> XWIKI-4677: Introduce new Model module
>
> * Fixed infinite cycle (revert some previous change). We need to find a solution.
> * Refactored existing code to prevent manual parsing
>
> Modified: platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java
> ===================================================================
> --- platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java 2010-01-07 16:55:03 UTC (rev 26073)
> +++ platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java 2010-01-07 22:02:51 UTC (rev 26074)
> @@ -80,6 +80,7 @@
> import org.xwiki.context.ExecutionContextManager;
> import org.xwiki.model.reference.DocumentReferenceResolver;
> import org.xwiki.model.reference.EntityReferenceSerializer;
> +import org.xwiki.model.reference.WikiReference;
> import org.xwiki.rendering.block.Block;
> import org.xwiki.rendering.block.HeaderBlock;
> import org.xwiki.rendering.block.LinkBlock;
> @@ -359,8 +360,10 @@
> /**
> * Used to create proper {@link Syntax} objects.
> */
> - SyntaxFactory syntaxFactory = Utils.getComponent(SyntaxFactory.class);
> + private SyntaxFactory syntaxFactory = Utils.getComponent(SyntaxFactory.class);
>
Why are we holding a hard reference on the Execution which was present when the document was first loaded
or created?
Is this not a memory leak? Cache holds Document holds Execution holds ExecutionContext holds XWikiContext
holds DocumentArchive?
> + private Execution execution = Utils.getComponent(Execution.class);
> +
> /**
> * @since 2.2M1
> */
> @@ -375,7 +378,9 @@
> @Deprecated
> public XWikiDocument()
> {
> - this(Utils.getComponent(DocumentReferenceResolver.class).resolve(""));
> + // TODO: Replace this with the following when we find a way to not generate a cycle:
> + // this(Utils.getComponent(DocumentReferenceResolver.class).resolve(""));
> + this(new DocumentReference("xwiki", "Main", "WebHome"));
> }
>
> /**
> @@ -397,25 +402,18 @@
> *
> * @param wiki The wiki this document belongs to.
> * @param space The space this document belongs to.
> - * @param name The name of the document.
> + * @param name The name of the document (can contain either the page name or the space and page name)
> * @deprecated since 2.2M1 use {@link #XWikiDocument(org.xwiki.model.reference.DocumentReference)} instead
> */
> @Deprecated
> public XWikiDocument(String wiki, String space, String name)
> {
> - String normalizedPage;
> - String normalizedSpace;
> - int i1 = name.indexOf(".");
> - if (i1 == -1) {
> - normalizedPage = name;
> - normalizedSpace = space;
> - } else {
> - normalizedSpace = name.substring(0, i1);
> - normalizedPage = name.substring(i1 + 1);
> - }
> -
> - init(Utils.getComponent(DocumentReferenceResolver.class, "current/reference").resolve(
> - new DocumentReference(wiki, normalizedSpace, normalizedPage)));
> + // We allow to specify the space in the name (eg name = "space.page"). In this case the passed space is
> + // ignored.
> + DocumentReference reference = resolveReference(name, new DocumentReference(wiki, space, null));
> + // Replace the resolved wiki by the passed wiki
> + reference.setWikiReference(new WikiReference(wiki));
> + init(reference);
> }
>
> public XWikiStoreInterface getStore(XWikiContext context)
> @@ -5846,4 +5844,21 @@
>
> return syntaxId;
> }
> +
> + private DocumentReference resolveReference(String referenceAsString, DocumentReference defaultReference)
> + {
> + XWikiContext xcontext = getXWikiContext();
> + XWikiDocument originalCurentDocument = xcontext.getDoc();
> + try {
> + xcontext.setDoc(new XWikiDocument(defaultReference));
> + return this.currentDocumentReferenceResolver.resolve(referenceAsString);
> + } finally {
> + xcontext.setDoc(originalCurentDocument);
> + }
> + }
> +
How is this different from XWikiDocument#getContext() introduced in 23506?
Is the only difference that the context is the one from when the document was created/loaded rather than the
current context? If so this probably ought to be commented since it is a major trap for anyone who expects
getXWikiContext().getUser() to yield the current user (for example).
> + private XWikiContext getXWikiContext()
> + {
> + return (XWikiContext) this.execution.getContext().getProperty("xwikicontext");
> + }
> }
>
> Modified: platform/core/trunk/xwiki-core/src/test/java/com/xpn/xwiki/doc/XWikiDocumentTest.java
> ===================================================================
> --- platform/core/trunk/xwiki-core/src/test/java/com/xpn/xwiki/doc/XWikiDocumentTest.java 2010-01-07 16:55:03 UTC (rev 26073)
> +++ platform/core/trunk/xwiki-core/src/test/java/com/xpn/xwiki/doc/XWikiDocumentTest.java 2010-01-07 22:02:51 UTC (rev 26074)
> @@ -155,6 +155,29 @@
> this.mockXWikiStoreInterface.stubs().method("search").will(returnValue(new ArrayList<XWikiDocument>()));
> }
>
> + public void testConstructor()
> + {
> + XWikiDocument doc = new XWikiDocument("notused", "space.page");
> + assertEquals("space", doc.getSpaceName());
> + assertEquals("page", doc.getPageName());
> + assertEquals("xwiki", doc.getWikiName());
> +
> + doc = new XWikiDocument("space", "page");
> + assertEquals("space", doc.getSpaceName());
> + assertEquals("page", doc.getPageName());
> + assertEquals("xwiki", doc.getWikiName());
> +
> + doc = new XWikiDocument("wiki", "space", "page");
> + assertEquals("space", doc.getSpaceName());
> + assertEquals("page", doc.getPageName());
> + assertEquals("wiki", doc.getWikiName());
> +
> + doc = new XWikiDocument("wiki", "notused", "notused:space.page");
> + assertEquals("space", doc.getSpaceName());
> + assertEquals("page", doc.getPageName());
> + assertEquals("wiki", doc.getWikiName());
> + }
> +
> public void testGetDisplayTitleWhenNoTitleAndNoContent()
> {
> this.document.setContent("Some content");
>
> _______________________________________________
> notifications mailing list
> notifications(a)xwiki.org
> http://lists.xwiki.org/mailman/listinfo/notifications
>
Currently, api.Document.getPreviousVersion() calls doc.XWikiDocument.getPreviousVersion() which
calls doc.XWikiDocument.getDocumentArchive() which will return null if the document archive is not
currently loaded.
doc.XWikiDocument.getPreviousVersion() is inherently dangerous and should be deprecated then removed.
doc.XWikiDocument.getDocumentArchive() sometimes returns null and should be deprecated then made private.
everywhere doc.XWikiDocument.getDocumentArchive() is used it should be replaced with
doc.XWikiDocument.getDocumentArchive(XWikiContext) which calls loadDocumentArchive first.
What I propose we do now (for 2.3)
#1
Change api.Document.getPreviousVersion() to call getDocumentArchive(getXWikiContext()) and move the logic
from doc.XWikiDocument.getPreviousVersion() into api.Document.getPreviousVersion()
#2
change doc.XWikiDocument.copyDocument(DocumentReference newDocumentReference, XWikiContext context) to call
getDocumentArchive(XWikiContext) instead of getDocumentArchive()
#3
Add warnings in javadoc for:
clone(XWikiDocument document)
cloneInternal(DocumentReference newDocumentReference, boolean keepsIdentity)
to say that they may not copy the archive since they use getDocumentArchive()
#4
mark doc.XWikiDocument.getPreviousVersion() and doc.XWikiDocument.getDocumentArchive() as depricated and
explain why in a comment.
WDYT?
Caleb
The XWiki development team is pleased to announce the release of XWiki
Enterprise and XWiki Enterprise Manager 2.2.5.
This is a bug fix release for the 2.2 branches.
Improvement
* [XSCOLIBRI-206] - Use isInPortletMode and isInServletMode
velocity variables instead of querying context mode
* [XWIKI-5095] - Introduce isInPortletMode and isInServletMode
velocity variables and use them instead of querying context mode
* [XWIKI-5096] - Prevent ActionFilter from being called
recursively and map it only to the action servlet
* [XWIKI-5097] - Make sure SavedRequestRestorerFilter is not
applied recursively
* [XWIKI-5114] - Allow controlling the depth of headers to look
for when generating titles from document's content
Important Bugs fixed
* [XSCOLIBRI-207] - Printing problems with displaying content and comments
* [XPMAIL-24] - If there is an exception while sending mail which
has no message (NPE) another exception is thrown hiding the real one.
* [XWIKI-5076] - Fail to parse content with macro containing only a newline
* [XWIKI-5085] - OfficeImporter does not set title of imported documents
* [XWIKI-5086] - OfficeImporter is generating absolute links when
performing splitting operations
* [XWIKI-5087] - Paging History is broken
* [XWIKI-5093] - Cancel edit JavaScript handler doesn't check if
the URL fragment is present before appending the query string
* [XWIKI-5094] - Administration rights editor cannot be used in portlet mode
* [XWIKI-5107] - URLs are not escaped in link labels if link meta
data is missing
* [XWIKI-5109] - The application/x-www-form-urlencoded reader for
objects and properties is broken
* [XWIKI-5116] - NPE during resolution of XClassReference
* [XWIKI-5119] - In a subwiki, a global user cannot save global documents
* [XE-634] - RecentChanges fails to display with some mysql versions
For more information see the Releases notes at:
http://www.xwiki.org/xwiki/bin/view/Main/ReleaseNotesXWikiEnterprise225
and http://www.xwiki.org/xwiki/bin/view/Main/ReleaseNotesXEM225
Thanks
-The XWiki dev team
Hi,
We've had a user request (Ludovic as a user ;)) to have a config option to decide the header level to consider for a title.
Right now we consider only levels 1 and 2 when computing a title from the doc content.
Thus I'm going to add a config option named xwiki.title.headerdepth and with a default value of 2 (to have the same behavior as now) and use it in XWikiDocument.getRenderedContentTitle().
Note that this is only for the 2.0 syntax (since it's too hard to do for syntax 1.0 and we're not supposed to bring changes to the 1.0 syntax).
Please shout quickly if you're against this.
Thanks
-Vincent
Hi,
I'd like to use the date picker application [1] as a dependency in one
of my project.
It has already been 'released' and AFAIK it is successfully used in
production, I'd like to commit it to
contrib/projects/xwiki-application-datepicker and perform a maven
release (1.0) from the current code.
Here's my +1.
[1] http://code.xwiki.org/xwiki/bin/view/Applications/DatePickerApplication
Thanks,
JV.
Hi devs,
I've been researching what it would take to be able to support the Extension Manager use case regarding components isolation and dependency versioning. I won't go over the details of all I've researched (you can ask questions for that). I'm just proposing a series of steps and a vision of the future for our component model.
If you're interested in the topic I would recommend that you read the Weld tutorial on CDI:
docs.jboss.org/weld/reference/1.0.0/en-US/html_single/
Here are the steps I'm willing to work on and implement.
Step 1: timeframe from now: 1 month
* Use JSR330 annotations
Step 2: timeframe from now: 1 month
* Do a POC of integrating xwiki-component with OSGi (as a xwiki-component-osgi module).
- No versioning management yet.
- Need to use a maven osgi plugin to generate Manifest files from the POMs
* Revise further steps based on result from Step 2.
Step 3: timeframe from now: 2 months
* If step 2 is successful add what's needed to the XWiki Component API to perform generic lookup: CM.lookup(Class, Properties) where Properties is a set of properties registered with the component. It would contain the role hint and the version for example. Also add annotations for specifying dependency version ranges.
Note: After step 3 we have the prereqs for the Extension Manager done. The other steps below are improvements and steps to put us in the standards direction.
Step 4: timeframe from now: 6 months-2 years
* When CDI (JSR299) has taken over the world (ie several DI frameworks migrate to it, it becomes a JavaSE de facto standard at least), migrate to it. We need 2 features not in the spec right now:
- support for dynamic bean registration
- ability to implement CDI over OSGi
* Work with the Weld dev team to add support for those 2 items above. They're interested to implement it if we help them and if these 2 items get done relatively quickly we could migrate to CDI earlier than the timeframe above
* In the meantime we can monitor it carefully to see its progress and we could start migrating to it slowly. Some ideas:
- use the CDI annotations instead of the xwiki-specific ones for the binding part
- introduce new concepts that comes from CDI: decorators, interceptors, producers
- refactor our observation module to use the CDI event model
Step 5: timeframe for now: 2-4 years
* When JSR294 is approved and final (will require at least JDK 7, so XWiki needs to be on JDK7 at least for this, so that's a few years in the future...) migrate to CDI over JSR294 over (Jigsaw, OSGi). The good part is that since we would be using CDI we won't need to change much in our code to do that.
WDYT?
Thanks
-Vincent
Links:
- Weld/JSR299: docs.jboss.org/weld/reference/1.0.0/en-US/html_single/
- Jigsaw: openjdk.java.net/projects/jigsaw/
- JSR330: atinject.googlecode.com/svn/trunk/javadoc/javax/inject/package-summary.html
- JSR294: See description on openjdk.java.net/projects/jigsaw/
I would like to propose changing checkstyle.xml to allow checkstyle to be enabled and disabled
using inline comments. I propose this with some reservation because this can be a slippery slope
but I would rather see the problems isolated in the file than the file excluded.
Also I think this can be used to enforce checkstyle on changes made to code in big files in
the old core.
WDYT?
Caleb
The XWiki development team is pleased to announce the release of
XWiki Enterprise 2.3 Release Candidate 1.
Go grab it at http://www.xwiki.org/xwiki/bin/view/Main/Download
Changes from XWiki Enterprise 2.3 Milestone 2:
* Annotations can now be activated by default from the wiki administration
* Email addresses can now be modified from the user profile
* Upgrade to Pygments 1.3.1
* Upgrade to Groovy 1.7.2
For more information see the Release notes at:
http://www.xwiki.org/xwiki/bin/view/Main/ReleaseNotesXWikiEnterprise23RC1
Thanks
-The XWiki dev team
Hi Devs,
While working on a client project I came across an issue where an exception
is thrown with a message that reads something like:
"Caused by: org.hibernate.HibernateException: Failed to commit or rollback
transaction. Root cause []"
Upon further digging I found the following code in XWikiHibernateBaseStore:
<code>
/**
* Ends a transaction
*
* @param context
* @param commit should we commit or not
*/
public void endTransaction(XWikiContext context, boolean commit)
{
endTransaction(context, commit, false);
}
/**
* Ends a transaction
*
* @param context
* @param commit should we commit or not
* @param withTransaction
* @throws HibernateException
*/
public void endTransaction(XWikiContext context, boolean commit, boolean
withTransaction) throws HibernateException
{
Session session = null;
try {
session = getSession(context);
Transaction transaction = getTransaction(context);
setSession(null, context);
setTransaction(null, context);
if (transaction != null) {
// We need to clean up our connection map first because the
connection will
// be aggressively closed by hibernate 3.1 and more
preCloseSession(session);
if (log.isDebugEnabled()) {
log.debug("Releasing hibernate transaction " + transaction);
}
if (commit) {
transaction.commit();
} else {
transaction.rollback();
}
}
} catch (HibernateException e) {
// Ensure the original cause will get printed.
throw new HibernateException("Failed to commit or rollback transaction.
Root cause ["
+ getExceptionMessage(e) + "]", e);
} finally {
closeSession(session);
}
}
</code>
The problem i see in this code is that if preCloseSession(session) or
transaction.commit() throws an exception, there is no attempt made to
rollback the transaction. Normally a transaction rollback attempt should be
made within the catch block.
If I understand the basics of transaction handling, this code is wrong. I
want to discuss this with you (other developers) because I'm not an expert
in this subject :)
Thanks.
- Asiri