Source:
public ProjectSetting createProjectSetting(UserInfo userInfo, ProjectSetting projectSetting) throws DatastoreException, NotFoundException { String parentId = projectSetting.getProjectId(); EntityType nodeType = nodeManager.getNodeType(userInfo, parentId); Class<? extends Entity> nodeClass = EntityTypeUtils.getClassForType(nodeType); if (projectSetting instanceof ProjectCertificationSetting) { if (nodeClass != Project.class) { throw new IllegalArgumentException("The certification setting can be applied only to projects"); } validateACTAccessForCertificationSetting(userInfo); } else { if (nodeClass != Project.class && nodeClass != Folder.class) { throw new IllegalArgumentException("The id is not the id of a project or folder entity"); } if (!authorizationManager.canAccess(userInfo, parentId, ObjectType.ENTITY, ACCESS_TYPE.CREATE).isAuthorized()) { throw new UnauthorizedException("Cannot create settings for this project"); } } Optional<ProjectSetting> parentSetting = getProjectSettingForNode(userInfo, parentId, ProjectSettingsType.upload, ProjectSetting.class); if (parentSetting.isPresent() && isStsStorageLocationSetting(parentSetting.get())) { throw new IllegalArgumentException("Can't override project settings in an STS-enabled folder path"); } projectSetting.setSettingsType(TYPE_MAP.get(projectSetting.getClass())); validateProjectSetting(projectSetting, userInfo); if (!isEntityEmptyWithTrash(parentId) && isStsStorageLocationSetting(projectSetting)) { throw new IllegalArgumentException("Can't enable STS in a non-empty folder"); } String id = projectSettingsDao.create(projectSetting); return projectSettingsDao.get(id); }

Target:
public ProjectSetting createProjectSetting(UserInfo userInfo, ProjectSetting projectSetting) throws DatastoreException, NotFoundException { String parentId = projectSetting.getProjectId(); EntityType nodeType = nodeManager.getNodeType(userInfo, parentId); Class<? extends Entity> nodeClass = EntityTypeUtils.getClassForType(nodeType); if (projectSetting instanceof ProjectCertificationSetting) { if (nodeClass != Project.class) { throw new IllegalArgumentException("The certification setting can be applied only to projects"); } validateACTAccessForCertificationSetting(userInfo); } if (nodeClass != Project.class && nodeClass != Folder.class) { throw new IllegalArgumentException("The id is not the id of a project or folder entity"); } if (!authorizationManager.canAccess(userInfo, parentId, ObjectType.ENTITY, ACCESS_TYPE.CREATE).isAuthorized()) { throw new UnauthorizedException("Cannot create settings for this project"); } Optional<ProjectSetting> parentSetting = getProjectSettingForNode(userInfo, parentId, ProjectSettingsType.upload, ProjectSetting.class); if (parentSetting.isPresent() && isStsStorageLocationSetting(parentSetting.get())) { throw new IllegalArgumentException("Can't override project settings in an STS-enabled folder path"); } projectSetting.setSettingsType(TYPE_MAP.get(projectSetting.getClass())); validateProjectSetting(projectSetting, userInfo); if (!isEntityEmptyWithTrash(parentId) && isStsStorageLocationSetting(projectSetting)) { throw new IllegalArgumentException("Can't enable STS in a non-empty folder"); } String id = projectSettingsDao.create(projectSetting); return projectSettingsDao.get(id); }