diff options
author | AviZi <avi.ziv@amdocs.com> | 2017-06-09 02:39:56 +0300 |
---|---|---|
committer | AviZi <avi.ziv@amdocs.com> | 2017-06-09 02:39:56 +0300 |
commit | 280f8015d06af1f41a3ef12e8300801c7a5e0d54 (patch) | |
tree | 9c1d3978c04cd28068f02073038c936bb49ca9e0 /openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest | |
parent | fd3821dad11780d33c5373d74c957c442489945e (diff) |
[SDC-29] Amdocs OnBoard 1707 initial commit.
Change-Id: Ie4d12a3f574008b792899b368a0902a8b46b5370
Signed-off-by: AviZi <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest')
9 files changed, 443 insertions, 0 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/pom.xml new file mode 100644 index 0000000000..baa9fdfc2b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/pom.xml @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>activity-log-rest-services</artifactId> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>activity-log-rest</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + + <dependencies> + + + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <version>1</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-activity-log-manager</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>activity-log-rest-types</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-common-rest</artifactId> + <version>${project.version}</version> + </dependency> + <!-- CXF --> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + + </dependencies> + + +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/ActivityLog.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/ActivityLog.java new file mode 100644 index 0000000000..be4cc1bbf5 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/ActivityLog.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.activitylog.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.openecomp.sdcrests.activitylog.types.ActivityLogDto; +import org.springframework.validation.annotation.Validated; + +import javax.validation.constraints.NotNull; +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + + +@Path("/v1.0/activity-logs") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Item Activity Log") +@Validated +public interface ActivityLog { + + @GET + @Path("/{itemId}/versions/{versionId}") + @ApiOperation(value = "List actions log of item", + response = ActivityLogDto.class, + responseContainer = "List") + Response getActivityLog(@ApiParam("Item Id") @PathParam("itemId") String itemId, + @ApiParam("Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/mapping/MapActivityLogEntityToActivityLogDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/mapping/MapActivityLogEntityToActivityLogDto.java new file mode 100644 index 0000000000..2794315188 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/mapping/MapActivityLogEntityToActivityLogDto.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.activitylog.rest.mapping; + +import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; +import org.openecomp.sdcrests.activitylog.types.ActivityLogDto; +import org.openecomp.sdcrests.activitylog.types.ActivityStatus; +import org.openecomp.sdcrests.activitylog.types.ActivityType; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapActivityLogEntityToActivityLogDto extends MappingBase<ActivityLogEntity, ActivityLogDto> { + + + @Override + public void doMapping(ActivityLogEntity source, ActivityLogDto target) { + target.setId(source.getId()); + target.setTimestamp(source.getTimestamp()); + target.setType(source.getType()); + target.setComment(source.getComment()); + target.setUser(source.getUser()); + target.setStatus(new ActivityStatus(source.isSuccess(), source.getMessage())); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/services/ActivityLogImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/services/ActivityLogImpl.java new file mode 100644 index 0000000000..c42d72b7a5 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/services/ActivityLogImpl.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.activitylog.rest.services; + +import org.openecomp.sdc.activityLog.ActivityLogManager; +import org.openecomp.sdc.activityLog.ActivityLogManagerFactory; +import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.activitylog.rest.ActivityLog; +import org.openecomp.sdcrests.activitylog.rest.mapping.MapActivityLogEntityToActivityLogDto; +import org.openecomp.sdcrests.activitylog.types.ActivityLogDto; +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import javax.inject.Named; +import javax.ws.rs.core.Response; +import java.util.Collection; + +@Named +@Service("activityLog") +@Scope(value = "prototype") +public class ActivityLogImpl implements ActivityLog { + + private ActivityLogManager activityLogManager = + ActivityLogManagerFactory.getInstance().createInterface(); + + + @Override + public Response getActivityLog(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_List_Activity_Log.toString()); + + Collection<ActivityLogEntity> activityLogs = + activityLogManager.listActivityLogs(vspId, Version.valueOf(versionId), user); + + MapActivityLogEntityToActivityLogDto mapper = new MapActivityLogEntityToActivityLogDto(); + GenericCollectionWrapper<ActivityLogDto> results = new GenericCollectionWrapper<>(); + for (ActivityLogEntity activityLog : activityLogs) { + results.add(mapper.applyMapping(activityLog, ActivityLogDto.class)); + } + + return Response.ok(results).build(); + } +} + diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/pom.xml new file mode 100644 index 0000000000..6139f04369 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/pom.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>activity-log-rest-types</artifactId> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>activity-log-rest</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityLogDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityLogDto.java new file mode 100644 index 0000000000..dde579554f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityLogDto.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.activitylog.types; + + + +import java.util.Date; + +public class ActivityLogDto { + + private String id; + private Date timestamp; + private String type; + private String comment; + private String user; + private ActivityStatus status; + + public ActivityLogDto(){} + + public String getId() { return id; } + + public void setId(String id) { this.id = id; } + + public Date getTimestamp() { + return timestamp; + } + + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public ActivityStatus getStatus() { + return status; + } + + public void setStatus(ActivityStatus status) { + this.status = status; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityStatus.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityStatus.java new file mode 100644 index 0000000000..326b1b624d --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityStatus.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.sdcrests.activitylog.types; + +public class ActivityStatus { + + private boolean success; + private String message; + + public ActivityStatus() { + } + + public ActivityStatus(boolean success) { + this(success, null); + } + + public ActivityStatus(boolean success, String message) { + this.success = success; + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java new file mode 100644 index 0000000000..dcbad726ab --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.activitylog.types; + +import java.io.Serializable; + +public enum ActivityType implements Serializable { + + CREATE_NEW("Create New"), + CHECKOUT("Check Out"), + CHECKIN("Check In"), + UPLOAD_HEAT("Upload Heat"), + UPLOAD_ARTIFACT("Upload Artifact"), + SUBMIT("Submit"); + + // after collaboration will be added - this will be added: + /* + CREATE_NEW, + COMMIT, + ADD_PERMISSION, + REMOVE_PERMISSION, + */ + + private String name; + + ActivityType(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml new file mode 100644 index 0000000000..cb096cdd30 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.openecomp.sdc</groupId> + <artifactId>activity-log-rest</artifactId> + <packaging>pom</packaging> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + + <modules> + <module>activity-log-rest-services</module> + <module>activity-log-rest-types</module> + </modules> + +</project> |