Skip to content

Commit c300862

Browse files
surlitmortagne
authored andcommitted
XWIKI-14136: Dedicate a different page for each version of the extension in the Repository
* Provide a script service for getting the extension version xobject * Fix the download button in ExtensionSheet
1 parent 1557174 commit c300862

File tree

2 files changed

+22
-1
lines changed
  • xwiki-platform-core/xwiki-platform-repository

2 files changed

+22
-1
lines changed

xwiki-platform-core/xwiki-platform-repository/xwiki-platform-repository-server-api/src/main/java/org/xwiki/repository/script/RepositoryScriptService.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import javax.inject.Inject;
2525
import javax.inject.Named;
26+
import javax.inject.Provider;
2627
import javax.inject.Singleton;
2728

2829
import org.xwiki.component.annotation.Component;
@@ -33,10 +34,16 @@
3334
import org.xwiki.extension.repository.ExtensionRepositoryManager;
3435
import org.xwiki.extension.version.Version;
3536
import org.xwiki.model.reference.DocumentReference;
37+
import org.xwiki.query.QueryException;
3638
import org.xwiki.repository.internal.ExtensionStore;
3739
import org.xwiki.repository.internal.RepositoryManager;
3840
import org.xwiki.script.service.ScriptService;
3941

42+
import com.xpn.xwiki.XWikiContext;
43+
import com.xpn.xwiki.XWikiException;
44+
import com.xpn.xwiki.api.Object;
45+
import com.xpn.xwiki.doc.XWikiDocument;
46+
4047
@Component
4148
@Named("repository")
4249
@Singleton
@@ -62,6 +69,9 @@ public class RepositoryScriptService implements ScriptService
6269
@Inject
6370
private Execution execution;
6471

72+
@Inject
73+
private Provider<XWikiContext> contextProvider;
74+
6575
/**
6676
* Store a caught exception in the context, so that it can be later retrieved using {@link #getLastError()}.
6777
*
@@ -122,4 +132,15 @@ public ExtensionSupportPlans resolveExtensionSupportPlans(Collection<String> sup
122132
{
123133
return this.extensionStore.resolveExtensionSupportPlans(supportPlanIds);
124134
}
135+
136+
public Object getVersionObject(String extensionId, String version) throws QueryException, XWikiException
137+
{
138+
XWikiDocument extensionDoc = this.extensionStore.getExistingExtensionDocumentById(extensionId);
139+
XWikiContext context = contextProvider.get();
140+
// FIXME: add some checks
141+
XWikiDocument extensionVersionDocument =
142+
this.extensionStore.getExtensionVersionDocument(extensionDoc, version, context);
143+
return new Object(this.extensionStore.getExtensionVersionObject(extensionVersionDocument, version),
144+
context);
145+
}
125146
}

xwiki-platform-core/xwiki-platform-repository/xwiki-platform-repository-server-ui/src/main/resources/ExtensionCode/ExtensionSheet.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
##------- Download button ------
177177
#set($lastVersion = $doc.getValue("lastVersion"))
178178
#if ("$!lastVersion" != '')
179-
#set ($lastVersionObject = $doc.getObject("ExtensionCode.ExtensionVersionClass", 'version', $lastVersion))
179+
#set ($lastVersionObject = $services.repository.getVersionObject($extension.getProperty('id').value, $lastVersion))
180180
#set ($version = $lastVersionObject.getProperty('version').value)
181181
#set ($download = $lastVersionObject.getProperty("download").value)
182182
#if ("$!download" == '')

0 commit comments

Comments
 (0)