MCHttpRepository.st
author Claus Gittinger <cg@exept.de>
Tue, 20 Feb 2018 01:08:08 +0100
changeset 1021 7ec8dc1c6c82
parent 909 b63cf5148da4
child 1053 86dccda75716
permissions -rw-r--r--
#FEATURE by cg class: MCHttpRepository changed: #password
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:''
632
0a03a211d43b category change
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
    11
	category:'SCM-Monticello-Repositories'
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
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    15
!MCHttpRepository class methodsFor:'initialization'!
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    16
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    17
clearPasswords
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    18
	self allSubInstancesDo: [:ea | ea password: ''].
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    19
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    20
! !
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    21
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    22
!MCHttpRepository class methodsFor:'instance creation'!
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    23
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    24
location: location user: user password: password
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    25
	^ self new
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    26
		location: location;
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    27
		user: user;
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    28
		password: password
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    29
! !
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    30
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    31
!MCHttpRepository class methodsFor:'queries'!
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
creationTemplate
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    34
	^self creationTemplateLocation: 'http://www.squeaksource.com/'
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
		user: 'squeak'
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
		password: 'squeak'
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    37
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
creationTemplateLocation: location user: user password: password
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    41
        ^
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
'MCHttpRepository
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    43
        location: %1
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    44
        user: %2
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    45
        password: %3' 
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    46
            bindWith: location storeString 
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    47
            with: user storeString
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    48
            with: password storeString
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    49
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    50
    "Modified: / 16-09-2010 / 14:34:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
description
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
	^ 'HTTP'
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
! !
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    57
!MCHttpRepository methodsFor:'accessing'!
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
778
3cdbfc6ff7da class: MCHttpRepository
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
    59
location
3cdbfc6ff7da class: MCHttpRepository
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
    60
      ^location 
3cdbfc6ff7da class: MCHttpRepository
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
    61
!
3cdbfc6ff7da class: MCHttpRepository
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
    62
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
location: aUrlString
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    64
	location := aUrlString
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
locationWithTrailingSlash
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
	^ (location endsWith: '/')
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
		ifTrue: [location]
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
		ifFalse: [location, '/']
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
password
1021
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
    74
        self userAndPasswordFromSettingsDo: [:usr :pwd | ^pwd].
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
    75
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
    76
        self user isEmpty ifTrue: [^password].
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
1021
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
    78
        [password isEmpty] whileTrue: [
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
    79
                | answer dialog |
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
    80
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
    81
                dialog := UIManager isNil ifTrue:[Dialog] ifFalse:[ UIManager default ].
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
1021
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
    83
                "Give the user a chance to change the login"
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
    84
                answer := dialog request: 'User name for ' translated, String cr, location
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
    85
                        initialAnswer: self user.
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
    86
                answer isEmpty
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
    87
                        ifTrue: [^password]
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
    88
                        ifFalse: [self user: answer].
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
    89
                
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
    90
                password := UIManager default requestPassword: 'Password for' translated, ' "', self user, '" ', 'at ' translated, String cr, location.
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
    91
        ].
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
1021
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
    93
        ^ password
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
password: passwordString
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    97
	password := passwordString
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
user
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
	self userAndPasswordFromSettingsDo: [:usr :pwd | ^usr].
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
	"not in settings"
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
	^user
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
user: userString
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   107
	user := userString
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   108
! !
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   109
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   110
!MCHttpRepository methodsFor:'as yet unclassified'!
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   111
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   112
asCreationTemplate
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   113
	^self class creationTemplateLocation: location user: user password: password
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   114
!
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   115
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   116
parseFileNamesFromStream: aStream
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   117
	| names fullName |
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   118
	names := OrderedCollection new.
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   119
	[aStream atEnd] whileFalse:
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   120
		[[aStream upTo: $<. {$a. $A. nil} includes: aStream next] whileFalse.
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   121
		aStream upTo: $".
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   122
		aStream atEnd ifFalse: [
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   123
			fullName := aStream upTo: $".
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   124
			names add: fullName unescapePercents]].
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   125
	^ names
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
userAndPasswordFromSettingsDo: aBlock
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
	"The mcSettings file in ExternalSettings preferenceDirectory should contain entries for each account:
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
	
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
		account1: *myhost.mydomain* user:password
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
		account2: *otherhost.mydomain/somerep* dXNlcjpwYXNzd29yZA==
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
	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.
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
	
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
	To not have the clear text password on your disc, you can base64 encode it:
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
			(Base64MimeConverter mimeEncode: 'user:password' readStream) contents
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
	"
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
	| entry userAndPassword |
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
	Settings ifNotNil: [
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
		Settings keysAndValuesDo: [:key :value |
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
			(key asLowercase beginsWith: 'account') ifTrue: [
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   144
				entry := value findTokens: '	 '.
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
				(entry first match: location) ifTrue: [
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
					userAndPassword := entry second.
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
					(userAndPassword includes: $:) ifFalse: [
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
						userAndPassword := (Base64MimeConverter mimeDecodeToChars: userAndPassword readStream) contents].
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
					userAndPassword := userAndPassword findTokens: $:.
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
					^aBlock value: userAndPassword first 
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
						value: userAndPassword second 
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
					]
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
			]
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
		]
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
	].
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
	^nil
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
versionReaderForFileNamed: aString
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   160
	readerCache ifNil: [readerCache := Dictionary new].
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
	^ readerCache at: aString ifAbsent:
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
		[self resizeCache: readerCache.
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
		super versionReaderForFileNamed: aString do:
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
			[:r |
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
			r ifNotNil: [readerCache at: aString put: r]]]
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
	
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
versionReaderForFileNamed: aString do: aBlock
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   170
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   171
    | r |
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   172
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   173
    ^(r := self versionReaderForFileNamed: aString) ifNotNil: [aBlock value: r]
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   174
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   175
    "Modified: / 14-09-2010 / 19:39:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   176
! !
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   177
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   178
!MCHttpRepository methodsFor:'displaying'!
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   179
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   180
displayString
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   181
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   182
    ^location
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   183
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   184
    "Created: / 14-09-2010 / 23:20:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
! !
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   187
!MCHttpRepository methodsFor:'queries'!
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   188
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   189
urlForFileNamed: aString
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   190
        ^ self locationWithTrailingSlash, aString utf8Encoded
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   191
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   192
    "Modified: / 14-09-2010 / 19:32:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   193
! !
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   194
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
!MCHttpRepository methodsFor:'required'!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
allFileNames
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   198
        | response |
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   199
        response := HTTPInterface get: self locationWithTrailingSlash, '?C=M;O=D' userName: self user password: self password.
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   200
        response responseCode ~= 200 
473
a2892180d5fc changed: #allFileNames
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   201
            ifTrue: [self error:('Could not access "',location,'" (',response response asString,')')].
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   202
        ^ self parseFileNamesFromStream: response data readStream
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   203
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   204
    "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
   205
    "Modified: / 07-09-2011 / 12:34:23 / cg"
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
description
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
	^ location
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   212
flushCache
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   213
	super flushCache.
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   214
	readerCache := nil.
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   215
!
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   216
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
readStreamForFileNamed: aString do: aBlock
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   218
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   219
    | response |
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   220
    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
   221
    ^response responseCode == 200 
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   222
        ifTrue: [aBlock value: response data readStream].
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   223
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   224
    "Modified: / 14-09-2010 / 19:38:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
writeStreamForFileNamed: aString replace: ignoreBoolean do: aBlock
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
	| stream response |
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   229
	stream := RWBinaryOrTextStream on: String new.
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
	aBlock value: stream.
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   231
	response := HTTPSocket
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
					httpPut: stream contents
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
					to: (self urlForFileNamed: aString)
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
					user: self user
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
					passwd: self password.
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
	(#( '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
   238
		anySatisfy: [:code | response beginsWith: code ])
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
			ifFalse: [self error: response].
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
! !
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
!MCHttpRepository class methodsFor:'documentation'!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
277
8a5d4e015717 initial checkin
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
   244
version
1021
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   245
    ^ '$Header$'
277
8a5d4e015717 initial checkin
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
   246
!
8a5d4e015717 initial checkin
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
   247
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   248
version_CVS
1021
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   249
    ^ '$Header$'
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   250
!
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   251
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   252
version_SVN
1021
7ec8dc1c6c82 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 909
diff changeset
   253
    ^ '$Id$'
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
! !
778
3cdbfc6ff7da class: MCHttpRepository
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
   255