Compare commits

...

6 Commits

Author SHA1 Message Date
swapnil.verma
01d907a3e5 [RM-7188] - Removed 'author' and 'since' attributes from files 2022-12-06 15:25:53 +05:30
swapnil.verma
9ec4323b76 [RM-7188] - Removed 'author' and 'since' attributes from files 2022-12-06 15:23:13 +05:30
swapnil.verma
c954f87706 [RM-7188] - Updated license header and version numbers 2022-12-06 11:44:19 +05:30
swapnil.verma
6572baf8e1 [RM-7188] - Updated formatting of methods 2022-12-06 10:13:04 +05:30
swapnil.verma
f295838c66 [RM-7188] - Removed extra exceptions from rm-public-rest-context.xml 2022-12-02 11:51:30 +05:30
swapnil.verma
1be88222e1 [RM-7188] - Added REST endpoint for fetching list of events 2022-12-02 11:46:06 +05:30
4 changed files with 196 additions and 0 deletions

View File

@@ -175,6 +175,10 @@
<property name="nodesModelFactory" ref="nodesModelFactory" />
</bean>
<bean class="org.alfresco.rm.rest.api.events.EventEntityResource">
<property name="recordsManagementEventService" ref="RecordsManagementEventService" />
</bean>
<!-- extended sites bean definition -->
<bean id="rm.sites" class="org.alfresco.rm.rest.api.impl.RMSitesImpl" parent="sites">
<property name="siteSurfConfig" ref="rm.siteSurfConfig" />

View File

@@ -0,0 +1,76 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco 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 3 of the License, or
* (at your option) any later version.
* -
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rm.rest.api.events;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
import org.alfresco.rest.framework.WebApiDescription;
import org.alfresco.rest.framework.resource.EntityResource;
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Paging;
import org.alfresco.rest.framework.resource.parameters.Parameters;
import org.alfresco.rm.rest.api.model.EventInfo;
import java.util.List;
import java.util.stream.Collectors;
/**
* Event entity resource
*/
@EntityResource(name = "events", title = "Events")
public class EventEntityResource implements EntityResourceAction.Read<EventInfo> {
private RecordsManagementEventService recordsManagementEventService;
/**
* Set the records management event service
*
* @param rmEventService Records management event service
*/
public void setRecordsManagementEventService(RecordsManagementEventService rmEventService)
{
this.recordsManagementEventService = rmEventService;
}
@Override
@WebApiDescription(title = "Return a list of events")
public CollectionWithPagingInfo<EventInfo> readAll(Parameters params)
{
Paging paging = params.getPaging();
List<EventInfo> eventInfoList = recordsManagementEventService.getEvents().stream()
.map(EventInfo::fromRecordsManagementEvent)
.collect(Collectors.toList());
int totalCount = eventInfoList.size();
boolean hasMoreItems = paging.getSkipCount() + paging.getMaxItems() < totalCount;
return CollectionWithPagingInfo.asPaged(paging, eventInfoList.stream()
.skip(paging.getSkipCount())
.limit(paging.getMaxItems())
.collect(Collectors.toList()), hasMoreItems, totalCount);
}
}

View File

@@ -0,0 +1,34 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco 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 3 of the License, or
* (at your option) any later version.
* -
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
/**
* Package info that defines the Information Governance Events REST API
*/
@WebApi(name="gs", scope=Api.SCOPE.PUBLIC, version=1)
package org.alfresco.rm.rest.api.events;
import org.alfresco.rest.framework.Api;
import org.alfresco.rest.framework.WebApi;

View File

@@ -0,0 +1,82 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2022 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* Alfresco 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 3 of the License, or
* (at your option) any later version.
* -
* Alfresco 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 Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rm.rest.api.model;
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
/**
* The EventInfo model to be exposed through REST API.
*/
public class EventInfo {
private String id;
private String name;
private String type;
public static EventInfo fromRecordsManagementEvent(RecordsManagementEvent event)
{
EventInfo eventInfo = new EventInfo();
if (event != null) {
eventInfo.setName(event.getDisplayLabel());
eventInfo.setId(event.getName());
eventInfo.setType(event.getType());
}
return eventInfo;
}
public EventInfo() {}
public String getId()
{
return id;
}
public void setId(String id)
{
this.id = id;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getType()
{
return type;
}
public void setType(String type)
{
this.type = type;
}
}