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