MCHttpRepository.st
author Merge Script
Thu, 07 Apr 2016 07:08:20 +0200
branchjv
changeset 1009 e25edee0d1e7
parent 989 4589c38afe55
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/monticello' }"
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
989
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
     3
"{ NameSpace: Smalltalk }"
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
     4
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
MCFileBasedRepository subclass:#MCHttpRepository
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
	instanceVariableNames:'location user password readerCache'
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
	classVariableNames:''
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
	poolDictionaries:''
632
0a03a211d43b category change
Claus Gittinger <cg@exept.de>
parents: 473
diff changeset
     9
	category:'SCM-Monticello-Repositories'
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    13
!MCHttpRepository class methodsFor:'initialization'!
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    14
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    15
clearPasswords
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    16
	self allSubInstancesDo: [:ea | ea password: ''].
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    17
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    18
! !
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    19
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    20
!MCHttpRepository class methodsFor:'instance creation'!
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    21
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    22
location: location user: user password: password
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    23
	^ self new
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    24
		location: location;
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    25
		user: user;
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    26
		password: password
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    27
! !
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    28
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    29
!MCHttpRepository class methodsFor:'queries'!
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
creationTemplate
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    32
	^self creationTemplateLocation: 'http://www.squeaksource.com/'
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
		user: 'squeak'
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
		password: 'squeak'
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    35
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
creationTemplateLocation: location user: user password: password
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    39
        ^
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
'MCHttpRepository
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    41
        location: %1
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    42
        user: %2
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    43
        password: %3' 
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    44
            bindWith: location storeString 
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    45
            with: user storeString
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    46
            with: password storeString
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    47
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    48
    "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
    49
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
description
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
	^ 'HTTP'
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
! !
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
    55
!MCHttpRepository methodsFor:'accessing'!
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
778
3cdbfc6ff7da class: MCHttpRepository
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
    57
location
3cdbfc6ff7da class: MCHttpRepository
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
    58
      ^location 
3cdbfc6ff7da class: MCHttpRepository
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
    59
!
3cdbfc6ff7da class: MCHttpRepository
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
    60
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
location: aUrlString
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    62
	location := aUrlString
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
locationWithTrailingSlash
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
	^ (location endsWith: '/')
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
		ifTrue: [location]
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
		ifFalse: [location, '/']
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
password
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
	self userAndPasswordFromSettingsDo: [:usr :pwd | ^pwd].
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
	self user isEmpty ifTrue: [^password].
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
	[password isEmpty] whileTrue: [
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
		| answer |
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
		"Give the user a chance to change the login"
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    79
		answer := UIManager default request: 'User name for ' translated, String cr, location
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
			initialAnswer: self user.
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
		answer isEmpty
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
			ifTrue: [^password]
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
			ifFalse: [self user: answer].
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
		
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    85
		password := UIManager default requestPassword: 'Password for' translated, ' "', self user, '" ', 'at ' translated, String cr, location.
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
	].
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
	^ password
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
password: passwordString
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
    92
	password := passwordString
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
user
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
	self userAndPasswordFromSettingsDo: [:usr :pwd | ^usr].
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
	"not in settings"
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
	^user
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
user: userString
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   102
	user := userString
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   103
! !
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   104
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   105
!MCHttpRepository methodsFor:'as yet unclassified'!
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   106
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   107
asCreationTemplate
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   108
	^self class creationTemplateLocation: location user: user password: password
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   109
!
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   110
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   111
parseFileNamesFromStream: aStream
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   112
	| names fullName |
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   113
	names := OrderedCollection new.
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   114
	[aStream atEnd] whileFalse:
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   115
		[[aStream upTo: $<. {$a. $A. nil} includes: aStream next] whileFalse.
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   116
		aStream upTo: $".
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   117
		aStream atEnd ifFalse: [
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   118
			fullName := aStream upTo: $".
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   119
			names add: fullName unescapePercents]].
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   120
	^ names
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
userAndPasswordFromSettingsDo: aBlock
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
	"The mcSettings file in ExternalSettings preferenceDirectory should contain entries for each account:
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
	
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
		account1: *myhost.mydomain* user:password
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
		account2: *otherhost.mydomain/somerep* dXNlcjpwYXNzd29yZA==
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
	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
   130
	
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
	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
   132
			(Base64MimeConverter mimeEncode: 'user:password' readStream) contents
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
	| entry userAndPassword |
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
	Settings ifNotNil: [
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
		Settings keysAndValuesDo: [:key :value |
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
			(key asLowercase beginsWith: 'account') ifTrue: [
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   139
				entry := value findTokens: '	 '.
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
				(entry first match: location) ifTrue: [
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
					userAndPassword := entry second.
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
					(userAndPassword includes: $:) ifFalse: [
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
						userAndPassword := (Base64MimeConverter mimeDecodeToChars: userAndPassword readStream) contents].
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
					userAndPassword := userAndPassword findTokens: $:.
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
					^aBlock value: userAndPassword first 
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
						value: userAndPassword second 
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
					]
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
			]
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
		]
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
	].
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
	^nil
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
versionReaderForFileNamed: aString
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   155
	readerCache ifNil: [readerCache := Dictionary new].
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
	^ readerCache at: aString ifAbsent:
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
		[self resizeCache: readerCache.
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
		super versionReaderForFileNamed: aString do:
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
			[:r |
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
			r ifNotNil: [readerCache at: aString put: r]]]
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
	
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
versionReaderForFileNamed: aString do: aBlock
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   165
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   166
    | r |
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   167
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   168
    ^(r := self versionReaderForFileNamed: aString) ifNotNil: [aBlock value: r]
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   169
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   170
    "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
   171
! !
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
!MCHttpRepository methodsFor:'displaying'!
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
displayString
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
    ^location
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   178
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   179
    "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
   180
! !
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   182
!MCHttpRepository methodsFor:'queries'!
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   183
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   184
urlForFileNamed: aString
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   185
        ^ self locationWithTrailingSlash, aString utf8Encoded
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   186
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   187
    "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
   188
! !
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   189
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
!MCHttpRepository methodsFor:'required'!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
allFileNames
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   193
        | response |
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   194
        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
   195
        response responseCode ~= 200 
473
a2892180d5fc changed: #allFileNames
Claus Gittinger <cg@exept.de>
parents: 277
diff changeset
   196
            ifTrue: [self error:('Could not access "',location,'" (',response response asString,')')].
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   197
        ^ self parseFileNamesFromStream: response data readStream
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   198
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   199
    "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
   200
    "Modified: / 07-09-2011 / 12:34:23 / cg"
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
description
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
	^ location
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   207
flushCache
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   208
	super flushCache.
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   209
	readerCache := nil.
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   210
!
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   211
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
readStreamForFileNamed: aString do: aBlock
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   213
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   214
    | response |
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   215
    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
   216
    ^response responseCode == 200 
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   217
        ifTrue: [aBlock value: response data readStream].
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
    "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
   220
!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
writeStreamForFileNamed: aString replace: ignoreBoolean do: aBlock
989
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   223
        | stream response |
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   224
        stream := RWBinaryOrTextStream on: String new.
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   225
        aBlock value: stream.
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   226
"/        response := HTTPSocket
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   227
"/                                        httpPut: stream contents
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   228
"/                                        to: (self urlForFileNamed: aString)
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   229
"/                                        user: self user
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   230
"/                                        passwd: self password.
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   231
        response := HTTPInterface
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   232
                        request:#PUT
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   233
                        url:(self urlForFileNamed: aString)
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   234
                        fromHost:nil port:nil
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   235
                        accept:#('*/*')
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   236
                        fromDocument:nil
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   237
                        userName:self user password: self password 
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   238
                        contentType:'application/octet-stream'
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   239
                        contents:stream contents asString.
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
989
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   241
        (#( 201 200 ) includes: response responseCode) ifFalse: [self error: response].
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   242
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   243
    "Modified: / 24-04-2015 / 00:12:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
! !
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
!MCHttpRepository class methodsFor:'documentation'!
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
277
8a5d4e015717 initial checkin
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
   248
version
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   249
    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCHttpRepository.st,v 1.7 2014-02-12 14:53:40 cg Exp $'
277
8a5d4e015717 initial checkin
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
   250
!
8a5d4e015717 initial checkin
Claus Gittinger <cg@exept.de>
parents: 192
diff changeset
   251
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   252
version_CVS
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   253
    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCHttpRepository.st,v 1.7 2014-02-12 14:53:40 cg Exp $'
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   254
!
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   255
989
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   256
version_HG
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   257
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   258
    ^ '$Changeset: <not expanded> $'
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   259
!
4589c38afe55 Initial support for commit to MCHttpRepositories.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 909
diff changeset
   260
192
567ecbaf1c88 added: #version_CVS
Claus Gittinger <cg@exept.de>
parents: 113
diff changeset
   261
version_SVN
909
b63cf5148da4 categories
Claus Gittinger <cg@exept.de>
parents: 778
diff changeset
   262
    ^ '$Id: MCHttpRepository.st,v 1.7 2014-02-12 14:53:40 cg Exp $'
113
e72af2ae0071 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
! !
778
3cdbfc6ff7da class: MCHttpRepository
Claus Gittinger <cg@exept.de>
parents: 632
diff changeset
   264