<<>> <> <> <> <<>> DIRECTORY AuthenticationP14V2 USING [CallProblem, Problem], BasicTime USING [GMT, Now, nullGMT], CrRPC USING [Error, ErrorReason], FilingAttributesP10V5, FilingP10V5, IO USING [card, EndOfStream, Error, PutFR, rope, time], PFS USING [Error, ErrorDesc], PFSBackdoor USING [ErrorCode, ProduceError], RefText USING [TrustTextAsRope], Rope USING [ROPE], XNSFilingOps USING [ServerData], XNSStream USING [ConnectionClosed, Timeout]; XNSFilingErrorImpl: CEDAR MONITOR IMPORTS CrRPC, IO, FilingP10V5, PFS, PFSBackdoor, RefText, XNSStream EXPORTS XNSFilingOps ~ { ROPE: TYPE ~ Rope.ROPE; <> AtomForErrorCode: PROC [code: InternalErrorCode] RETURNS [atom: ATOM] ~ { atom _ SELECT code FROM badCredentials => $badCredentials, illegalAttributeType => $illegalAttributeType, illegalAttributeValue => $illegalAttributeValue, illegalControlType => $illegalControlType, illegalControlValue => $illegalControlValue, illegalScope => $illegalScope, illegalScopeValue => $illegalScopeValue, illegalSession => $illegalSession, fileBusy => $fileBusy, fileHandleError => $fileHandleError, insertionError => $insertionError, rangeError => $rangeError, crRPCError => $crRPCError, unexpectedClose => $unexpectedClose, connectionTimedOut => $connectionTimedOut, connectionTrouble => $connectionTrouble, serviceProblem => $serviceProblem, transferError => $transferError, undefinedError => $undefinedError, ENDCASE => ERROR; }; InternalErrorCode: TYPE ~ { --user:-- badCredentials, --client:-- illegalAttributeType, illegalAttributeValue, illegalControlType, illegalControlValue, illegalScope, illegalScopeValue, --client:-- illegalSession, fileBusy, fileHandleError, insertionError, rangeError, --environ:-- crRPCError, unexpectedClose, connectionTimedOut, connectionTrouble, serviceProblem, transferError, --bug:-- undefinedError }; Bug: PROC [code: InternalErrorCode[undefinedError..undefinedError], msg: ROPE] ~ { atom: ATOM ~ AtomForErrorCode[code]; error: PFS.ErrorDesc ~ [$bug, atom, msg]; ERROR PFS.Error[error]; }; ClientError: PROC [code: InternalErrorCode[illegalAttributeType..rangeError], msg: ROPE] ~ { atom: ATOM ~ AtomForErrorCode[code]; error: PFS.ErrorDesc ~ [$client, atom, msg]; ERROR PFS.Error[error]; }; EnvironError: PROC [code: InternalErrorCode[crRPCError..transferError], msg: ROPE] ~ { atom: ATOM ~ AtomForErrorCode[code]; error: PFS.ErrorDesc ~ [$environment, atom, msg]; ERROR PFS.Error[error]; }; UserError: PROC [code: InternalErrorCode[badCredentials..badCredentials], msg: ROPE] ~ { atom: ATOM ~ AtomForErrorCode[code]; error: PFS.ErrorDesc ~ [$user, atom, msg]; ERROR PFS.Error[error]; }; BackdoorError: PROC [code: PFSBackdoor.ErrorCode, msg: ROPE] ~ INLINE { PFSBackdoor.ProduceError[code, msg]; }; UnknownError: PROC [pathname: ROPE, time: BasicTime.GMT] ~ { msg: ROPE ~ IO.PutFR["%g of %g", IO.rope[pathname], IO.time[time] ]; BackdoorError[$unknownFile, msg]; }; <> StartCall: ENTRY PROC [mnt: XNSFilingOps.ServerData] ~ { ENABLE UNWIND => { NULL }; mnt.admin.callsOut _ mnt.admin.callsOut.SUCC; mnt.admin.active _ TRUE; }; EndCall: ENTRY PROC [mnt: XNSFilingOps.ServerData] ~ { ENABLE UNWIND => { NULL }; mnt.admin.callsOut _ mnt.admin.callsOut.PRED; mnt.admin.active _ (mnt.admin.callsOut > 0); mnt.admin.lastOp _ BasicTime.Now[]; }; CallProtected: PUBLIC PROC [mnt: XNSFilingOps.ServerData, proc: PROC, pathname: ROPE, time: BasicTime.GMT] ~ { ENABLE UNWIND => { EndCall[mnt] }; StartCall[mnt]; GuardOpInner[proc, pathname, time]; EndCall[mnt]; }; GuardOp: PUBLIC PROC [proc: PROC] ~ { GuardOpInner[proc]; }; GuardOpInner: PUBLIC PROC [proc: PROC, pathname: ROPE _ NIL, time: BasicTime.GMT _ BasicTime.nullGMT] ~ { ENABLE { UNWIND => { NULL }; XNSStream.ConnectionClosed => { xx: ROPE ~ IO.PutFR[RopeForText["Server for %g closed the connection."], IO.rope[pathname] ]; EnvironError[$connectionTimedOut, xx]; }; CrRPC.Error => { text2: ROPE ~ RopeForText[errorReasonText[errorReason]]; xx: ROPE ~ IO.PutFR[RopeForText["CrRPC.Error[%g]: %g"], IO.rope[text2], IO.rope[text] ]; EnvironError[$crRPCError, xx]; }; IO.EndOfStream => { xx: ROPE ~ IO.PutFR[RopeForText["Server for %g closed the connection."], IO.rope[pathname] ]; EnvironError[$unexpectedClose, xx]; }; IO.Error => { xx: ROPE ~ IO.PutFR[RopeForText["File: %g unexpected IO.Error."], IO.rope[pathname] ]; BackdoorError[$ioError, xx]; }; FilingP10V5.AccessError => { text: ROPE ~ RopeForText[accessProblemText[problem]]; xx: ROPE ~ IO.PutFR[RopeForText["Filing5.AccessError[%g]: %g"], IO.rope[text], IO.rope[pathname] ]; SELECT problem FROM accessRightsInsufficient, accessRightsIndeterminate => BackdoorError[$accessDenied, xx]; fileChanged, fileDamaged => BackdoorError[$inconsistent, xx]; fileInUse, fileOpen => ClientError[$fileBusy, xx]; fileNotFound => UnknownError[pathname, time]; ENDCASE => ERROR; }; FilingP10V5.AttributeTypeError => { text: ROPE ~ RopeForText[argumentProblemText[problem]]; xx: ROPE ~ IO.PutFR[RopeForText["Filing5.AttributeTypeError[%g]: %g"], IO.rope[text], IO.card[type] ]; ClientError[$illegalAttributeType, xx]; }; FilingP10V5.AttributeValueError => { text: ROPE ~ RopeForText[argumentProblemText[problem]]; xx: ROPE ~ IO.PutFR[RopeForText["Filing5.AttributeValueError[%g]: %g"], IO.rope[text], IO.card[type] ]; ClientError[$illegalAttributeValue, xx]; }; FilingP10V5.AuthenticationError => { text: ROPE ~ RopeForText[problemText[problem]]; xx: ROPE ~ IO.PutFR[RopeForText["Filing5.AuthenticationError[%g]: %g"], IO.rope[text], IO.rope[pathname] ]; UserError[$badCredentials, xx]; }; FilingP10V5.ConnectionError => { text: ROPE ~ RopeForText[connectionProblemText[problem]]; xx: ROPE ~ IO.PutFR[RopeForText["Filing5.ConnectionError[%g]: %g"], IO.rope[text], IO.rope[pathname] ]; EnvironError[$connectionTrouble, xx]; }; FilingP10V5.ControlTypeError => { text: ROPE ~ RopeForText[argumentProblemText[problem]]; text2: ROPE ~ RopeForText[controlTypeText[type]]; xx: ROPE ~ IO.PutFR[RopeForText["Filing5.ControlTypeError[%g]: %g"], IO.rope[text], IO.rope[text2] ]; ClientError[$illegalControlType, xx]; }; FilingP10V5.ControlValueError => { text: ROPE ~ RopeForText[argumentProblemText[problem]]; text2: ROPE ~ RopeForText[controlTypeText[type]]; xx: ROPE ~ IO.PutFR[RopeForText["Filing5.ControlValueError[%g]: %g"], IO.rope[text], IO.rope[text2] ]; ClientError[$illegalControlValue, xx]; }; FilingP10V5.HandleError => { text: ROPE ~ RopeForText[handleProblemText[problem]]; xx: ROPE ~ IO.PutFR[RopeForText["Filing5.HandleError[%g]: %g"], IO.rope[text], IO.rope[pathname] ]; ClientError[$fileHandleError, xx]; }; FilingP10V5.InsertionError => { text: ROPE ~ RopeForText[insertionProblemText[problem]]; xx: ROPE ~ IO.PutFR[RopeForText["Filing5.InsertionError[%g]: %g"], IO.rope[text], IO.rope[pathname] ]; ClientError[$insertionError, xx]; }; FilingP10V5.RangeError => { text: ROPE ~ RopeForText[argumentProblemText[problem]]; xx: ROPE ~ IO.PutFR[RopeForText["Filing5.RangeError[%g]: %g"], IO.rope[text], IO.rope[pathname] ]; ClientError[$rangeError, xx]; }; FilingP10V5.ScopeTypeError => { text: ROPE ~ RopeForText[argumentProblemText[problem]]; text2: ROPE ~ RopeForText[scopeTypeText[type]]; xx: ROPE ~ IO.PutFR[RopeForText["Filing5.ScopeTypeError[%g]: %g"], IO.rope[text], IO.rope[text2] ]; ClientError[$illegalScope, xx]; }; FilingP10V5.ScopeValueError => { text: ROPE ~ RopeForText[argumentProblemText[problem]]; text2: ROPE ~ RopeForText[scopeTypeText[type]]; xx: ROPE ~ IO.PutFR[RopeForText["Filing5.ScopeTypeError[%g]: %g"], IO.rope[text], IO.rope[text2] ]; ClientError[$illegalScopeValue, xx]; }; FilingP10V5.ServiceError => { text: ROPE ~ RopeForText[serviceProblemText[problem]]; xx: ROPE ~ IO.PutFR[RopeForText["Filing5.ServiceError[%g]: %g"], IO.rope[text], IO.rope[pathname] ]; EnvironError[$serviceProblem, xx]; }; FilingP10V5.SessionError => { text: ROPE ~ RopeForText[sessionProblemText[problem]]; xx: ROPE ~ IO.PutFR[RopeForText["Filing5.SessionError[%g]: %g"], IO.rope[text] ]; ClientError[$illegalSession, xx]; }; FilingP10V5.SpaceError => { text: ROPE ~ RopeForText[spaceProblemText[problem]]; xx: ROPE ~ IO.PutFR[RopeForText["Filing5.SpaceError[%g]: %g"], IO.rope[text] ]; BackdoorError[(SELECT problem FROM allocationExceeded => $quotaExceeded, attributeAreaFull => $outOfPropertySpace, mediumFull => $volumeFull, ENDCASE => ERROR), xx]; }; FilingP10V5.TransferError => { text: ROPE ~ RopeForText[transferProblemText[problem]]; xx: ROPE ~ IO.PutFR[RopeForText["Filing5.TransferError[%g]: %g"], IO.rope[text], IO.rope[pathname] ]; EnvironError[$transferError, xx]; }; FilingP10V5.UndefinedError => { xx: ROPE ~ IO.PutFR[RopeForText["Filing5.UndefinedError[%g]: %g"], IO.card[problem], IO.rope[pathname] ]; Bug[$undefinedError, xx]; }; }; IF ( proc = NIL ) THEN ERROR; proc[ ! XNSStream.Timeout => RESUME]; -- since the timeout is retryable }; <> RopeForText: PROC [text: STRING] RETURNS [rope: ROPE] ~ { <> ref: REF READONLY TEXT; TRUSTED { ref _ LOOPHOLE[text] }; rope _ RefText.TrustTextAsRope[ref]; }; REQUIREDTEXT: TYPE ~ <> STRING _ ; -- no default value! <> callProblemText: PUBLIC ARRAY AuthenticationP14V2.CallProblem OF REQUIREDTEXT _ [ tooBusy: "tooBusy", accessRightsInsufficient: "accessRightsInsufficient", keysUnavailable: "keysUnavailable", strongKeyDoesNotExist: "strongKeyDoesNotExist", simpleKeyDoesNotExist: "simpleKeyDoesNotExist", strongKeyAlreadyRegistered: "strongKeyAlreadyRegistered", simpleKeyAlreadyRegistered: "simpleKeyAlreadyRegistered", domainForNewKeyUnavailable: "domainForNewKeyUnavailable", domainForNewKeyUnknown: "domainForNewKeyUnknown", badKey: "badKey", badName: "badName", databaseFull: "databaseFull", other: "other" ]; problemText: PUBLIC ARRAY AuthenticationP14V2.Problem OF REQUIREDTEXT _ [ credentialsInvalid: "credentialsInvalid", verifierInvalid: "verifierInvalid", verifierExpired: "verifierExpired", verifierReused: "verifierReused", credentialsExpired: "credentialsExpired", inappropriateCredentials: "inappropriateCredentials" ]; <> errorReasonText: PUBLIC ARRAY CrRPC.ErrorReason OF REQUIREDTEXT _ [ unknown: "unknown", unknownClass: "unknownClass", courierVersionMismatch: "courierVersionMismatch", rejectedNoSuchProgram: "rejectedNoSuchProgram", rejectedNoSuchVersion: "rejectedNoSuchVersion", rejectedNoSuchProcedure: "rejectedNoSuchProcedure", rejectedInvalidArgument: "rejectedInvalidArgument", rejectedUnspecified: "rejectedUnspecified", remoteError: "remoteError", cantConnectToRemote: "cantConnectToRemote", argsError: "argsError", resultsError: "resultsError", bulkDataError: "bulkDataError", protocolError: "protocolError", remoteClose: "remoteClose", communicationFailure: "communicationFailure", notImplemented: "notImplemented", unknownOperation: "unknownOperation", notServerHandle: "notServerHandle", notClientHandle: "notClientHandle", addressInappropriateForClass: "addressInappropriateForClass", other: "other" ]; <> accessProblemText: PUBLIC ARRAY FilingP10V5.AccessProblem OF REQUIREDTEXT _ [ accessRightsInsufficient: "accessRightsInsufficient", accessRightsIndeterminate: "accessRightsIndeterminate", fileChanged: "fileChanged", fileDamaged: "fileDamaged", fileInUse: "fileInUse", fileNotFound: "fileNotFound", fileOpen: "fileOpen" ]; argumentProblemText: PUBLIC ARRAY FilingP10V5.ArgumentProblem OF REQUIREDTEXT _ [ illegal: "illegal", disallowed: "disallowed", unreasonable: "unreasonable", unimplemented: "unimplemented", duplicated: "duplicated", missing: "missing" ]; ConnectionProblemSubRange: TYPE ~ FilingP10V5. ConnectionProblem[noRoute..returnTimedOut]; connectionProblemText: PUBLIC ARRAY ConnectionProblemSubRange OF REQUIREDTEXT _ [ noRoute: "noRoute", noResponse: "noResponse", transmissionHardware: "transmissionHardware", transportTimeout: "transportTimeout", tooManyLocalConnections: "tooManyLocalConnections", tooManyRemoteConnections: "tooManyRemoteConnections", missingCourier: "missingCourier", missingProgram: "missingProgram", missingProcedure: "missingProcedure", protocolMismatch: "protocolMismatch", parameterInconsistency: "parameterInconsistency", invalidMessage: "invalidMessage", returnTimedOut: "returnTimedOut" ]; controlTypeText: PUBLIC ARRAY FilingP10V5.ControlType OF REQUIREDTEXT _ [ lock: "lock", timeout: "timeout", access: "access" ]; directionText: PUBLIC ARRAY FilingP10V5.Direction OF REQUIREDTEXT _ [ forward: "forward", backward: "backward" ]; filterTypeText: PUBLIC ARRAY FilingP10V5.FilterType OF REQUIREDTEXT _ [ less: "less", lessOrEqual: "lessOrEqual", equal: "equal", notEqual: "notEqual", greaterOrEqual: "greaterOrEqual", greater: "greater", and: "and", or: "or", not: "not", none: "none", all: "all", matches: "matches" ]; handleProblemText: PUBLIC ARRAY FilingP10V5.HandleProblem OF REQUIREDTEXT _ [ invalid: "invalid", nullDisallowed: "nullDisallowed", directoryRequired: "directoryRequired" ]; insertionProblemText: PUBLIC ARRAY FilingP10V5.InsertionProblem OF REQUIREDTEXT _ [ positionUnavailable: "positionUnavailable", fileNotUnique: "fileNotUnique", loopInHierarchy: "loopInHierarchy" ]; lockText: PUBLIC ARRAY FilingP10V5.Lock OF REQUIREDTEXT _ [ lockNone: "lockNone", share: "share", exclusive: "exclusive" ]; scopeTypeText: PUBLIC ARRAY FilingP10V5.ScopeType OF REQUIREDTEXT _ [ count: "count", direction: "direction", filter: "filter", depth: "depth" ]; serviceProblemText: PUBLIC ARRAY FilingP10V5.ServiceProblem OF REQUIREDTEXT _ [ cannotAuthenticate: "cannotAuthenticate", serviceFull: "serviceFull", serviceUnavailable: "serviceUnavailable", sessionInUse: "sessionInUse", serviceUnknown: "serviceUnknown" ]; sessionProblemText: PUBLIC ARRAY FilingP10V5.SessionProblem OF REQUIREDTEXT _ [ tokenInvalid: "tokenInvalid", serviceAlreadySet: "serviceAlreadySet" ]; spaceProblemText: PUBLIC ARRAY FilingP10V5.SpaceProblem OF REQUIREDTEXT _ [ allocationExceeded: "allocationExceeded", attributeAreaFull: "attributeAreaFull", mediumFull: "mediumFull" ]; strengthText: PUBLIC ARRAY FilingP10V5.Strength OF REQUIREDTEXT _ [ none: "none", simple: "simple", strong: "strong" ]; transferProblemText: PUBLIC ARRAY FilingP10V5.TransferProblem OF REQUIREDTEXT _ [ aborted: "aborted", checksumIncorrect: "checksumIncorrect", formatIncorrect: "formatIncorrect", noRendevous: "noRendevous", wrongDirection: "wrongDirection" ]; }.