How to get last modification date and creator of a Space returned from SpaceService?

Hi there,

I’m trying to get rid of all deprecated APIs in Confluence Server by replacing them with the recommended APIs.

Now I’m working on converting SpaceManager-usage into SpaceService. However, I have a problem here:

We are using (inherited from EntityObject → ConfluenceEntityObject → Space)

com.atlassian.confluence.spaces.Space.getLastModificationDate()

and

com.atlassian.confluence.spaces.Space.getCreator()

to get those two values.

How can I get those from

com.atlassian.confluence.api.model.content.Space

I’m getting the new Space-instance like this:

com.atlassian.confluence.api.model.content.Space space2 =
    spaceService.find(ExpansionsParser.parse("description,metadata"))
                            .withKeys(spaceKey)
                            .fetchOrNull();

I was thinking that either description or metadata expansions contain the last modified timestamp and creator, but they seem to be empty maps, nothing at all in them.

Please advice how I can get that information when using SpaceService.

If the ContentEntityObject is going away, that’d be news to me. But you don’t have to use the space.Spaces object. You can use the ContentEntityObject directly.

Please see my response to the question How to get Last Modified Date of a Confleunce Space programmatically? for the last modified date.

For getCreator, I’m not sure. That new way of getting spaces and content needs waaaay better documentation than is out there now.

I didn’t say that ContentEntityObject is going away. ContentManager.getById() has been marked as deprecated and replacement is ContentService.find(…) so if I want to get rid if the getById(), I need to switch to ContentService.find(…) and it returns Content. So I need to figure out a way to replace ContentEntityObject-usage with Content.

Similar thing with SpaceManager → SpaceManager.getSpace(spaceKey) is marked deprecated and replacement is SpaceService.Find(…) and it returns different Space then SpaceManager, hence I need to figure out also way to replace current SpaceManager returned Space usage with the Space-class that SpaceService returns.

I had meant to say the ContentEntityManager. If you look at my other post I linked to, you’ll see that you don’t need ContentService.find(…) to get the last modified date of content in a space. You just need a space key. You hadn’t mentioned you were using the Id.

From what I’ve read and heard, when Atlassian deprecates something, they don’t always fully replace the functionality of the deprecation with until later, and they for sure don’t document them all well. The SOAP APIs are still around even though they were deprecated a long time ago.

At first, I was like you, and wanted to use the new objects in new code or replace the old code. After digging and asking and trying to find anything I could, I’m really not going to worry too much about trying to replace all of the Space/Manager and Page/Manager code with the alternatives until they actually decide to delete them. Only then will they be useful, at least to me, because by that point, they’ll be all thought out (I hope!) and documented somewhere.

They haven’t provided any examples of how to get the .find() code to work in custom user macros in Velocity, which doesn’t like doing more than one thing in one line of code. So, I’m not really worried at this point about those objects being deleted any time soon.

But I wish you luck and hopefully getting the last modified date by space key will work for you!