MCHttpRepository.st
author Claus Gittinger <cg@exept.de>
Mon, 27 Aug 2018 09:38:31 +0200
changeset 1073 8dc1f701d37e
parent 1069 5ea6b7f00935
child 1075 70f7daee8c92
permissions -rw-r--r--
#FEATURE by cg class: MCHttpRepository comment/format in: #readStreamForFileNamed:do: changed: #versionReaderForFileNamed:do:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1021
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
     1
"{ Encoding: utf8 }"
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
     2
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"{ Package: 'stx:goodies/monticello' }"
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
1021
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
     5
"{ NameSpace: Smalltalk }"
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
     6
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
MCFileBasedRepository subclass:#MCHttpRepository
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
	instanceVariableNames:'location user password readerCache'
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
	classVariableNames:''
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
	poolDictionaries:''
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    11
	category:'SCM-Monticello-RemoteRepositories'
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    14
!MCHttpRepository class methodsFor:'documentation'!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    15
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    16
documentation
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    17
"
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    18
    I am general http repository for monticello.
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    19
    I support the general protocol for listing files in a remote repository.
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    20
"
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    21
! !
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    23
!MCHttpRepository class methodsFor:'initialization'!
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    24
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    25
clearPasswords
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    26
	self allSubInstancesDo: [:ea | ea password: ''].
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    27
! !
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    28
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    29
!MCHttpRepository class methodsFor:'instance creation'!
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    30
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    31
basicFromUrl: aZnUrl
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    32
	^ aZnUrl hasUsername
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    33
		ifFalse: [ self location: aZnUrl location ]
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    34
		ifTrue: [ (self repositoryClassFor: aZnUrl location) new
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    35
				location: aZnUrl location;
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    36
				user: aZnUrl username;
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    37
				password: aZnUrl password;
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    38
				yourself  ]
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    39
!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    40
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    41
location: location
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    42
	^ MCServerRegistry uniqueInstance 
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    43
		repositoryAt: location credentialsDo: [ :username :password |
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    44
			(self repositoryClassFor: location) new
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    45
				location: location;
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    46
				user: username;
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    47
				password: password;
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    48
				yourself ]
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    49
!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    50
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    51
location: location user: user password: password
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    52
	^ self new
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    53
		location: location;
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    54
		user: user;
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    55
		password: password
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    56
!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    57
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    58
pharoInboxRepository
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    59
	^ self location: 'http://smalltalkhub.com/mc/Pharo/Pharo60Inbox/main'.
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    60
!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    61
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    62
pharoRepository
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    63
	^ self location: 'http://smalltalkhub.com/mc/Pharo/Pharo60/main'.
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    64
!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    65
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    66
project: aProjectIdentifier
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    67
	^ self location: self baseURL, aProjectIdentifier
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    68
!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    69
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    70
repositoryClassFor: location
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    71
	MCHttpRepository subclassesDo: [ :subclass | 
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    72
		(subclass isResponsibleFor: location)
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    73
			ifTrue: [ ^ subclass ]].
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    74
	^ MCHttpRepository
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    75
! !
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    76
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    77
!MCHttpRepository class methodsFor:'*Komitter-Models'!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    78
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    79
pharoLocations
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    80
	"Answer the locations for both pharo and pharo inbox repositories.
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    81
	No commit should actually be pushed directly there"
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    82
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    83
	^ #('http://smalltalkhub.com/mc/Pharo/Pharo60/main' 
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    84
		'http://smalltalkhub.com/mc/Pharo/Pharo60/main/' 
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    85
		'http://smalltalkhub.com/mc/Pharo/Pharo60Inbox/main'
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    86
		'http://smalltalkhub.com/mc/Pharo/Pharo60Inbox/main/'
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    87
		'http://smalltalkhub.com/mc/Pharo/Pharo50Inbox/main'
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    88
		'http://smalltalkhub.com/mc/Pharo/Pharo50Inbox/main/')
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    89
! !
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    90
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    91
!MCHttpRepository class methodsFor:'*MonticelloGUI'!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    92
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    93
fillInTheBlankRequest
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    94
	^ 'HTTP Repository:'
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    95
			
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    96
!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    97
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    98
morphicConfigure
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
    99
	^ self fillInTheBlankConfigure
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   100
! !
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   101
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   102
!MCHttpRepository class methodsFor:'accessing'!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   103
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   104
baseURL
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   105
	^ ''
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   106
!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   107
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   108
urlSchemes
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   109
	^ #(http https)
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   110
! !
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   111
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   112
!MCHttpRepository class methodsFor:'queries'!
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
creationTemplate
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   115
	^self creationTemplateLocation: 'http://www.squeaksource.com/'
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
		user: 'squeak'
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
		password: 'squeak'
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   118
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
creationTemplateLocation: location user: user password: password
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   122
        ^
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   123
self name,'
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   124
        location: %1
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   125
        user: %2
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   126
        password: %3' 
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   127
            bindWith: location storeString 
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   128
            with: user storeString
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   129
            with: password storeString
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   130
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   131
    "Modified: / 16-09-2010 / 14:34:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   132
    "Modified: / 26-08-2018 / 14:28:47 / Claus Gittinger"
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
description
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
	^ 'HTTP'
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
! !
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   139
!MCHttpRepository class methodsFor:'testing'!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   140
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   141
isResponsibleFor: aURLString
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   142
	"Override in subclasses to enable custom instances for certain URLs"
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   143
	^ true
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   144
! !
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   145
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   146
!MCHttpRepository methodsFor:'*Komitter-Models'!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   147
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   148
isPrivatePharoRepository
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   149
	
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   150
	^ self class pharoLocations includes: self location
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   151
!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   152
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   153
isRemote
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   154
	^ self isPrivatePharoRepository not
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   155
!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   156
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   157
koRemote
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   158
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   159
	^ KomitHttpRemote new
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   160
		remote: self;
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   161
		yourself
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   162
! !
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   163
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   164
!MCHttpRepository methodsFor:'*metacello-mc'!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   165
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   166
asRepositorySpecFor: aMetacelloMCProject
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   167
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   168
	^(aMetacelloMCProject repositorySpec)
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   169
		description:  self description;
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   170
	 	type: 'http';
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   171
		yourself
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   172
! !
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   173
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   174
!MCHttpRepository methodsFor:'accessing'!
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   176
credentials
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   177
	^ MCServerCredentials user: self user password: self password
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   178
!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   179
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   180
credentials: mcServerCredentials
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   181
	self user: mcServerCredentials username.
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   182
	self password: mcServerCredentials password.
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   183
!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   184
778
3cdbfc6ff7da class: MCHttpRepository
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
   185
location
3cdbfc6ff7da class: MCHttpRepository
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
   186
      ^location 
3cdbfc6ff7da class: MCHttpRepository
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
   187
!
3cdbfc6ff7da class: MCHttpRepository
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
   188
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
location: aUrlString
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   190
	location := aUrlString
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
locationWithTrailingSlash
1069
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   194
        ^ (self location endsWith: '/')
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   195
                ifTrue: [self location]
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   196
                ifFalse: [self location, '/']
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   197
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   198
    "Modified: / 26-08-2018 / 16:16:22 / Claus Gittinger"
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
password
1021
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   202
        self userAndPasswordFromSettingsDo: [:usr :pwd | ^pwd].
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   203
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   204
        self user isEmpty ifTrue: [^password ? ''].
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
1021
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   206
        [password isEmpty] whileTrue: [
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   207
                | answer dialog |
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   208
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   209
                dialog := UIManager isNil ifTrue:[Dialog] ifFalse:[ UIManager default ].
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
1021
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   211
                "Give the user a chance to change the login"
1069
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   212
                answer := dialog request: 'User name for ' translated, String cr, self location
1021
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   213
                        initialAnswer: self user.
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   214
                answer isEmpty
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   215
                        ifTrue: [^password]
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   216
                        ifFalse: [self user: answer].
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   217
                
1069
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   218
                password := UIManager default requestPassword: 'Password for' translated, ' "', self user, '" ', 'at ' translated, String cr, self location.
1021
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   219
        ].
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
1021
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   221
        ^ password
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   222
1069
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   223
    "Modified: / 26-08-2018 / 16:16:29 / Claus Gittinger"
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
password: passwordString
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   227
	password := passwordString
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   230
project
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   231
	"Return a project name"
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   232
	^ (self location splitOn: $/) last
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   233
!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   234
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
user
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
	self userAndPasswordFromSettingsDo: [:usr :pwd | ^usr].
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
	"not in settings"
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
	^user
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
user: userString
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   242
	user := userString
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   243
! !
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   244
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   245
!MCHttpRepository methodsFor:'actions'!
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   246
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   247
parseFileNamesFromStream: aStream
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   248
	| names fullName |
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   249
	names := OrderedCollection new.
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   250
	[aStream atEnd] whileFalse:
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   251
		[[aStream upTo: $<. {$a. $A. nil} includes: aStream next] whileFalse.
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   252
		aStream upTo: $".
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   253
		aStream atEnd ifFalse: [
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   254
			fullName := aStream upTo: $".
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   255
			names add: fullName urlDecoded ]].
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   256
	^ names
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   259
retryOnCredentialRequest: aBlock
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   260
	aBlock	on: MCPermissionDenied do: [ :error | |credentials| 
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   261
		credentials := MCCredentialsRequest 
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   262
							signalUrl: self location
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   263
							username: self user
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   264
							password: self password.
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   265
		credentials 
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   266
			ifNotNil: [ 
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   267
				self credentials: credentials.
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   268
				^ self retryOnCredentialRequest: aBlock ]]
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   269
!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   270
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   271
urlForFileNamed: aString
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   272
	^ self locationWithTrailingSlash, aString urlEncoded
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   273
! !
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   274
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   275
!MCHttpRepository methodsFor:'displaying'!
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   276
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   277
displayString
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   278
1069
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   279
    ^ self location
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   280
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   281
    "Created: / 14-09-2010 / 23:20:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1069
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   282
    "Modified: / 26-08-2018 / 16:15:38 / Claus Gittinger"
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
! !
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   285
!MCHttpRepository methodsFor:'i/o'!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   286
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   287
cacheRawVersionNamed: aString stream: contents
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   288
	"directly forward the contents to the cache repository. 
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   289
	this avoids and unnecessary serialization step"
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   290
	MCCacheRepository uniqueInstance 
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   291
		writeStreamForFileNamed: aString 
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   292
		replace: true 
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   293
		do: [ :s| s nextPutAll: contents ]
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   294
!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   295
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   296
displayProgress: label during: workBlock
1069
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   297
        | nextUpdateTime |
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   298
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   299
        Smalltalk isSmalltalkX ifTrue:[
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   300
            workBlock value.
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   301
        ].
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   302
        
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   303
        nextUpdateTime := 0.
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   304
        ^UIManager default displayProgress: label 
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   305
                from: 0.0 to: 1.0 during:[:bar|
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   306
                        [workBlock value] on: HTTPProgress do:[:ex|
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   307
                                (ex total == nil or: [ex amount == nil]) ifFalse:[
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   308
                                        (nextUpdateTime < Time millisecondClockValue 
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   309
                                                or:[ex total = ex amount]) ifTrue:[
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   310
                                                        bar current: ex amount asFloat / ex total asFloat.
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   311
                                                        nextUpdateTime := Time millisecondClockValue + 100.
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   312
                                        ].
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   313
                                ].
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   314
                                ex resume.
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   315
                        ]
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   316
                ].
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   317
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   318
    "Modified: / 26-08-2018 / 14:57:19 / Claus Gittinger"
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   319
!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   320
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   321
handleUnsuccessfulResponse: aZnResponse
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   322
	(#(403 401) includes: aZnResponse code)
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   323
		ifTrue: [ MCPermissionDenied signalFor: self ].
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   324
	Error signal: 'Could not save version.'
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   325
!
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   326
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   327
loadAllFileNames
1069
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   328
        | client response |
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   329
        self displayProgress: 'Loading all file names from ', self description during: [
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   330
            Smalltalk isSmalltalkX ifTrue:[
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   331
                response := HTTPInterface 
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   332
                                get: self locationWithTrailingSlash, '?C=M;O=D' 
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   333
                                userName: self user 
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   334
                                password: self password.
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   335
                response responseCode ~= 200 ifTrue: [
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   336
                    self error:('Could not access "',self location,'" (',response response asString,')')
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   337
                ].
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   338
            ] ifFalse:[    
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   339
                client := self httpClient.
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   340
                client
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   341
                        ifFail: [ :exception | 
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   342
                                (exception className beginsWith: 'Zn')
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   343
                                        ifTrue: [ MCRepositoryError signal: 'Could not access ', self location, ': ', exception printString ]
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   344
                                        ifFalse: [ exception pass ] ];
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   345
                        url: self locationWithTrailingSlash;
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   346
                        queryAt: 'C' put: 'M;O=D';      "legacy that some servers maybe expect"
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   347
                        get.
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   348
                self assertNonBinaryResponse: client response 
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   349
            ].
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   350
        ].
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   351
        ^ self parseFileNamesFromStream: client contents readStream
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   352
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   353
    "Modified: / 26-08-2018 / 16:16:11 / Claus Gittinger"
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   354
! !
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   355
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   356
!MCHttpRepository methodsFor:'private'!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   357
1069
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   358
asCreationTemplate
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   359
        ^self class creationTemplateLocation: self location user: user password: password
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   360
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   361
    "Modified: / 26-08-2018 / 16:15:28 / Claus Gittinger"
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   362
!
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   363
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   364
assertBinaryResponse: response 
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   365
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   366
	response contentType isBinary ifFalse: [ 
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   367
		MCRepositoryError signal: 'Expected a binary response instead of ', response contentType printString ].
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   368
!
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   369
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   370
assertNonBinaryResponse: response 
1069
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   371
    Smalltalk isSmalltalkX ifTrue:[
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   372
        response contentType = 'text/plain' ifFalse:[
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   373
            Error "MCRepositoryError" signal: 'Did not expect a binary response but got ', response contentType printString 
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   374
        ]. 
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   375
        ^ self.
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   376
    ].    
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   377
    response contentType isBinary ifTrue: [ 
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   378
        MCRepositoryError signal: 'Did not expect a binary response but got ', response contentType printString 
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   379
    ].
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   380
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   381
    "Modified: / 26-08-2018 / 15:02:39 / Claus Gittinger"
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   382
!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   383
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   384
entityStreamContents: aBlock
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   385
	"Generate output in a buffer because we need the length"
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   386
	
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   387
	| stream |
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   388
	stream := RWBinaryOrTextStream on: String new.
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   389
	aBlock value: stream.
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   390
	stream reset.
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   391
	^ (ZnStreamingEntity type: ZnMimeType applicationOctetStream)
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   392
		stream: stream;
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   393
		contentLength: stream size;
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   394
		yourself
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   395
!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   396
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   397
httpClient
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   398
	"Return a new, specifically configured instance of the HTTP client for internal use.
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   399
	Note how we request GZIP compression and will signal progress."
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   400
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   401
	^ ZnClient new
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   402
		systemPolicy;
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   403
		beOneShot;
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   404
		username: self user password: self password;
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   405
	
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   406
		signalProgress: true;
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   407
		yourself
1069
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   408
!
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   409
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   410
userAndPasswordFromSettingsDo: aBlock
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   411
        "The mcSettings file in ExternalSettings preferenceDirectory should contain entries for each account:
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   412
        
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   413
                account1: *myhost.mydomain* user:password
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   414
                account2: *otherhost.mydomain/somerep* dXNlcjpwYXNzd29yZA==
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   415
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   416
        That is it must start with 'account', followed by anything to distinguish accounts, and a colon. Then comes a match expression for the repository url, and after a space the user:password string.
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   417
        
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   418
        To not have the clear text password on your disc, you can base64 encode it:
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   419
                        (Base64MimeConverter mimeEncode: 'user:password' readStream) contents
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   420
        "
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   421
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   422
        | entry userAndPassword |
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   423
        Settings ifNotNil: [
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   424
                Settings keysAndValuesDo: [:key :value |
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   425
                        (key asLowercase beginsWith: 'account') ifTrue: [
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   426
                                entry := value findTokens: '     '.
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   427
                                (entry first match: self location) ifTrue: [
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   428
                                        userAndPassword := entry second.
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   429
                                        (userAndPassword includes: $:) ifFalse: [
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   430
                                                userAndPassword := (Base64MimeConverter mimeDecodeToChars: userAndPassword readStream) contents].
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   431
                                        userAndPassword := userAndPassword findTokens: $:.
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   432
                                        ^aBlock value: userAndPassword first 
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   433
                                                value: userAndPassword second 
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   434
                                        ]
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   435
                        ]
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   436
                ]
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   437
        ].
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   438
        ^nil
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   439
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   440
    "Modified: / 26-08-2018 / 16:16:02 / Claus Gittinger"
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   441
!
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   442
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   443
versionReaderForFileNamed: aString
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   444
	readerCache ifNil: [readerCache := Dictionary new].
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   445
	^ readerCache at: aString ifAbsent:
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   446
		[self resizeCache: readerCache.
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   447
		super versionReaderForFileNamed: aString do:
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   448
			[:r |
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   449
			r ifNotNil: [readerCache at: aString put: r]]]
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   450
	
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   451
!
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   452
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   453
versionReaderForFileNamed: aString do: aBlock
1073
8dc1f701d37e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1069
diff changeset
   454
    | r fileName|
1069
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   455
1073
8dc1f701d37e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1069
diff changeset
   456
    fileName := aString.
8dc1f701d37e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1069
diff changeset
   457
    (aString endsWith:'.mcz') ifFalse:[
8dc1f701d37e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1069
diff changeset
   458
        fileName := aString,'.mcz'
8dc1f701d37e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1069
diff changeset
   459
    ].    
8dc1f701d37e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1069
diff changeset
   460
    ^(r := self versionReaderForFileNamed: fileName) ifNotNil: [aBlock value: r]
1069
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   461
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   462
    "Modified: / 14-09-2010 / 19:39:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1073
8dc1f701d37e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1069
diff changeset
   463
    "Modified: / 27-08-2018 / 09:35:18 / Claus Gittinger"
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   464
! !
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   465
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
!MCHttpRepository methodsFor:'required'!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
allFileNames
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   469
        | response |
1069
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   470
        response := HTTPInterface 
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   471
                        get: self locationWithTrailingSlash, '?C=M;O=D' 
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   472
                        userName: self user 
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   473
                        password: self password.
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   474
        response responseCode ~= 200 
1069
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   475
            ifTrue: [self error:('Could not access "',self location,'" (',response response asString,')')].
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   476
        ^ self parseFileNamesFromStream: response data readStream
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   477
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   478
    "Modified: / 14-09-2010 / 19:16:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
473
a2892180d5fc changed: #allFileNames
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   479
    "Modified: / 07-09-2011 / 12:34:23 / cg"
1069
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   480
    "Modified: / 26-08-2018 / 16:15:24 / Claus Gittinger"
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
description
1069
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   484
        ^ self location
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   485
5ea6b7f00935 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1053
diff changeset
   486
    "Modified: / 26-08-2018 / 16:15:33 / Claus Gittinger"
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   489
flushCache
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   490
	super flushCache.
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   491
	readerCache := nil.
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   492
!
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   493
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
readStreamForFileNamed: aString do: aBlock
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   495
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   496
    | response |
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   497
    response := HTTPInterface get: (self urlForFileNamed: aString) userName: self user password: self password.
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   498
    ^response responseCode == 200 
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   499
        ifTrue: [
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   500
            "/ self assertBinaryResponse: client response.
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   501
            "immediately cache the version and avoid an unnecessary serialization"
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   502
            "/ self cacheRawVersionNamed: aString stream: client contents ].
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   503
            aBlock value: response data readStream.
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   504
        ].
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   505
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   506
    "Modified: / 14-09-2010 / 19:38:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1073
8dc1f701d37e #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1069
diff changeset
   507
    "Modified: / 27-08-2018 / 09:34:25 / Claus Gittinger"
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   508
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   509
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   510
writeStreamForFileNamed: aString replace: ignoreBoolean do: aBlock
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   511
	| stream response |
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   512
	stream := RWBinaryOrTextStream on: String new.
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   513
	aBlock value: stream.
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   514
	response := HTTPSocket
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   515
					httpPut: stream contents
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   516
					to: (self urlForFileNamed: aString)
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
					user: self user
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   518
					passwd: self password.
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   519
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   520
	(#( 'HTTP/1.1 201 ' 'HTTP/1.1 200 ' 'HTTP/1.0 201 ' 'HTTP/1.0 200 ')
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
		anySatisfy: [:code | response beginsWith: code ])
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
			ifFalse: [self error: response].
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
! !
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
1053
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   525
!MCHttpRepository methodsFor:'storing'!
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   526
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   527
storeVersion: aVersion
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   528
	self retryOnCredentialRequest: [ super storeVersion: aVersion ]
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   529
! !
86dccda75716 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 1021
diff changeset
   530
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
!MCHttpRepository class methodsFor:'documentation'!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
277
8a5d4e015717 initial checkin
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
   533
version
1021
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   534
    ^ '$Header$'
277
8a5d4e015717 initial checkin
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
   535
!
8a5d4e015717 initial checkin
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
   536
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   537
version_CVS
1021
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   538
    ^ '$Header$'
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   539
!
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   540
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   541
version_SVN
1021
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   542
    ^ '$Id$'
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
! !
778
3cdbfc6ff7da class: MCHttpRepository
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
   544