Skip to content

Commit

Permalink
feat: Implement Category API - MEED-7944 - Meeds-io/MIPs#170
Browse files Browse the repository at this point in the history
  • Loading branch information
boubaker committed Dec 13, 2024
1 parent 2d26a29 commit a96a448
Show file tree
Hide file tree
Showing 27 changed files with 2,175 additions and 142 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/**
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2020 - 2024 Meeds Association [email protected]
*
* This program 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.
* This program 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 this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package io.meeds.social.category.model;

import java.util.List;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Category implements Cloneable {

/**
* Technical identifier of the element
*/
private long id;

/**
* Parent Tree identifier, 0 when it's the root element
*/
private long parentId;

/**
* The designation of the category, null when no user locale is chosen, else
* it will depends from user Locale
*/
private String name;

/**
* Fontawesome Icon identifier
*/
private String icon;

/**
* Identity Id of the category creator
*/
private long creatorId;

/**
* Identity Id of the owner of the tree (Owner Id who can manage the tree)
*/
private long ownerId;

/**
* Access Permissions of the category
*/
private List<Long> accessPermissionIds;

/**
* Link/Use Permissions of the category
*/
private List<Long> linkPermissionIds;

@Override
protected Category clone() { // NOSONAR
return new Category(id,
parentId,
name,
icon,
creatorId,
ownerId,
accessPermissionIds,
linkPermissionIds);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2020 - 2024 Meeds Association [email protected]
*
* This program 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.
* This program 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 this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package io.meeds.social.category.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class CategoryFilter {

private long ownerId;

private long parentId;

private long depth;

private long offset;

private long limit;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2020 - 2024 Meeds Association [email protected]
*
* This program 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.
* This program 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 this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package io.meeds.social.category.model;

import org.exoplatform.social.metadata.model.MetadataObject;

import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class CategoryObject extends MetadataObject {

public CategoryObject(String type, String id, long spaceId) {
super(type, id, null, spaceId);
}

public CategoryObject(String type, String id, String parentObjectId, long spaceId) {
super(type, id, parentObjectId, spaceId);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2020 - 2024 Meeds Association [email protected]
*
* This program 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.
* This program 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 this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package io.meeds.social.category.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class CategorySearchFilter implements Cloneable {

private String term;

private long ownerId;

private long parentId;

private long offset;

private long limit;

private boolean linkPermission;

@Override
public CategorySearchFilter clone() { // NOSONAR
return new CategorySearchFilter(term,
ownerId,
parentId,
offset,
limit,
linkPermission);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2020 - 2024 Meeds Association [email protected]
*
* This program 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.
* This program 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 this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package io.meeds.social.category.model;

import java.util.List;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class CategoryTree extends Category {

private List<CategoryTree> categories;

public CategoryTree(Category category) {
super(category.getId(),
category.getParentId(),
category.getName(),
category.getIcon(),
category.getCreatorId(),
category.getOwnerId(),
category.getAccessPermissionIds(),
category.getLinkPermissionIds());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2020 - 2024 Meeds Association [email protected]
*
* This program 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.
* This program 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 this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package io.meeds.social.category.plugin;

public interface CategoryPlugin {

/**
* @return The managed Object Type (Space, Activity...)
**/
public String getType();

/**
* Checks whether an associated object to a category is accessible to a user.
* This check will be called after checking whether the user can access or not
* to the category an object (generic ACL check made in Category API switch
* Category properties)
*
* @id Object technical identifier
* @username User technical name (login identifier)
* @return true if the user has access permission to the designated Object
* Type
**/
public boolean canAccess(String objectId, String username);

/**
* Checks whether an associated object to a category is editable to a user.
* This check will be used mainly used to know if a user can modify the object
* in order to associate/link a category into it. This check will be called
* after checking whether the user can link or not to the category an object
* (generic ACL check made in Category API switch Category properties)
*
* @id Object technical identifier
* @username User technical name (login identifier)
* @return true if the user has access permission to the designated Object
* Type identified by its Id
**/
public boolean canEdit(String objectId, String username);

}
Loading

0 comments on commit a96a448

Please sign in to comment.