Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-37 adding aio-lib-java-events-xdm module: the Adobe I/O Events Extensions models. #38

Merged
merged 2 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions events_xdm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# `aio-lib-java-events-xdm`

`aio-lib-java-events-xdm` holds a few
(Adobe I/O Events) [Xdm](https://github.com/adobe/xdm-event-model) Extensions models.

## Builds

This Library is build with [maven](https://maven.apache.org/)

### Contributing

Contributions are welcomed! Read the [Contributing Guide](../.github/CONTRIBUTING.md) for more information.

### Licensing

This project is licensed under the Apache V2 License. See [LICENSE](../LICENSE.md) for more information.



45 changes: 45 additions & 0 deletions events_xdm/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright 2017 Adobe. All rights reserved.
This file is licensed to you 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 REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.

-->
<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">

<parent>
<groupId>com.adobe</groupId>
<artifactId>aio-lib-java</artifactId>
<version>0.0.10-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>aio-lib-java-events-xdm</artifactId>
<name>Adobe I/O - Events XDM Model Library</name>
<description>Adobe I/O - Events XDM Model Library</description>

<dependencies>

<!-- adobe.io XDM event model -->
<dependency>
<groupId>com.adobe.xdm.event</groupId>
<artifactId>com.adobe.xdm.event.xdm-event-model</artifactId>
</dependency>

<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<classifier>apis</classifier>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2017 Adobe. All rights reserved.
* This file is licensed to you 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 REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
package com.adobe.xdm.event;

import com.adobe.xdm.common.XdmContext;
import com.adobe.xdm.common.XdmEvent;
import com.adobe.xdm.content.ContentRepository;
import com.adobe.xdm.extensions.aem.AemUser;
import com.adobe.xdm.extensions.aem.PageModification;
import com.adobe.xdm.extensions.ims.ImsOrg;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class AemPageModificationEvent extends
XdmEvent<PageModification, ImsOrg, ContentRepository, AemUser> {

public static final String XDM_EVENT_MOVED_TYPE = "xdmMoved";
public static final String XDM_EVENT_VERSION_CREATED_TYPE = "xdmVersioned";

public AemPageModificationEvent() {
super();
}

@Override
@JsonProperty("@type")
public String getType() {
switch (this.getObject().getModificationType()) {
case CREATED:
return XdmContext.XDM_EVENT_CREATED_TYPE;
case DELETED:
return XdmContext.XDM_EVENT_DELETED_TYPE;
case MOVED:
return XDM_EVENT_MOVED_TYPE;
case VERSION_CREATED:
return XDM_EVENT_VERSION_CREATED_TYPE;
default:
return XdmContext.XDM_EVENT_UPDATED_TYPE;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* Copyright 2017 Adobe. All rights reserved.
* This file is licensed to you 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 REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
package com.adobe.xdm.extensions.aem;

import com.adobe.xdm.content.Page;
import com.day.cq.wcm.api.PageModification.ModificationType;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Date;
import java.util.Optional;
import java.util.Set;

@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class PageModification extends Page {

public static final String PAGE_MODIFICATION_TYPE = "pageModification";

private final String movedFromPath;
private final String above;
private final String vid;
private final Date modificationDate;
private final Set<String> modificationPaths;
private final ModificationType modificationType;

public static Optional<PageModification> of(Page page,
com.day.cq.wcm.api.PageModification pageModification) {
if (page == null) {
return Optional.empty();
} else if (pageModification.getType().equals(ModificationType.MOVED)) {
return Optional.of(new PageModification(page,
pageModification.getType(),
pageModification.getVersionId(),
pageModification.getPath(),
pageModification.getAbove(),
pageModification.getModificationDate(),
pageModification.getModificationPaths()));
} else {
return Optional.of(new PageModification(page,
pageModification.getType(),
pageModification.getVersionId(),
null,
pageModification.getAbove(),
pageModification.getModificationDate(),
pageModification.getModificationPaths()));
}
}

private PageModification(Page page, ModificationType modificationType,
String vid, String movedFromPath, String above, Date md,
Set<String> modificationPaths) {
super();

this.setTitle(page.getTitle());
this.setId(page.getId());
this.setPath(page.getPath());
this.setVersion(page.getVersion());
this.setType(PAGE_MODIFICATION_TYPE);
this.modificationType = modificationType;
this.vid = vid;
this.movedFromPath = movedFromPath;
this.above = above;
this.modificationDate = md == null ? new Date() : md;
this.modificationPaths = modificationPaths;
}

@JsonProperty(PAGE_MODIFICATION_TYPE + ":moveFromPath")
public String getMovedFromPath() {
return movedFromPath;
}

@JsonProperty(PAGE_MODIFICATION_TYPE + ":above")
public String getAbove() {
return above;
}

@JsonProperty(PAGE_MODIFICATION_TYPE + ":vid")
public String getVid() {
return vid;
}

@JsonProperty(PAGE_MODIFICATION_TYPE + ":modificationDate")
public Date getModificationDate() {
return modificationDate;
}

@JsonProperty(PAGE_MODIFICATION_TYPE + ":modificationPaths")
public Set<String> getModificationPaths() {
return modificationPaths;
}

@Override
@JsonProperty(PAGE_MODIFICATION_TYPE + ":title")
public String getTitle() {
return super.getTitle();
}

@Override
@JsonProperty(PAGE_MODIFICATION_TYPE + ":path")
public String getPath() {
return super.getPath();
}

@JsonProperty(PAGE_MODIFICATION_TYPE + ":type")
public String getModificationSubType() {
return modificationType.toString();
}

@JsonProperty(PAGE_MODIFICATION_TYPE + ":version")
public String getVersion() {
return super.getVersion();
}

@JsonIgnore
public ModificationType getModificationType() {
return modificationType;
}
}


9 changes: 8 additions & 1 deletion osgi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
<artifactId>aio-lib-java-events-journal</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.adobe</groupId>
<artifactId>aio-lib-java-events-xdm</artifactId>
<version>${project.version}</version>
</dependency>


<dependency>
<groupId>io.jsonwebtoken</groupId>
Expand Down Expand Up @@ -146,6 +152,7 @@
aio-lib-java-events-mgmt,
aio-lib-java-events-ingress,
aio-lib-java-events-journal,
aio-lib-java-events-xdm,
commons-text,
jjwt-api,
jjwt-impl,
Expand Down Expand Up @@ -176,7 +183,7 @@
com.adobe.event.journal.model,com.adobe.event.management,com.adobe.event.management.api,
com.adobe.event.management.model,com.adobe.ims,com.adobe.ims.api,com.adobe.ims.model,
com.adobe.ims.util,com.fasterxml.jackson.*,
com.adobe.aio.lib.Activator
com.adobe.aio.lib.Activator,com.adobe.xdm.*
</Export-Package>
</instructions>
</configuration>
Expand Down
31 changes: 30 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<module>events_mgmt</module>
<module>events_ingress</module>
<module>events_journal</module>
<module>events_xdm</module>
<module>osgi</module>
</modules>

Expand Down Expand Up @@ -94,12 +95,41 @@

<feign.version>11.2</feign.version>
<feign-form.version>3.8.0</feign-form.version>

<com.adobe.aem.uber-jar.version>6.5.0</com.adobe.aem.uber-jar.version>
<javax.jcr.version>2.0</javax.jcr.version>
<xdm.event-model.version>0.94.15</xdm.event-model.version>

</properties>


<dependencyManagement>
<dependencies>

<!-- adobe.io XDM event model -->
<dependency>
<groupId>com.adobe.xdm.event</groupId>
<artifactId>com.adobe.xdm.event.xdm-event-model</artifactId>
<version>${xdm.event-model.version}</version>
<scope>provided</scope>
</dependency>
<!-- Adobe AEM Dependencies -->
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<version>${com.adobe.aem.uber-jar.version}</version>
<classifier>apis</classifier>
<scope>provided</scope>
</dependency>

<!-- JCR -->
<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
<version>${javax.jcr.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
Expand Down Expand Up @@ -157,7 +187,6 @@
<version>${feign-form.version}</version>
</dependency>


<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
Expand Down