Source:
<code>public void save(final Folder folder, final String existingId, final User user, final boolean respectFrontEndPermissions) throws DotDataException, DotStateException, DotSecurityException { Identifier id = APILocator.getIdentifierAPI().find(folder.getIdentifier()); if(id ==null || !UtilMethods.isSet(id.getId())){ throw new DotStateException("Folder must already have an identifier before saving"); } Host host = APILocator.getHostAPI().find(folder.getHostId(), user, respectFrontEndPermissions); Folder parentFolder = findFolderByPath(id.getParentPath(), id.getHostId(), user, respectFrontEndPermissions); <START> Permissionable parent = "/".equals(id.getParentPath()) || "/System folder".equals(id.getParentPath()) <END> ? host : parentFolder; if(parent ==null){ throw new DotStateException("No Folder Found for id: " + id.getParentPath()); } if (!permissionAPI.doesUserHavePermission(parent, PermissionAPI.PERMISSION_CAN_ADD_CHILDREN, user,respectFrontEndPermissions) || !permissionAPI.doesUserHavePermissions(PermissionableType.FOLDERS, PermissionAPI.PERMISSION_EDIT, user)) { final String userId = user.getUserId() != null ? user.getUserId() : ""; final String parentFolderAsString = "/".equals(id.getParentPath()) || "/System folder".equals(id.getParentPath()) ? host.getName(): parentFolder.getPath(); throw new AddContentToFolderPermissionException(userId, parentFolderAsString); } boolean isNew = folder.getInode() == null; folder.setModDate(new Date()); folder.setName(folder.getName().toLowerCase()); folderFactory.save(folder, existingId); SystemEventType systemEventType = isNew ? SystemEventType.SAVE_FOLDER : SystemEventType.UPDATE_FOLDER; systemEventsAPI.pushAsync(systemEventType, new Payload(folder, Visibility.EXCLUDE_OWNER, new ExcludeOwnerVerifierBean(user.getUserId(), PermissionAPI.PERMISSION_READ, Visibility.PERMISSION))); }</code><technical_language>nice create constants for **"/System folder"** **"/"**</technical_language>

Target:
public void save(final Folder folder, final String existingId, final User user, final boolean respectFrontEndPermissions) throws DotDataException, DotStateException, DotSecurityException { Identifier id = APILocator.getIdentifierAPI().find(folder.getIdentifier()); if(id ==null || !UtilMethods.isSet(id.getId())){ throw new DotStateException("Folder must already have an identifier before saving"); } Host host = APILocator.getHostAPI().find(folder.getHostId(), user, respectFrontEndPermissions); Folder parentFolder = findFolderByPath(id.getParentPath(), id.getHostId(), user, respectFrontEndPermissions); Permissionable parent = FolderAPI.ROOT_PATH.equals(id.getParentPath()) || FolderAPI.SYSTEM_FOLDER_PATH.equals(id.getParentPath()) ? host : parentFolder; if(parent ==null){ throw new DotStateException("No Folder Found for id: " + id.getParentPath()); } if (!permissionAPI.doesUserHavePermission(parent, PermissionAPI.PERMISSION_CAN_ADD_CHILDREN, user,respectFrontEndPermissions) || !permissionAPI.doesUserHavePermissions(PermissionableType.FOLDERS, PermissionAPI.PERMISSION_EDIT, user)) { final String userId = user.getUserId() != null ? user.getUserId() : ""; final String parentFolderAsString = FolderAPI.ROOT_PATH.equals(id.getParentPath()) || FolderAPI.SYSTEM_FOLDER_PATH.equals(id.getParentPath()) ? host.getName(): parentFolder.getPath(); throw new AddContentToFolderPermissionException(userId, parentFolderAsString); } boolean isNew = folder.getInode() == null; folder.setModDate(new Date()); folder.setName(folder.getName().toLowerCase()); folderFactory.save(folder, existingId); SystemEventType systemEventType = isNew ? SystemEventType.SAVE_FOLDER : SystemEventType.UPDATE_FOLDER; systemEventsAPI.pushAsync(systemEventType, new Payload(folder, Visibility.EXCLUDE_OWNER, new ExcludeOwnerVerifierBean(user.getUserId(), PermissionAPI.PERMISSION_READ, Visibility.PERMISSION))); }