KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > repository > serverimpl > AbstractLocalStrategy


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.outerj.daisy.repository.serverimpl;
17
18 import org.outerj.daisy.repository.variant.Branch;
19 import org.outerj.daisy.repository.variant.Language;
20 import org.outerj.daisy.repository.commonimpl.AuthenticatedUser;
21 import org.outerj.daisy.jdbcutil.JdbcHelper;
22 import org.apache.avalon.framework.logger.Logger;
23
24 import java.util.Calendar JavaDoc;
25 import java.util.Date JavaDoc;
26 import java.util.GregorianCalendar JavaDoc;
27
28 public abstract class AbstractLocalStrategy {
29     protected Logger logger;
30     protected AuthenticatedUser systemUser;
31     protected LocalRepositoryManager.Context context;
32     protected JdbcHelper jdbcHelper;
33     protected EventHelper eventHelper;
34
35     public AbstractLocalStrategy(LocalRepositoryManager.Context context, AuthenticatedUser systemUser, JdbcHelper jdbcHelper) {
36         this.context = context;
37         this.logger = context.getLogger();
38         this.systemUser = systemUser;
39         this.jdbcHelper = jdbcHelper;
40         this.eventHelper = new EventHelper(context, jdbcHelper);
41     }
42
43     protected String JavaDoc getBranchLabel(long branchId) {
44         try {
45             Branch branch = context.getCommonRepository().getVariantManager().getBranch(branchId, false, systemUser);
46             return branch.getName() + " (ID " + branchId + ")";
47         } catch (Throwable JavaDoc e) {
48             return String.valueOf(branchId);
49         }
50     }
51
52     protected String JavaDoc getLanguageLabel(long languageId) {
53         try {
54             Language language = context.getCommonRepository().getVariantManager().getLanguage(languageId, false, systemUser);
55             return language.getName() + " (ID " + languageId + ")";
56         } catch (Throwable JavaDoc e) {
57             return String.valueOf(languageId);
58         }
59     }
60
61     protected Calendar JavaDoc getCalendar(Date JavaDoc date) {
62         GregorianCalendar JavaDoc calendar = new GregorianCalendar JavaDoc();
63         calendar.setTime(date);
64         return calendar;
65     }
66 }
67
Popular Tags