-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
137 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
projectforge-carddav/src/main/kotlin/org/projectforge/carddav/DeleteRequestHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Project ProjectForge Community Edition | ||
// www.projectforge.org | ||
// | ||
// Copyright (C) 2001-2024 Micromata GmbH, Germany (www.micromata.com) | ||
// | ||
// ProjectForge is dual-licensed. | ||
// | ||
// This community edition 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; version 3 of the License. | ||
// | ||
// This community edition 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.projectforge.carddav | ||
|
||
import mu.KotlinLogging | ||
import org.projectforge.carddav.service.AddressService | ||
import org.projectforge.rest.utils.ResponseUtils | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.http.HttpStatus | ||
import org.springframework.stereotype.Service | ||
|
||
private val log = KotlinLogging.logger {} | ||
|
||
@Service | ||
internal class DeleteRequestHandler { | ||
@Autowired | ||
private lateinit var addressService: AddressService | ||
|
||
/** | ||
* Handles uri=/carddav/users/admin/addressbooks/ProjectForge-128.vcf, method=DELETE | ||
* @param writerContext The writer context. | ||
*/ | ||
fun handleDeleteCall(writerContext: WriterContext) { | ||
val requestWrapper = writerContext.requestWrapper | ||
val response = writerContext.response | ||
val contactList = writerContext.contactList ?: emptyList() | ||
log.debug { "handleDeleteCall: ${requestWrapper.request.method}: '${requestWrapper.requestURI}' body=[${requestWrapper.body}]" } | ||
val requestedPath = requestWrapper.requestURI | ||
val contactId = CardDavUtils.extractContactId(requestedPath) | ||
val contact = contactList.find { it.id == contactId } | ||
if (contactId == null) { | ||
log.info { "Contact with id=$contactId not found in personal contact list. Can't delete it." } | ||
ResponseUtils.setValues(response, content = "The resource does not exist.", status = HttpStatus.NOT_FOUND) | ||
return | ||
} | ||
if (addressService.deleteContact(contactId, contact)) { | ||
ResponseUtils.setValues(response, HttpStatus.NO_CONTENT) | ||
} else { | ||
ResponseUtils.setValues(response, content = "The resource does not exist.", status = HttpStatus.NOT_FOUND) | ||
} | ||
log.debug { "handleGetCall: response.content=[]" } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.