As
#set ( $allSpaces = $spaceManager.getAllSpaces() )
is deprecated, how do I use:
#set($spaces = $spaceService.find().fetchMany(new SimplePageRequest(0, 1000))
correctly - above does npot work.
I also assume I need spaceService in :
JVM_SUPPORT_RECOMMENDED_ARGS=-Dconfluence.startup.remigration.disable=true -Dupm.plugin.upload.enabled=true -Dmacro.required.velocity.context.keys=pageManager,spaceService,spaceManagerInternal,attachmentManager,permissionHelper,userAccessor,i18n,dateFormatter,res,settingsManager,htmlUtil,generalUtil,bootstrap,containerContext,action,req,content
Still does not work though
Hi @Normann P_ Nielsen _Netic_ ,
I`ve tried some approaches to inject SpaceService into User Macro, but none of them were working , even after adding all of them to method allowlist and velocity context .
Here is some code that i tried :
<b>Approach 1</b><br>
#set($componentManager = $action.getComponentManager())
#set($spaceService = $componentManager.getComponent("spaceService"))
1:$spaceService<br>
<b>Approach 2</b><br>
#set($spaceService = $containerManager.getComponent("spaceService"))
2:$spaceService<br>
<b>Approach 3</b><br>
#set($spaceService = $componentLocator.getComponent("spaceService"))
3:$spaceService<br>
<b>Approach 4</b><br>
#set($serviceAccessor = $containerManager.getComponent("serviceAccessor"))
#set($spaceService = $serviceAccessor.getSpaceService())
4:$spaceService<br>
<b>Approach 5</b><br>
#set($spaceServiceClass = $action.class.loader.loadClass('com.atlassian.confluence.api.service.content.SpaceService'))
#set($spaceService = $componentLocator.getComponent($spaceServiceClass))
5:$spaceService<br>
<b> Approach 6</b><br>
#set($spaceService = $componentLocator.getComponent("spaceService"))
6: $spaceService<br>
<b> Space Manager<b><br>
#set($spaceManager = $action.spaceManager)
8:$spaceManager<br>
Render:
And only SpaceManager that is deprecated but still usable works. So my take is probably use SpaceManager whilst it is still available)
Thanks, that is apprciated - but also very disappointing.
Seem I have to move to Scriprunner for the job .. :-/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It may not be the actual solution, but I noticed that a closing bracket is missing from your expression?!
This:
#set($spaces = $spaceService.find().fetchMany(new SimplePageRequest(0, 1000))
... should be:
#set($spaces = $spaceService.find().fetchMany(new SimplePageRequest(0, 1000)))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, - that did not solve the Issue though :-) But its highly appeciated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
#set ($groups = $userAccessor.getGroupNamesForUserName($action.remoteUser.name))
Also some deprecated stuff I need to fix
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ChatGPT:
## Create a query for all global spaces
#set($query = $spaceService.newQueryBuilder().forAnySpace().build())
## Run the query
#set($spaces = $spaceService.find($query, $contentPermissionManager.getAllPermissionCheck()))
<ul>
#foreach($space in $spaces)
<li>
<a href="$req.contextPath/display/$space.key">$space.name</a>
($space.key)
</li>
#end
</ul>
Does not work though..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.