mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-17 14:21:39 +00:00
[RM-7188] - Added REST endpoint for fetching list of events
This commit is contained in:
@@ -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" />
|
||||
@@ -209,6 +213,8 @@
|
||||
<entry key="org.alfresco.service.cmr.attributes.DuplicateAttributeException" value="#{T(org.springframework.extensions.webscripts.Status).STATUS_CONFLICT}" />
|
||||
<entry key="org.alfresco.module.org_alfresco_module_rm.record.RecordCreationException" value="422" />
|
||||
<entry key="org.alfresco.service.cmr.model.FileExistsException" value="409" />
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.EventAlreadyExistsException" value="409" />
|
||||
<entry key="org.alfresco.rest.framework.core.exceptions.EntityNotFoundException" value="404" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* #%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
|
||||
*
|
||||
* @author Swapnil Verma
|
||||
* @since 2.6
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2016 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
|
||||
*
|
||||
* @author Swapnil Verma
|
||||
* @since 2.6
|
||||
*/
|
||||
@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;
|
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* #%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.
|
||||
*
|
||||
* @author Swapnil Verma
|
||||
* @since 7.3.0
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user