01: /*
02:
03: Derby - Class org.apache.derby.impl.sql.LanguageDbPropertySetter
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to you under the Apache License, Version 2.0
09: (the "License"); you may not use this file except in compliance with
10: the License. You may obtain a copy of the License at
11:
12: http://www.apache.org/licenses/LICENSE-2.0
13:
14: Unless required by applicable law or agreed to in writing, software
15: distributed under the License is distributed on an "AS IS" BASIS,
16: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: See the License for the specific language governing permissions and
18: limitations under the License.
19:
20: */
21:
22: package org.apache.derby.impl.sql;
23:
24: import org.apache.derby.iapi.services.property.PropertySetCallback;
25: import org.apache.derby.iapi.services.property.PropertyUtil;
26: import org.apache.derby.iapi.reference.Property;
27: import org.apache.derby.iapi.reference.SQLState;
28: import org.apache.derby.iapi.services.daemon.Serviceable;
29: import org.apache.derby.iapi.services.sanity.SanityManager;
30: import org.apache.derby.iapi.services.context.ContextService;
31: import org.apache.derby.iapi.error.StandardException;
32: import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
33: import org.apache.derby.iapi.store.access.TransactionController;
34: import java.io.Serializable;
35: import java.util.Dictionary;
36:
37: /**
38: * A class to handle setting language database properties
39: */
40: public class LanguageDbPropertySetter implements PropertySetCallback {
41: public void init(boolean dbOnly, Dictionary p) {
42: // not called yet ...
43: }
44:
45: /** @exception StandardException Thrown on error. */
46: public boolean validate(String key, Serializable value, Dictionary p)
47: throws StandardException {
48: // Disallow changing sqlAuthorization from true to false or null after
49: // switching to Standard authorization
50: if (key.trim().equals(Property.SQL_AUTHORIZATION_PROPERTY)) {
51: LanguageConnectionContext lcc = (LanguageConnectionContext) ContextService
52: .getContext(LanguageConnectionContext.CONTEXT_ID);
53:
54: if (lcc.usesSqlAuthorization()
55: && !Boolean.valueOf((String) value).booleanValue())
56: throw StandardException.newException(
57: SQLState.PROPERTY_UNSUPPORTED_CHANGE, key,
58: value);
59: }
60:
61: if (key.equals(Property.LANGUAGE_STALE_PLAN_CHECK_INTERVAL)) {
62: PropertyUtil
63: .intPropertyValue(
64: Property.LANGUAGE_STALE_PLAN_CHECK_INTERVAL,
65: value,
66: Property.MIN_LANGUAGE_STALE_PLAN_CHECK_INTERVAL,
67: Integer.MAX_VALUE,
68: Property.DEFAULT_LANGUAGE_STALE_PLAN_CHECK_INTERVAL);
69: return true;
70: }
71:
72: return false;
73: }
74:
75: public Serviceable apply(String key, Serializable value,
76: Dictionary p) {
77: return null;
78: }
79:
80: public Serializable map(String key, Serializable value, Dictionary p) {
81: return null;
82: }
83: }
|