@@ -23,6 +23,7 @@ import it.niedermann.owncloud.notes.share.model.toOCShare
2323import it.niedermann.owncloud.notes.shared.model.ApiVersion
2424import it.niedermann.owncloud.notes.shared.model.Capabilities
2525import it.niedermann.owncloud.notes.shared.model.NotesSettings
26+ import it.niedermann.owncloud.notes.shared.util.extensions.getErrorMessage
2627import org.json.JSONObject
2728import java.text.SimpleDateFormat
2829import java.util.Date
@@ -210,7 +211,7 @@ class ShareRepository(private val applicationContext: Context, private val accou
210211
211212 val date = Date (chosenExpDateInMills)
212213
213- return SimpleDateFormat (" yyyy-MM-dd" , Locale .US ).format(date)
214+ return SimpleDateFormat (" yyyy-MM-dd" , Locale .getDefault() ).format(date)
214215 }
215216
216217 fun capabilities (): Capabilities = notesRepository.capabilities
@@ -354,26 +355,19 @@ class ShareRepository(private val applicationContext: Context, private val accou
354355 Log_OC .d(tag, " Response successful: $createShareResponse " )
355356 true to applicationContext.getString(R .string.note_share_created)
356357 } else {
357- val errorBody = response.errorBody()?.string ()
358- if (errorBody == null ) {
358+ val errorMessage = response.getErrorMessage ()
359+ if (errorMessage == null ) {
359360 return false to defaultErrorMessage
360361 }
361- Log_OC .d(tag, " Response failed: $errorBody " )
362- false to (extractErrorMessage(errorBody) ? : defaultErrorMessage)
362+ Log_OC .d(tag, " Response failed: $errorMessage " )
363+ false to errorMessage
363364 }
364365 } catch (e: Exception ) {
365366 Log_OC .d(tag, " Exception while creating share" , e)
366367 false to defaultErrorMessage
367368 }
368369 }
369370
370- private fun extractErrorMessage (json : String ): String {
371- val jsonObject = JSONObject (json)
372- return jsonObject.getJSONObject(" ocs" )
373- .getJSONObject(" meta" )
374- .getString(" message" )
375- }
376-
377371 fun updateSharePermission (
378372 shareId : Long ,
379373 permissions : Int? = null,
0 commit comments