Skip to content
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
7 changes: 7 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog for nextcloud api

## Version 14.2.0
- Add support for the Group Folders app: create, rename, delete and list group
folders, grant/revoke group access, set group permissions and set the folder
quota via the new `GroupFolders` connector and `NextcloudConnector` methods
(issue #109). Thanks to Denis Verkhovsky for the original implementation the
port is based on.

## Version 14.1.6
- 2026-07-24
- Add optional `expireDate` parameter to `doShare` / `doShareAsync`, so an
Expand Down
83 changes: 83 additions & 0 deletions src/main/java/org/aarboard/nextcloud/api/NextcloudConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import org.aarboard.nextcloud.api.filesharing.ShareType;
import org.aarboard.nextcloud.api.filesharing.SharesXMLAnswer;
import org.aarboard.nextcloud.api.filesharing.SingleShareXMLAnswer;
import org.aarboard.nextcloud.api.groupfolders.GroupFolderInfo;
import org.aarboard.nextcloud.api.groupfolders.GroupFolders;
import org.aarboard.nextcloud.api.provisioning.*;
import org.aarboard.nextcloud.api.utils.*;
import org.aarboard.nextcloud.api.webdav.Files;
Expand All @@ -48,6 +50,7 @@ public class NextcloudConnector implements AutoCloseable {
private final ConfigConnector cc;
private final Folders fd;
private final Files fl;
private final GroupFolders gf;

/**
*
Expand Down Expand Up @@ -110,6 +113,7 @@ public NextcloudConnector(String originalServiceUrl, AuthenticationConfig authen
cc = new ConfigConnector(this.serverConfig);
fd = new Folders(this.serverConfig);
fl = new Files(this.serverConfig);
gf = new GroupFolders(this.serverConfig);

} catch (MalformedURLException e) {
throw new IllegalArgumentException(e);
Expand All @@ -131,6 +135,7 @@ public NextcloudConnector(String serverName, boolean useHTTPS, int port,
cc = new ConfigConnector(this.serverConfig);
fd = new Folders(this.serverConfig);
fl = new Files(this.serverConfig);
gf = new GroupFolders(this.serverConfig);
}

/**
Expand Down Expand Up @@ -189,6 +194,84 @@ public void shutdown() throws IOException {
ConnectorCommon.shutdown();
}

/**
* Creates a new group folder (Group Folders app must be installed).
*
* @param mountPoint name/mount point of the group folder
* @return the id of the newly created group folder
*/
public int createGroupFolder(String mountPoint) {
return gf.createGroupFolder(mountPoint);
}

/**
* Renames (changes the mount point of) a group folder.
*
* @param groupFolderId id of the group folder
* @param newMountPoint new name/mount point
*/
public void renameGroupFolder(int groupFolderId, String newMountPoint) {
gf.renameGroupFolder(groupFolderId, newMountPoint);
}

/**
* Deletes a group folder.
*
* @param groupFolderId id of the group folder
*/
public void deleteGroupFolder(int groupFolderId) {
gf.deleteGroupFolder(groupFolderId);
}

/**
* @return all group folders visible to the current user
*/
public Collection<GroupFolderInfo> getGroupFolders() {
return gf.getGroupFolders();
}

/**
* Grants a group access to a group folder.
*
* @param groupFolderId id of the group folder
* @param group group id to grant access to
*/
public void grantAccessToGroupFolder(int groupFolderId, String group) {
gf.grantAccess(groupFolderId, group);
}

/**
* Revokes a group's access to a group folder.
*
* @param groupFolderId id of the group folder
* @param group group id to revoke access from
*/
public void revokeAccessToGroupFolder(int groupFolderId, String group) {
gf.revokeAccess(groupFolderId, group);
}

/**
* Sets the permissions a group has on a group folder.
*
* @param groupFolderId id of the group folder
* @param group group id
* @param permissions permission bit mask (1 = read, 2 = update, 4 =
* create, 8 = delete, 16 = share, 31 = all)
*/
public void setGroupFolderPermissions(int groupFolderId, String group, int permissions) {
gf.setGroupPermissions(groupFolderId, group, permissions);
}

/**
* Sets the quota of a group folder.
*
* @param groupFolderId id of the group folder
* @param quota quota in bytes, or {@code -3} for an unlimited quota
*/
public void setGroupFolderQuota(int groupFolderId, long quota) {
gf.setQuota(groupFolderId, quota);
}

/**
* Close the HTTP client. Perform this to cleanly shut down this
* application.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (C) 2026 a.schild
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.aarboard.nextcloud.api.groupfolders;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.aarboard.nextcloud.api.utils.JsonAnswer;

/**
* Answer of the "create group folder" call. The server returns the full
* created folder, of which we expose the id.
*/
public class GroupFolderAnswer extends JsonAnswer {

@JsonProperty
private GroupFolderInfo data;

@JsonIgnore
public Integer getId() {
if (data != null) {
return data.getId();
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (C) 2026 a.schild
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.aarboard.nextcloud.api.groupfolders;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;

/**
* Information about a single group folder as returned by the
* <a href="https://github.com/nextcloud/groupfolders">Group Folders</a> app.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class GroupFolderInfo {

@JsonProperty
private Integer id;
@JsonProperty
private String mount_point;
@JsonProperty
private Map<String, Integer> groups;
@JsonProperty
private Long quota;

/**
* @return the id of the group folder
*/
@JsonIgnore
public Integer getId() {
return id;
}

/**
* @return the mount point (name) of the group folder
*/
@JsonIgnore
public String getMountPoint() {
return mount_point;
}

/**
* @return the assigned groups mapped to their permission bit mask
*/
@JsonIgnore
public Map<String, Integer> getAssignedGroups() {
return groups;
}

/**
* @return the quota of the group folder in bytes, or {@code -3} for an
* unlimited quota (see the Group Folders app documentation)
*/
@JsonIgnore
public Long getQuota() {
return quota;
}
}
Loading
Loading