This is an automated email from the ASF dual-hosted git repository.
isjarana pushed a commit to branch baremetal
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git
The following commit(s) were added to refs/heads/baremetal by this push:
new 887acb74e externalize sharing core to be released as independent
package
new 18dd742e5 Merge pull request #341 from isururanawaka/baremetal
887acb74e is described below
commit 887acb74e47d7e2939dbd67bddaf0382dfb5201b
Author: Isuru Ranawaka <[email protected]>
AuthorDate: Fri Feb 3 10:02:51 2023 -0500
externalize sharing core to be released as independent package
---
custos-core-services/pom.xml | 1 +
custos-core-services/sharing-core-impl/pom.xml | 43 ++++
.../org/apache/custos/sharing/core/SharingAPI.java | 184 +++++++++++++++++
.../sharing/core/persistance/model/Entity.java | 224 +++++++++++++++++++++
.../sharing/core/persistance/model/EntityType.java | 129 ++++++++++++
.../core/persistance/model/PermissionType.java | 128 ++++++++++++
.../sharing/core/persistance/model/Sharing.java | 168 ++++++++++++++++
.../persistance/repository/EntityRepository.java | 38 ++++
.../repository/EntityTypeRepository.java | 31 +++
.../repository/PermissionTypeRepository.java | 34 ++++
.../repository/SearchEntityRepository.java | 32 +++
.../repository/SearchEntityRepositoryImpl.java | 160 +++++++++++++++
.../persistance/repository/SharingRepository.java | 95 +++++++++
.../src/main/proto/SharingModel.proto | 117 +++++++++++
14 files changed, 1384 insertions(+)
diff --git a/custos-core-services/pom.xml b/custos-core-services/pom.xml
index e90fcaaaa..4fe5b069c 100644
--- a/custos-core-services/pom.xml
+++ b/custos-core-services/pom.xml
@@ -46,6 +46,7 @@
<module>sharing-core-service</module>
<module>custos-logging</module>
<module>custos-messaging-core-service</module>
+ <module>sharing-core-impl</module>
</modules>
diff --git a/custos-core-services/sharing-core-impl/pom.xml
b/custos-core-services/sharing-core-impl/pom.xml
new file mode 100644
index 000000000..7c9df734c
--- /dev/null
+++ b/custos-core-services/sharing-core-impl/pom.xml
@@ -0,0 +1,43 @@
+<?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">
+ <parent>
+ <artifactId>custos-core-services</artifactId>
+ <groupId>org.apache.custos</groupId>
+ <version>1.1-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>sharing-core-impl</artifactId>
+
+ <properties>
+ <maven.compiler.source>11</maven.compiler.source>
+ <maven.compiler.target>11</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jsch</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git
a/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/SharingAPI.java
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/SharingAPI.java
new file mode 100644
index 000000000..9bdaa96ef
--- /dev/null
+++
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/SharingAPI.java
@@ -0,0 +1,184 @@
+package org.apache.custos.sharing.core;
+
+import java.util.List;
+
+/**
+ * Custos Shraing API.All sharing implementations should implement
+ */
+public interface SharingAPI {
+
+ /**
+ * Create an Entity Type
+ * @param entityType
+ */
+ public void createEntityType(EntityType entityType);
+
+ /**
+ * Update a given Entity Type
+ * @param entityType
+ */
+ public void updateEntityType(EntityType entityType);
+
+ /**
+ * Delete a given Entity
+ * @param tenantId
+ * @param entityTypeId
+ */
+ public void deleteEntityType(String tenantId, String entityTypeId);
+
+ /**
+ * Get given Entity Type
+ * @param tenantId
+ * @param entityTypeId
+ * @return
+ */
+ public EntityType getEntityType(String tenantId, String entityTypeId);
+
+ /**
+ * Get Entity Types
+ * @param tenantId
+ * @return
+ */
+ public List<EntityType> getEntityTypes(String tenantId);
+
+
+ /**
+ * Create a given Permission Type
+ * @param permissionType
+ */
+ public void createPermissionType(PermissionType permissionType);
+
+ /**
+ * Update a given Permission Type
+ * @param permissionType
+ */
+ public void updatePermissionType(PermissionType permissionType);
+
+ /**
+ * Delete a given Permission Type
+ * @param tenantId
+ * @param permissionTypeId
+ */
+ public void deletePermissionType(String tenantId, String
permissionTypeId);
+
+ /**
+ * Get a permission Type
+ * @param tenantId
+ * @param permissionTypeId
+ * @return
+ */
+ public EntityType getPermissionType(String tenantId, String
permissionTypeId);
+
+ /**
+ * Get all permission Types
+ * @param tenantId
+ * @return
+ */
+ public List<EntityType> getPermissionTypes(String tenantId);
+
+
+ /**
+ * Create an Entity
+ * @param entity
+ */
+ public void createEntity(Entity entity);
+
+ /**
+ * Update an given Entity
+ * @param entity
+ */
+ public void updateEntity(Entity entity);
+
+ /**
+ * Delete an given Entity
+ * @param tenantId
+ * @param entityId
+ */
+ public void deleteEntity(String tenantId, String entityId);
+
+ /**
+ * Returns true is Entity is exist
+ * @param tenantId
+ * @param entityId
+ * @return
+ */
+ public boolean isEntityExists(String tenantId, String entityId);
+
+ /**
+ * Get Entity wit given ID
+ * @param tenantId
+ * @param entityId
+ * @return
+ */
+ public Entity getEntity(String tenantId, String entityId);
+
+ /**
+ * Search Entities for given search criteria
+ * @param tenantId
+ * @param searchCriteriaList
+ * @param limit
+ * @param offset
+ * @return
+ */
+ public List<Entity> searchEntities(String tenantId, List<SearchCriteria>
searchCriteriaList,int limit, int offset);
+
+ /**
+ * Get list of shared users for given permission for given entityId
+ * @param tenantId
+ * @param entityId
+ * @param permissionTypeId
+ * @return
+ */
+ public List<SharedOwners> getListOfSharedUsers(String tenantId, String
entityId, String permissionTypeId);
+
+ /**
+ * Get list of directly (DIRECT CASCADING, DIRECT NON CASCADING, INDIRECT
CASCADING) shared users of given entity id for given permission type id.
+ * @param tenantId
+ * @param entityId
+ * @param permissionTypeId
+ * @return
+ */
+ public List<SharedOwners> getListOfDirectlySharedUsers(String tenantId,
String entityId, String permissionTypeId);
+
+
+ /**
+ * Get list of directly (DIRECT CASCADING, DIRECT NON CASCADING)shared
groups of given entity id for given permission type id.
+ * @param tenantId
+ * @param entityId
+ * @param permissionTypeId
+ * @return
+ */
+ public List<SharedOwners> getListOfSharedGroups(String tenantId, String
entityId, String permissionTypeId);
+
+ /**
+ * Get list of directly shared groups
+ * @param tenantId
+ * @param entityId
+ * @param permissionTypeId
+ * @return
+ */
+ public List<SharedOwners> getListOfDirectlySharedGroups(String tenantId,
String entityId, String permissionTypeId);
+
+ /**
+ * Revoke permissions of user for given Entity
+ * @param tenantId
+ * @param entityId
+ * @param permissionType
+ * @param usersList
+ * @return
+ */
+ public boolean revokePermission(String tenantId, String entityId, String
permissionType, List<String> usersList);
+
+
+ /**
+ * Check user has access for given entityId for given username
+ * @param tenantId
+ * @param permission
+ * @param username
+ * @return
+ */
+ public boolean userHasAccess(String tenantId, String entityId, String
permission, String username);
+
+
+
+}
diff --git
a/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/model/Entity.java
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/model/Entity.java
new file mode 100644
index 000000000..e3e520e65
--- /dev/null
+++
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/model/Entity.java
@@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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 CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.custos.sharing.core.persistance.model;
+
+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.*;
+import java.sql.Blob;
+import java.util.Date;
+import java.util.Set;
+
[email protected]
+@Table(name = "entity")
+@EntityListeners(AuditingEntityListener.class)
+public class Entity {
+ @Id
+ @Column(nullable = false)
+ private String id;
+
+ @Column(nullable = false)
+ private String externalId;
+
+ @Column
+ private long tenantId;
+
+ @Column
+ private String externalParentId;
+
+ @Column(nullable = false)
+ private String ownerId;
+
+ @Column(nullable = false)
+ private String name;
+
+ @Column
+ private String description;
+
+ @Column
+ @Lob
+ private String fullText;
+
+ @Column
+ private int sharedCount;
+
+ @Column(nullable = false)
+ @Temporal(TemporalType.TIMESTAMP)
+ @CreatedDate
+ private Date createdAt;
+
+ @Column(nullable = false)
+ @Temporal(TemporalType.TIMESTAMP)
+ @LastModifiedDate
+ private Date lastModifiedAt;
+
+
+ @Column(nullable = true)
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date originalCreatedTime;
+
+
+ @Lob
+ @Column
+ private Blob binaryData;
+
+
+ @JoinColumn(name = "entity_type_id")
+ @ManyToOne
+ private EntityType entityType;
+
+ @OneToMany(mappedBy = "entity", cascade = CascadeType.ALL)
+ private Set<Sharing> sharingSet;
+
+ @OneToMany(mappedBy = "inheritedParent", cascade = CascadeType.ALL)
+ private Set<Sharing> inheritedSharing;
+
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+
+ public String getExternalParentId() {
+ return externalParentId;
+ }
+
+ public void setExternalParentId(String externalParentId) {
+ this.externalParentId = externalParentId;
+ }
+
+ public String getOwnerId() {
+ return ownerId;
+ }
+
+ public void setOwnerId(String ownerId) {
+ this.ownerId = ownerId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getFullText() {
+ return fullText;
+ }
+
+ public void setFullText(String fullText) {
+ this.fullText = fullText;
+ }
+
+ public int getSharedCount() {
+ return sharedCount;
+ }
+
+ public void setSharedCount(int sharedCount) {
+ this.sharedCount = sharedCount;
+ }
+
+ public Date getCreatedAt() {
+ return createdAt;
+ }
+
+ public void setCreatedAt(Date createdAt) {
+ this.createdAt = createdAt;
+ }
+
+ public Date getLastModifiedAt() {
+ return lastModifiedAt;
+ }
+
+ public void setLastModifiedAt(Date lastModifiedAt) {
+ this.lastModifiedAt = lastModifiedAt;
+ }
+
+ public Date getOriginalCreatedTime() {
+ return originalCreatedTime;
+ }
+
+ public void setOriginalCreatedTime(Date originalCreatedTime) {
+ this.originalCreatedTime = originalCreatedTime;
+ }
+
+ public Blob getBinaryData() {
+ return binaryData;
+ }
+
+ public void setBinaryData(Blob binaryData) {
+ this.binaryData = binaryData;
+ }
+
+ public long getTenantId() {
+ return tenantId;
+ }
+
+ public void setTenantId(long tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public EntityType getEntityType() {
+ return entityType;
+ }
+
+ public void setEntityType(EntityType entityType) {
+ this.entityType = entityType;
+ }
+
+ public Set<Sharing> getSharingSet() {
+ return sharingSet;
+ }
+
+ public void setSharingSet(Set<Sharing> sharingSet) {
+ this.sharingSet = sharingSet;
+ }
+
+ public Set<Sharing> getInheritedSharing() {
+ return inheritedSharing;
+ }
+
+ public void setInheritedSharing(Set<Sharing> inheritedSharing) {
+ this.inheritedSharing = inheritedSharing;
+ }
+
+ public String getExternalId() {
+ return externalId;
+ }
+
+ public void setExternalId(String externalId) {
+ this.externalId = externalId;
+ }
+}
diff --git
a/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/model/EntityType.java
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/model/EntityType.java
new file mode 100644
index 000000000..05d085d3b
--- /dev/null
+++
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/model/EntityType.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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 CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.custos.sharing.core.persistance.model;
+
+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.*;
+import javax.persistence.Entity;
+import java.util.Date;
+import java.util.Set;
+
+@Entity
+@Table(name = "entity_type")
+@EntityListeners(AuditingEntityListener.class)
+public class EntityType {
+
+ @Id
+ @Column(nullable = false)
+ private String id;
+
+ @Column(nullable = false)
+ private String externalId;
+
+ @Column(nullable = false)
+ private String name;
+
+ @Column
+ private String description;
+
+ @Column(nullable = false)
+ private long tenantId;
+
+ @Column(nullable = false)
+ @Temporal(TemporalType.TIMESTAMP)
+ @CreatedDate
+ private Date createdAt;
+
+ @Column(nullable = false)
+ @Temporal(TemporalType.TIMESTAMP)
+ @LastModifiedDate
+ private Date lastModifiedAt;
+
+ @OneToMany(mappedBy = "entityType", cascade = CascadeType.ALL)
+ private Set<org.apache.custos.sharing.core.persistance.model.Entity>
entitySet;
+
+
+ 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 getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Date getCreatedAt() {
+ return createdAt;
+ }
+
+ public void setCreatedAt(Date createdAt) {
+ this.createdAt = createdAt;
+ }
+
+ public Date getLastModifiedAt() {
+ return lastModifiedAt;
+ }
+
+ public void setLastModifiedAt(Date lastModifiedAt) {
+ this.lastModifiedAt = lastModifiedAt;
+ }
+
+ public Set<org.apache.custos.sharing.core.persistance.model.Entity>
getEntitySet() {
+ return entitySet;
+ }
+
+ public void
setEntitySet(Set<org.apache.custos.sharing.core.persistance.model.Entity>
entitySet) {
+ this.entitySet = entitySet;
+ }
+
+ public long getTenantId() {
+ return tenantId;
+ }
+
+ public void setTenantId(long tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getExternalId() {
+ return externalId;
+ }
+
+ public void setExternalId(String externalId) {
+ this.externalId = externalId;
+ }
+}
diff --git
a/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/model/PermissionType.java
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/model/PermissionType.java
new file mode 100644
index 000000000..29f65cfdf
--- /dev/null
+++
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/model/PermissionType.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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 CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.custos.sharing.core.persistance.model;
+
+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.*;
+import java.util.Date;
+import java.util.Set;
+import javax.persistence.Entity;
+
+@Entity
+@Table(name = "permission_type")
+@EntityListeners(AuditingEntityListener.class)
+public class PermissionType {
+
+ @Id
+ @Column(nullable = false)
+ private String id;
+
+ @Column
+ private String externalId;
+
+ @Column(nullable = false)
+ private long tenantId;
+
+ @Column(nullable = false)
+ private String name;
+
+ @Column
+ private String description;
+
+ @Column(nullable = false)
+ @Temporal(TemporalType.TIMESTAMP)
+ @CreatedDate
+ private Date createdAt;
+
+ @Column(nullable = false)
+ @Temporal(TemporalType.TIMESTAMP)
+ @LastModifiedDate
+ private Date lastModifiedAt;
+
+ @OneToMany(mappedBy = "permissionType", cascade = CascadeType.ALL)
+ private Set<Sharing> sharingSet;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public long getTenantId() {
+ return tenantId;
+ }
+
+ public void setTenantId(long tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Date getCreatedAt() {
+ return createdAt;
+ }
+
+ public void setCreatedAt(Date createdAt) {
+ this.createdAt = createdAt;
+ }
+
+ public Date getLastModifiedAt() {
+ return lastModifiedAt;
+ }
+
+ public void setLastModifiedAt(Date lastModifiedAt) {
+ this.lastModifiedAt = lastModifiedAt;
+ }
+
+ public Set<Sharing> getSharingSet() {
+ return sharingSet;
+ }
+
+ public void setSharingSet(Set<Sharing> sharingSet) {
+ this.sharingSet = sharingSet;
+ }
+
+ public String getExternalId() {
+ return externalId;
+ }
+
+ public void setExternalId(String externalId) {
+ this.externalId = externalId;
+ }
+}
diff --git
a/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/model/Sharing.java
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/model/Sharing.java
new file mode 100644
index 000000000..76459e592
--- /dev/null
+++
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/model/Sharing.java
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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 CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.custos.sharing.core.persistance.model;
+
+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.*;
+import javax.persistence.Entity;
+import java.util.Date;
+
+@Entity
+@Table(name = "sharing")
+@EntityListeners(AuditingEntityListener.class)
+public class Sharing {
+
+ @Id
+ @Column(length = 1000)
+ private String id;
+
+ @Column(nullable = false)
+ private String associatingId;
+
+ @Column(nullable = false)
+ private String associatingIdType;
+
+ @Column(nullable = false)
+ private String sharingType;
+
+
+ private String sharedBy;
+
+ @Column(nullable = false)
+ @Temporal(TemporalType.TIMESTAMP)
+ @CreatedDate
+ private Date createdAt;
+
+ @Column(nullable = false)
+ @Temporal(TemporalType.TIMESTAMP)
+ @LastModifiedDate
+ private Date lastModifiedAt;
+
+
+ @Column(nullable = false)
+ private long tenantId;
+
+
+ @JoinColumn(name = "permission_type_id")
+ @ManyToOne
+ private PermissionType permissionType;
+
+
+ @JoinColumn(name = "entity_id")
+ @ManyToOne
+ private org.apache.custos.sharing.core.persistance.model.Entity entity;
+
+
+ @JoinColumn(name = "inherited_parent_id")
+ @ManyToOne
+ private org.apache.custos.sharing.core.persistance.model.Entity
inheritedParent;
+
+
+ public String getSharedBy() {
+ return sharedBy;
+ }
+
+ public void setSharedBy(String sharedBy) {
+ this.sharedBy = sharedBy;
+ }
+
+ public String getAssociatingId() {
+ return associatingId;
+ }
+
+ public void setAssociatingId(String associatingId) {
+ this.associatingId = associatingId;
+ }
+
+ public String getSharingType() {
+ return sharingType;
+ }
+
+ public void setSharingType(String sharingType) {
+ this.sharingType = sharingType;
+ }
+
+ public Date getCreatedAt() {
+ return createdAt;
+ }
+
+ public void setCreatedAt(Date createdAt) {
+ this.createdAt = createdAt;
+ }
+
+ public Date getLastModifiedAt() {
+ return lastModifiedAt;
+ }
+
+ public void setLastModifiedAt(Date lastModifiedAt) {
+ this.lastModifiedAt = lastModifiedAt;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public long getTenantId() {
+ return tenantId;
+ }
+
+ public void setTenantId(long tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ public PermissionType getPermissionType() {
+ return permissionType;
+ }
+
+ public void setPermissionType(PermissionType permissionType) {
+ this.permissionType = permissionType;
+ }
+
+ public org.apache.custos.sharing.core.persistance.model.Entity getEntity()
{
+ return entity;
+ }
+
+ public void
setEntity(org.apache.custos.sharing.core.persistance.model.Entity entity) {
+ this.entity = entity;
+ }
+
+ public org.apache.custos.sharing.core.persistance.model.Entity
getInheritedParent() {
+ return inheritedParent;
+ }
+
+ public void
setInheritedParent(org.apache.custos.sharing.core.persistance.model.Entity
inheritedParent) {
+ this.inheritedParent = inheritedParent;
+ }
+
+ public String getAssociatingIdType() {
+ return associatingIdType;
+ }
+
+ public void setAssociatingIdType(String associatingIdType) {
+ this.associatingIdType = associatingIdType;
+ }
+}
diff --git
a/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/repository/EntityRepository.java
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/repository/EntityRepository.java
new file mode 100644
index 000000000..24309637c
--- /dev/null
+++
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/repository/EntityRepository.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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 CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.custos.sharing.core.persistance.repository;
+
+
+import org.apache.custos.sharing.core.persistance.model.Entity;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+
+public interface EntityRepository extends JpaRepository<Entity, String>,
SearchEntityRepository {
+
+ public List<Entity> findAllByExternalParentIdAndTenantId(String
externalParentId, long tenantId);
+
+ public List<Entity> findAllByTenantId(long tenantId);
+
+
+
+
+
+}
diff --git
a/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/repository/EntityTypeRepository.java
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/repository/EntityTypeRepository.java
new file mode 100644
index 000000000..f95b0322a
--- /dev/null
+++
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/repository/EntityTypeRepository.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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 CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.custos.sharing.core.persistance.repository;
+
+import org.apache.custos.sharing.core.persistance.model.EntityType;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+
+public interface EntityTypeRepository extends JpaRepository<EntityType,
String> {
+
+
+ public List<EntityType> findAllByTenantId(long tenantId);
+}
diff --git
a/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/repository/PermissionTypeRepository.java
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/repository/PermissionTypeRepository.java
new file mode 100644
index 000000000..125388556
--- /dev/null
+++
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/repository/PermissionTypeRepository.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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 CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.custos.sharing.core.persistance.repository;
+
+
+import org.apache.custos.sharing.core.persistance.model.PermissionType;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+public interface PermissionTypeRepository extends
JpaRepository<PermissionType, String> {
+
+ public List<PermissionType> findAllByTenantId(long tenantId);
+
+ public Optional<PermissionType> findByExternalIdAndTenantId(String
externalId, long tenantId);
+}
diff --git
a/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/repository/SearchEntityRepository.java
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/repository/SearchEntityRepository.java
new file mode 100644
index 000000000..1e7f3d5d1
--- /dev/null
+++
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/repository/SearchEntityRepository.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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 CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.custos.sharing.core.persistance.repository;
+
+
+import org.apache.custos.sharing.core.SearchCriteria;
+import org.apache.custos.sharing.core.persistance.model.Entity;
+
+import java.util.List;
+
+public interface SearchEntityRepository {
+
+
+ List<Entity> searchEntities(long tenantId, List<SearchCriteria>
searchCriteria, int limit, int offset);
+}
diff --git
a/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/repository/SearchEntityRepositoryImpl.java
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/repository/SearchEntityRepositoryImpl.java
new file mode 100644
index 000000000..0f029e8ab
--- /dev/null
+++
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/repository/SearchEntityRepositoryImpl.java
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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 CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.custos.sharing.core.persistance.repository;
+
+import org.apache.custos.sharing.core.EntitySearchField;
+import org.apache.custos.sharing.core.SearchCondition;
+import org.apache.custos.sharing.core.SearchCriteria;
+import org.apache.custos.sharing.core.persistance.model.Entity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Repository;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Repository
+public class SearchEntityRepositoryImpl implements SearchEntityRepository {
+
+ private static final Logger LOGGER =
LoggerFactory.getLogger(SearchEntityRepositoryImpl.class);
+
+ @PersistenceContext
+ EntityManager entityManager;
+
+ @Override
+ public List<Entity> searchEntities(long tenantId, List<SearchCriteria>
searchCriteria, int limit, int offset) {
+
+ Map<String, Object> valueMap = new HashMap<>();
+ String query = createSQLQuery(tenantId, searchCriteria, valueMap,
limit, offset);
+
+
+ Query q = entityManager.createNativeQuery(query, Entity.class);
+ for (String key : valueMap.keySet()) {
+ q.setParameter(key, valueMap.get(key));
+ }
+
+ return q.getResultList();
+
+ }
+
+
+ private String createSQLQuery(long tenantId, List<SearchCriteria>
searchCriteriaList, Map<String, Object> valueMap, int limit, int offset) {
+
+ String query = "SELECT * FROM entity E WHERE ";
+ query = query + "E.tenant_id = :" + "TENANT_ID" + " AND ";
+ valueMap.put("TENANT_ID", tenantId);
+
+ for (SearchCriteria searchCriteria : searchCriteriaList) {
+
+ if (searchCriteria.getSearchField().equals(EntitySearchField.ID)) {
+ if
(searchCriteria.getCondition().equals(SearchCondition.EQUAL)) {
+ query = query + "E.external_id = :" +
EntitySearchField.ID.name() + " AND ";
+ } else {
+ query = query + "E.external_id != :" +
EntitySearchField.ID.name() + " AND ";
+ }
+ valueMap.put(EntitySearchField.ID.name(),
searchCriteria.getValue());
+
+ } else if
(searchCriteria.getSearchField().equals(EntitySearchField.NAME)) {
+ if
(searchCriteria.getCondition().equals(SearchCondition.EQUAL)) {
+ query = query + "E.name LIKE :" +
EntitySearchField.NAME.name() + " AND ";
+ } else {
+ query = query + "E.name NOT LIKE :" +
EntitySearchField.NAME.name() + " AND ";
+ }
+ valueMap.put(EntitySearchField.NAME.name(),
searchCriteria.getValue());
+ } else if
(searchCriteria.getSearchField().equals(EntitySearchField.DESCRIPTION)) {
+ if
(searchCriteria.getCondition().equals(SearchCondition.EQUAL)) {
+ query = query + "E.description LIKE :" +
EntitySearchField.DESCRIPTION.name() + " AND ";
+ } else {
+ query = query + "E.description NOT LIKE :" +
EntitySearchField.DESCRIPTION.name() + " AND ";
+ }
+ valueMap.put(EntitySearchField.DESCRIPTION.name(),
searchCriteria.getValue());
+
+ } else if
(searchCriteria.getSearchField().equals(EntitySearchField.FULL_TEXT)) {
+ if
(searchCriteria.getCondition().equals(SearchCondition.EQUAL)) {
+ query = query + "E.fullText LIKE :" +
EntitySearchField.DESCRIPTION.name() + " AND ";
+ } else {
+ query = query + "E.fullText NOT LIKE :" +
EntitySearchField.DESCRIPTION.name() + " AND ";
+ }
+ valueMap.put(EntitySearchField.FULL_TEXT.name(),
searchCriteria.getValue());
+ } else if
(searchCriteria.getSearchField().equals(EntitySearchField.OWNER_ID)) {
+ if
(searchCriteria.getCondition().equals(SearchCondition.EQUAL)) {
+ query = query + "E.owner_id = :" +
EntitySearchField.OWNER_ID.name() + " AND ";
+ } else {
+ query = query + "E.owner_id != :" +
EntitySearchField.OWNER_ID.name() + " AND ";
+ }
+ valueMap.put(EntitySearchField.OWNER_ID.name(),
searchCriteria.getValue());
+
+ } else if
(searchCriteria.getSearchField().equals(EntitySearchField.ENTITY_TYPE_ID)) {
+ if
(searchCriteria.getCondition().equals(SearchCondition.EQUAL)) {
+ query = query + "E.entity_type_id = :" +
EntitySearchField.ENTITY_TYPE_ID.name() + " AND ";
+ } else {
+ query = query + "E.entity_type_id != :" +
EntitySearchField.ENTITY_TYPE_ID.name() + " AND ";
+ }
+ valueMap.put(EntitySearchField.ENTITY_TYPE_ID.name(),
searchCriteria.getValue() + "@" + tenantId);
+ } else if
(searchCriteria.getSearchField().equals(EntitySearchField.CREATED_AT)) {
+ if (searchCriteria.getCondition().equals(SearchCondition.GTE))
{
+ query = query + "E.created_at >= :" +
EntitySearchField.CREATED_AT.name() + " AND ";
+ } else {
+ query = query + "E.created_at < :" +
EntitySearchField.CREATED_AT.name() + " AND ";
+ }
+ valueMap.put(EntitySearchField.CREATED_AT.name(),
searchCriteria.getValue());
+ } else if
(searchCriteria.getSearchField().equals(EntitySearchField.LAST_MODIFIED_AT)) {
+ if (searchCriteria.getCondition().equals(SearchCondition.GTE))
{
+ query = query + "E.last_modified_at >= :" +
EntitySearchField.ENTITY_TYPE_ID.name() + " AND ";
+ } else {
+ query = query + "E.last_modified_at < :" +
EntitySearchField.ENTITY_TYPE_ID.name() + " AND ";
+ }
+ valueMap.put(EntitySearchField.ENTITY_TYPE_ID.name(),
searchCriteria.getValue());
+ } else if
(searchCriteria.getSearchField().equals(EntitySearchField.PARENT_ID)) {
+ if
(searchCriteria.getCondition().equals(SearchCondition.EQUAL)) {
+ query = query + "E.external_parent_id = :" +
EntitySearchField.PARENT_ID.name() + " AND ";
+ } else {
+ query = query + "E.external_parent_id != :" +
EntitySearchField.PARENT_ID.name() + " AND ";
+ }
+ valueMap.put(EntitySearchField.PARENT_ID.name(),
searchCriteria.getValue());
+ } else if
(searchCriteria.getSearchField().equals(EntitySearchField.SHARED_COUNT)) {
+ if (searchCriteria.getCondition().equals(SearchCondition.GTE))
{
+ query = query + "E.shared_count >= :" +
EntitySearchField.SHARED_COUNT.name() + " AND ";
+ } else {
+ query = query + "E.shared_count < :" +
EntitySearchField.SHARED_COUNT.name() + " AND ";
+ }
+ valueMap.put(EntitySearchField.SHARED_COUNT.name(),
searchCriteria.getValue());
+ }
+
+ }
+
+ query = query.substring(0, query.length() - 5);
+ query = query + " ORDER BY E.created_at DESC";
+
+ if (limit > 0) {
+ query = query + " LIMIT " + ":limit" + " OFFSET " + ":offset";
+ valueMap.put("limit", limit);
+ valueMap.put("offset", offset);
+ }
+
+ return query;
+ }
+
+
+}
diff --git
a/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/repository/SharingRepository.java
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/repository/SharingRepository.java
new file mode 100644
index 000000000..879a8e576
--- /dev/null
+++
b/custos-core-services/sharing-core-impl/src/main/java/org/apache/custos/sharing/core/persistance/repository/SharingRepository.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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 CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.custos.sharing.core.persistance.repository;
+
+import org.apache.custos.sharing.core.persistance.model.Sharing;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+public interface SharingRepository extends JpaRepository<Sharing, String> {
+
+ @Query(value = "select * from sharing s where s.tenant_id = ?1 and
s.entity_id = ?2 " +
+ "and s.sharing_type IN ?3", nativeQuery = true)
+ public List<Sharing> findSharingForEntityOfTenant(long tenantId, String
entityId, List<String> sharingTypes);
+
+ @Modifying
+ @Transactional
+ @Query(value = "delete from sharing s where s.tenant_id = ?1 and
s.entity_id = ?2 " +
+ "and s.sharing_type = ?3", nativeQuery = true)
+ public void removeGivenCascadingPermissionsForEntity(long tenantId, String
entityId, String sharingType);
+
+
+ @Query(value = "select * from sharing s where s.tenant_id = ?1 and
s.entity_id = ?2 " +
+ "and s.permission_type_id = ?3 and s.sharing_type IN ?4",
nativeQuery = true)
+ public List<Sharing> findAllByEntityAndSharingTypeAndPermissionType
+ (long tenantId, String entityId, String permissionTypeId,
List<String> sharingTypes);
+
+
+ @Query(value = "select * from sharing s where s.tenant_id = ?1 and
s.entity_id = ?2 " +
+ "and s.sharing_type IN ?3", nativeQuery = true)
+ public List<Sharing> findAllByEntityAndSharingType
+ (long tenantId, String entityId, List<String> sharingTypes);
+
+
+ @Query(value = "select * from sharing s where s.tenant_id = ?1 and
s.entity_id = ?2 " +
+ "and s.permission_type_id = ?3 and s.associating_id_type = ?4",
nativeQuery = true)
+ public List<Sharing> findAllByEntityAndPermissionTypeAndOwnerType
+ (long tenantId, String entityId, String permissionTypeId, String
associatingIdType);
+
+ @Query(value = "select * from sharing s where s.tenant_id = ?1 and
s.entity_id = ?2 " +
+ " and s.associating_id_type = ?3", nativeQuery = true)
+ public List<Sharing> findAllByEntityAndOwnerType
+ (long tenantId, String entityId, String associatingIdType);
+
+
+ @Query(value = "select * from sharing s where s.tenant_id = ?1 and
s.entity_id = ?2 " +
+ "and s.permission_type_id = ?3 and s.associating_id_type = ?4 and
s.sharing_type IN ?5", nativeQuery = true)
+ public List<Sharing>
findAllByEntityAndPermissionTypeAndOwnerTypeAndSharingType
+ (long tenantId, String entityId, String permissionTypeId, String
associatingIdType, List<String> sharingList);
+
+
+ @Transactional
+ public List<Sharing>
deleteAllByInheritedParentIdAndPermissionTypeIdAndTenantIdAndSharingTypeAndAssociatingId(
+ String inheritedParentId, String permissionTypeId, long tenantId,
String sharingType, String associatedId);
+
+
+ @Transactional
+ public void
deleteAllByEntityIdAndPermissionTypeIdAndAssociatingIdAndTenantIdAndInheritedParentId(
+ String entityId, String permissionTypeId, String associatingId,
long tenantId, String inheritedParentId);
+
+ @Query(value = "select * from sharing s where s.tenant_id = ?1 and
s.entity_id = ?2 " +
+ "and s.permission_type_id IN ?3 and s.associating_id IN ?4",
nativeQuery = true)
+ public List<Sharing> findAllSharingOfEntityForGroupsUnderPermissions(long
tenantId, String entityId,
+
List<String> permissionTypes,
+
List<String> associatedIds);
+
+
+ @Query(value = "select * from sharing s where s.tenant_id = ?1 and
s.associating_id IN ?2 " +
+ "and s.entity_id IN ?3", nativeQuery = true)
+ public List<Sharing> findAllSharingEntitiesForUsers(long tenantId,
+ List<String>
associatedIds,
+ List<String>
entityIds);
+
+
+}
diff --git
a/custos-core-services/sharing-core-impl/src/main/proto/SharingModel.proto
b/custos-core-services/sharing-core-impl/src/main/proto/SharingModel.proto
new file mode 100644
index 000000000..b7a3ba12f
--- /dev/null
+++ b/custos-core-services/sharing-core-impl/src/main/proto/SharingModel.proto
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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 CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+package org.apache.custos.sharing.core;
+
+option go_package = "./pb";
+
+enum SearchCondition {
+ EQUAL = 0;
+ LIKE = 1;
+ GTE = 2;
+ LTE = 3;
+ NOT = 4;
+}
+
+enum EntitySearchField {
+ NAME = 0;
+ DESCRIPTION = 1;
+ ID = 2;
+ FULL_TEXT = 3;
+ OWNER_ID = 4;
+ CREATED_AT = 5;
+ LAST_MODIFIED_AT = 6;
+ ENTITY_TYPE_ID = 7;
+ PARENT_ID = 8;
+ SHARED_COUNT = 9;
+ PERMISSION_TYPE_ID = 10;
+ SHARED_BY=11;
+ SHARED_WITH=12;
+}
+
+
+message EntityType {
+ string id = 1;
+ string name = 2;
+ string description = 3;
+ int64 created_at = 4;
+ int64 updated_at = 5;
+}
+
+message PermissionType {
+ string id = 1;
+ string name = 2;
+ string description = 3;
+ int64 created_at = 4;
+ int64 updated_at = 5;
+}
+
+message Entity {
+ string id = 1;
+ string type = 2;
+ string owner_id = 3;
+ string parent_id = 4;
+ string name = 5;
+ string description = 6;
+ bytes binary_data = 7;
+ string full_text = 8;
+ int64 original_creation_time = 9;
+ int64 created_at = 10;
+ int64 updated_at = 11;
+ int32 shared_count = 12;
+ SharingMetadata sharing_metadata = 13;
+}
+
+message SearchCriteria {
+ EntitySearchField search_field = 1;
+ string value = 2;
+ SearchCondition condition = 3;
+}
+
+message Status {
+ bool status = 1;
+}
+
+message EntityTypes {
+ repeated EntityType types = 1;
+}
+
+message PermissionTypes {
+ repeated PermissionType types = 1;
+}
+
+message Entities {
+ repeated Entity entity_array = 1;
+}
+
+message SharedOwners {
+ repeated string owner_ids = 1;
+}
+
+message SharingMetadata {
+ Entity entity = 1;
+ string owner_id = 2;
+ string owner_type = 3;
+ repeated PermissionType permissions = 4;
+ string shared_by = 5;
+}
\ No newline at end of file