0001: /*
0002: * JFolder, Copyright 2001-2006 Gary Steinmetz
0003: *
0004: * Distributable under LGPL license.
0005: * See terms of license at gnu.org.
0006: */
0007:
0008: package org.jfolder.console.base;
0009:
0010: //base classes
0011: import java.io.ByteArrayOutputStream;
0012: import java.security.MessageDigest;
0013: import java.security.NoSuchAlgorithmException;
0014: import java.security.SecureRandom;
0015: import java.util.ArrayList;
0016: import java.util.HashMap;
0017: import javax.servlet.http.HttpSessionBindingEvent;
0018: import javax.servlet.http.HttpSessionBindingListener;
0019:
0020: //project specific classes
0021: import org.jfolder.common.UnexpectedSystemException;
0022: import org.jfolder.common.tagging.ConceptTag;
0023: import org.jfolder.common.tagging.ConceptTagCallContext;
0024: import org.jfolder.common.tagging.ConceptTagCharacteristic;
0025: import org.jfolder.common.tagging.ConceptTagFlagsHelper;
0026: import org.jfolder.common.tagging.ConceptTagHelper;
0027: import org.jfolder.common.tagging.ConceptTagPreferences;
0028: import org.jfolder.common.tagging.ConceptTagPreferencesHelper;
0029: import org.jfolder.common.tagging.InitializeConceptTagContext;
0030: import org.jfolder.common.tagging.RootConceptTagHolder;
0031: import org.jfolder.common.tagging.StudioConceptTagUsabilityContext;
0032: import org.jfolder.common.tagging.TemplateHolderForConceptTag;
0033: import org.jfolder.common.utils.misc.MiscHelper;
0034: import org.jfolder.common.web.template.ConsoleTemplateSession;
0035: import org.jfolder.common.web.template.MenuBranch;
0036: import org.jfolder.common.web.template.SubmitActionParameters;
0037: import org.jfolder.console.macro.ConsoleMacro;
0038: import org.jfolder.dms.model.DocumentFileSystemRoot;
0039: import org.jfolder.engines.call.GovernorCall;
0040: import org.jfolder.engines.call.GovernorCallHelper;
0041: import org.jfolder.project.model.ProjectSystem;
0042: import org.jfolder.security.audit.SecurityAuditSet;
0043: import org.jfolder.security.lifecycle.SecurityLifecycle;
0044: import org.jfolder.security.lifecycle.SecurityLifecycleHelper;
0045: import org.jfolder.security.model.GroupHolder;
0046: import org.jfolder.security.model.SystemGroups;
0047: import org.jfolder.security.model.UserHolder;
0048: import org.jfolder.services.console.ConsoleService;
0049: import org.jfolder.services.console.ConsoleServiceCallerFactory;
0050: import org.jfolder.services.project.ProjectService;
0051: import org.jfolder.services.project.ProjectServiceCallerFactory;
0052: import org.jfolder.web.page.RootWebPageTag;
0053: import org.jfolder.workflow.model.instance.WorkflowInstance;
0054:
0055: //other classes
0056:
0057: public class ConsolePageSession extends ConsoleTemplateSession
0058: implements HttpSessionBindingListener,
0059: TemplateHolderForConceptTag {
0060:
0061: //
0062: protected final static int STARTING_SEQUENCE_CODE = 0;
0063:
0064: //
0065: //private String consoleError = null;
0066: private ConsolePageMessageHolder messageHolder = null;
0067: private String handle = null;
0068: private UserHolder uh = null;
0069: //private int sequenceCode = 0;
0070: private HashMap cpcHandles = null;
0071:
0072: //
0073: private boolean projectSystemInitialized = false;
0074: private ArrayList userProjectSystemNames = null;
0075: private HashMap userProjectSystemValues = null;
0076: private ArrayList serverProjectSystemNames = null;
0077: private HashMap serverProjectSystemValues = null;
0078: //
0079: private ArrayList dataAccessResults = null;
0080: private WorkflowInstance workflowInstance = null;
0081: //
0082: private Boolean accessDevel = null;
0083: private Boolean accessAdmin = null;
0084: //
0085: private DocumentFileSystemRoot dsr = null;
0086: //
0087: /////////////////////////////////
0088: private String currentApplicationType = null;
0089: private String currentApplicationName = null;
0090: private String currentApplicationWebDocType = null;
0091: private String currentApplicationWebDocDirectory = null;
0092: private String currentApplicationWebDocFile = null;
0093: //
0094: private RootConceptTagHolder currentApplicationRcth = null;
0095: private RootConceptTagHolder currentApplicationTemplateRcth = null;
0096: private String currentApplicationTemplateLocation = null;
0097: //
0098: private String currentConsolePage = null;
0099: private int currentConsoleSequence = 0;
0100: private byte currentConsoleSalt[] = null;
0101: //
0102: private final static int MACRO_STATE__INACTIVE = 0;
0103: private final static int MACRO_STATE__RECORDING = 1;
0104: private final static int MACRO_STATE__REPLAYING = 2;
0105: private RootConceptTagHolder currentMacroRcth = null;
0106: private int currentMacroState = MACRO_STATE__INACTIVE;
0107: private String macroInterval = "110";
0108: //
0109: private HashMap consoleConfigs = null;
0110: //
0111: private SecurityAuditSet sas = null;
0112: //
0113: private HashMap copyHolders = null;
0114: //
0115: private StudioConceptTagUsabilityContext sctuc = null;
0116:
0117: public StudioConceptTagUsabilityContext getStudioUsability() {
0118: return this .sctuc;
0119: }
0120:
0121: //
0122: public boolean isSecurityAuditSetPresent() {
0123: return (this .sas != null);
0124: }
0125:
0126: public SecurityAuditSet getSecurityAuditSet() {
0127: return this .sas;
0128: }
0129:
0130: public void setSecurityAuditSet(SecurityAuditSet inSas) {
0131: this .sas = inSas;
0132: }
0133:
0134: //
0135: //
0136: //
0137: public RootConceptTagHolder getConsoleConfig() {
0138:
0139: RootConceptTagHolder outValue = null;
0140:
0141: ConceptTagPreferences localCtp = getCurrentApplicationRootHolder()
0142: .getPreferences();
0143: String prefHan = localCtp.getPreferencesHandle();
0144: if (this .consoleConfigs.containsKey(prefHan)) {
0145: outValue = (RootConceptTagHolder) this .consoleConfigs
0146: .get(prefHan);
0147: } else {
0148: ConsoleService cs = ConsoleServiceCallerFactory
0149: .getConsoleService();
0150: outValue = cs.getConsoleConfig(this .uh.getUserIdentity(),
0151: prefHan);
0152: this .consoleConfigs.put(prefHan, outValue);
0153: }
0154:
0155: return outValue;
0156: }
0157:
0158: public void resetConsoleConfig() {
0159:
0160: ConceptTagPreferences localCtp = getCurrentApplicationRootHolder()
0161: .getPreferences();
0162: String prefHan = localCtp.getPreferencesHandle();
0163: if (this .consoleConfigs.containsKey(prefHan)) {
0164: this .consoleConfigs.remove(prefHan);
0165: }
0166: }
0167:
0168: //
0169: public boolean isCurrentMacroPresent() {
0170: return (this .currentMacroRcth != null);
0171: }
0172:
0173: public void setCurrentMacro(RootConceptTagHolder inRcth) {
0174: this .currentMacroRcth = inRcth;
0175: }
0176:
0177: public RootConceptTagHolder getCurrentMacro() {
0178: return this .currentMacroRcth;
0179: }
0180:
0181: public ConsoleMacro getCurrentMacroAsMacro() {
0182:
0183: ConsoleMacro outValue = null;
0184:
0185: ConceptTag ct = this .currentMacroRcth.getFirstChildConceptTag();
0186:
0187: outValue = (ConsoleMacro) ct;
0188:
0189: return outValue;
0190: }
0191:
0192: public boolean isInactiveMacroState() {
0193: return (this .currentMacroState == MACRO_STATE__INACTIVE);
0194: }
0195:
0196: public boolean isRecordingMacroState() {
0197: return (this .currentMacroState == MACRO_STATE__RECORDING);
0198: }
0199:
0200: public boolean isReplayingMacroState() {
0201: return (this .currentMacroState == MACRO_STATE__REPLAYING);
0202: }
0203:
0204: public void setMacroStateAsReplaying(String inInterval) {
0205: this .macroInterval = inInterval;
0206: this .currentMacroState = MACRO_STATE__REPLAYING;
0207: }
0208:
0209: public void setMacroStateAsRecording() {
0210: this .currentMacroState = MACRO_STATE__RECORDING;
0211: }
0212:
0213: public void setMacroStateAsInactive() {
0214: this .currentMacroState = MACRO_STATE__INACTIVE;
0215: }
0216:
0217: public String getMacroInterval() {
0218: return this .macroInterval;
0219: }
0220:
0221: protected ConsolePageSession(String inHandle, UserHolder inUh) {
0222:
0223: try {
0224: //
0225: this .handle = inHandle;
0226: this .uh = inUh;
0227: //this.sequenceCode = STARTING_SEQUENCE_CODE;
0228: this .cpcHandles = new HashMap();
0229: //this.studioFrameState = 0;
0230:
0231: //
0232: this .userProjectSystemNames = new ArrayList();
0233: this .userProjectSystemValues = new HashMap();
0234: //
0235: this .serverProjectSystemNames = new ArrayList();
0236: this .serverProjectSystemValues = new HashMap();
0237:
0238: //
0239: this .messageHolder = ConsolePageMessageHolder.newInstance();
0240: //
0241: this .currentConsoleSequence = STARTING_SEQUENCE_CODE;
0242: SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
0243: this .currentConsoleSalt = sr.generateSeed(8);
0244: //
0245: this .consoleConfigs = new HashMap();
0246: //
0247: this .copyHolders = new HashMap();
0248: } catch (NoSuchAlgorithmException nsae) {
0249: throw new UnexpectedSystemException(nsae);
0250: }
0251: }
0252:
0253: //
0254: public boolean isCurrentConsolePagePresent() {
0255: return (this .currentConsolePage != null);
0256: }
0257:
0258: public String getCurrentConsolePage() {
0259: return this .currentConsolePage;
0260: }
0261:
0262: public void setCurrentConsolePage(String inCurrentConsolePage) {
0263: this .currentConsolePage = inCurrentConsolePage;
0264: }
0265:
0266: //
0267: public String getCurrentSequenceCode() {
0268:
0269: try {
0270: String outValue = null;
0271:
0272: //
0273: int scAll = this .currentConsoleSequence;
0274: byte sc1 = (byte) scAll;
0275: scAll = scAll / 256;
0276: byte sc2 = (byte) scAll;
0277: scAll = scAll / 256;
0278: byte sc3 = (byte) scAll;
0279: scAll = scAll / 256;
0280: byte sc4 = (byte) scAll;
0281: byte scArray[] = { sc1, sc2, sc3, sc4 };
0282: ByteArrayOutputStream baos = new ByteArrayOutputStream();
0283: baos.write(scArray, 0, scArray.length);
0284: baos.write(this .currentConsoleSalt, 0,
0285: this .currentConsoleSalt.length);
0286: //
0287: MessageDigest md = MessageDigest.getInstance("MD5");
0288:
0289: outValue = MiscHelper.fromSerializedDataToCData(md
0290: .digest(baos.toByteArray()));
0291:
0292: return outValue;
0293: } catch (NoSuchAlgorithmException nsae) {
0294: throw new UnexpectedSystemException(nsae);
0295: }
0296: }
0297:
0298: public void incrementCurrentSequenceCode() {
0299: this .currentConsoleSequence++;
0300: }
0301:
0302: public void setCurrentApplication(String inType, String inName,
0303: String inWebDocType, String inWebDocDirectory,
0304: String inWebDocFile, RootConceptTagHolder inRcth,
0305: String inTemplateLocation,
0306: RootConceptTagHolder inTemplateRcth) {
0307: //
0308: this .currentApplicationType = inType;
0309: this .currentApplicationName = inName;
0310: this .currentApplicationWebDocType = inWebDocType;
0311: this .currentApplicationWebDocDirectory = inWebDocDirectory;
0312: this .currentApplicationWebDocFile = inWebDocFile;
0313: //
0314: this .currentApplicationRcth = inRcth;
0315: this .currentApplicationTemplateLocation = inTemplateLocation;
0316: this .currentApplicationTemplateRcth = inTemplateRcth;
0317: //this.currentApplicationWebDocTreeState = inWebDocTreeState;
0318: }
0319:
0320: public String getCurrentApplicationType() {
0321: return this .currentApplicationType;
0322: }
0323:
0324: public String getCurrentApplicationName() {
0325: return this .currentApplicationName;
0326: }
0327:
0328: public String getCurrentApplicationWebDocType() {
0329: return this .currentApplicationWebDocType;
0330: }
0331:
0332: public String getCurrentApplicationWebDocDirectory() {
0333: return this .currentApplicationWebDocDirectory;
0334: }
0335:
0336: public String getCurrentApplicationWebDocFile() {
0337: return this .currentApplicationWebDocFile;
0338: }
0339:
0340: public RootConceptTagHolder getCurrentApplicationRootHolder() {
0341: return this .currentApplicationRcth;
0342: }
0343:
0344: //
0345: //
0346: //
0347: //
0348: public RootConceptTagHolder getCurrentApplicationTemplateRootHolder() {
0349: return this .currentApplicationTemplateRcth;
0350: }
0351:
0352: public String getCurrentApplicationTemplateLocation() {
0353: return this .currentApplicationTemplateLocation;
0354: }
0355:
0356: //
0357: public boolean isCurrentApplicationTemplatePresent() {
0358:
0359: boolean outValue = false;
0360:
0361: outValue = (this .currentApplicationTemplateRcth != null && this .currentApplicationTemplateLocation != null);
0362:
0363: return outValue;
0364: }
0365:
0366: public void setCurrentApplicationTemplate(String inLocation,
0367: RootConceptTagHolder inTemplateRcth) {
0368: //
0369: this .currentApplicationTemplateLocation = inLocation;
0370: this .currentApplicationTemplateRcth = inTemplateRcth;
0371: //
0372: if (inLocation != null && inTemplateRcth != null) {
0373: validateCurrentApplicationTemplateRootHolder();
0374: }
0375: }
0376:
0377: //public String getCurrentApplicationWebDocTreeState() {
0378: // //MiscHelper.println("cs.getTreeState = " + this.treeState);
0379: // return this.currentApplicationWebDocTreeState;
0380: //}
0381: //
0382: public void setCurrentApplicationRootHolder(
0383: RootConceptTagHolder inRcth) {
0384: this .currentApplicationRcth = inRcth;
0385: }
0386:
0387: public InitializeConceptTagContext validateCurrentApplicationRootHolder() {
0388:
0389: InitializeConceptTagContext outValue = null;
0390:
0391: outValue = validateRootHolder(this .currentApplicationRcth);
0392: //
0393: ConceptTag parentCt = this .currentApplicationRcth
0394: .getFirstChildConceptTag();
0395: if (parentCt instanceof RootWebPageTag) {
0396: RootWebPageTag parentRwpt = ((RootWebPageTag) parentCt);
0397: if (parentRwpt.isTemplateCaller()) {
0398: //template rcth already called in initialization
0399: } else {
0400: setCurrentApplicationTemplate(null, null);
0401: }
0402: } else {
0403: setCurrentApplicationTemplate(null, null);
0404: }
0405:
0406: return outValue;
0407: }
0408:
0409: public void validateCurrentApplicationTemplateRootHolder() {
0410:
0411: validateRootHolder(this .currentApplicationTemplateRcth);
0412: }
0413:
0414: private InitializeConceptTagContext validateRootHolder(
0415: RootConceptTagHolder inRcth) {
0416: //
0417: InitializeConceptTagContext outValue = null;
0418: //
0419: if (this .currentApplicationType != null
0420: && this .currentApplicationName != null) {
0421: //
0422: ConceptTagPreferences localCtp = inRcth.getPreferences();
0423: //
0424: outValue = localCtp.getInitializeContext();
0425: //ConceptTagFlags ictcFlags = ictc.getFlags();
0426: initializeCommonFlags(outValue);
0427: //
0428: //
0429: ConceptTagFlagsHelper.pushStudioUsability(outValue);
0430: inRcth.validate(outValue);
0431: this .sctuc = ConceptTagFlagsHelper
0432: .popStudioUsability(outValue);
0433: } else {
0434: inRcth.validate();
0435: }
0436:
0437: return outValue;
0438: }
0439:
0440: //
0441: public void initializeCommonFlags(ConceptTagCallContext inCtcc) {
0442: //
0443: ConceptTagPreferences localCtp = getCurrentApplicationRootHolder()
0444: .getPreferences();
0445: if (localCtp.getPreferencesHandle().equals(
0446: ConceptTagPreferencesHelper.CTP_PREF_HANDLE__WEB_PAGE)) {
0447: //
0448: ConceptTagFlagsHelper.setCurrentProjectSystem(inCtcc,
0449: getCurrentApplicationProjectSystem());
0450: }
0451: //
0452: ConceptTagFlagsHelper.createStudioValidationMode(inCtcc, true);
0453: ConceptTagFlagsHelper.createConsolePageSession(inCtcc, this );
0454: }
0455:
0456: //public void setCurrentApplicationWebDocTreeState(String inTreeState) {
0457: // //MiscHelper.println("cs.setTreeState = " + inTreeState);
0458: // this.currentApplicationWebDocTreeState = inTreeState;
0459: //}
0460: //////////////////////////////////////////////////
0461: public ProjectSystem getCurrentApplicationProjectSystem() {
0462:
0463: ProjectSystem outValue = null;
0464:
0465: String appType = getCurrentApplicationType();
0466: String appName = getCurrentApplicationName();
0467: outValue = getProjectSystem(appType, appName);
0468:
0469: return outValue;
0470: }
0471:
0472: public ProjectSystem getProjectSystem(String inType, String inName) {
0473:
0474: ProjectSystem outValue = null;
0475:
0476: if (SubmitActionParameters.USER.equals(inType)) {
0477: outValue = getUserProjectSystem(inName);
0478: } else if (SubmitActionParameters.SERVER.equals(inType)) {
0479: outValue = getServerProjectSystem(inName);
0480: } else {
0481: throw UnexpectedSystemException.unknownState();
0482: }
0483:
0484: return outValue;
0485: }
0486:
0487: ////////////////////////
0488: public void valueBound(HttpSessionBindingEvent inEvent) {
0489: }
0490:
0491: public void valueUnbound(HttpSessionBindingEvent inEvent) {
0492: ConsolePageSessionFactory.removeConsoleSession(this .handle);
0493: }
0494:
0495: ////////////////////////
0496: //
0497: //
0498: public boolean isCopyHolderPresent() {
0499:
0500: boolean outValue = false;
0501:
0502: ConceptTagPreferences localCtp = this .currentApplicationRcth
0503: .getPreferences();
0504: String localPrefHandle = localCtp.getPreferencesHandle();
0505: //
0506: outValue = this .copyHolders.containsKey(localPrefHandle);
0507:
0508: return outValue;
0509: }
0510:
0511: public void setCopyHolder(String inCode, int inIndex) {
0512:
0513: //
0514: ConceptTagPreferences localCtp = this .currentApplicationRcth
0515: .getPreferences();
0516: String localPrefHandle = localCtp.getPreferencesHandle();
0517: //
0518: ConceptTagCharacteristic sourceCtchar = this .currentApplicationRcth
0519: .getCharacteristic(inCode);
0520: //
0521: RootConceptTagHolder localRcth = ConceptTagHelper
0522: .createEmptyRootHolder(localPrefHandle);
0523: //
0524: sourceCtchar.copyTo(localRcth.getFirstCharacteristic(),
0525: inIndex, 0);
0526: //
0527: this .copyHolders.put(localPrefHandle, localRcth
0528: .getFirstCharacteristic());
0529: }
0530:
0531: public void enableCopyHolderAsPasteInsert(String inCode, int inIndex) {
0532: //
0533: ConceptTagCharacteristic destCtchar = this .currentApplicationRcth
0534: .getCharacteristic(inCode);
0535: getCopyHolderCharacteristic().copyTo(destCtchar, 0, inIndex);
0536: }
0537:
0538: //
0539: public String getCopyHolderValueAsString() {
0540:
0541: String outValue = null;
0542:
0543: ConceptTagCharacteristic localCtchar = getCopyHolderCharacteristic();
0544: outValue = localCtchar.getValueAsString(0, null);
0545:
0546: return outValue;
0547: }
0548:
0549: public boolean isCopyHolderAsStatic() {
0550:
0551: boolean outValue = false;
0552:
0553: if (isCopyHolderPresent()) {
0554: ConceptTagCharacteristic localCtchar = getCopyHolderCharacteristic();
0555: outValue = localCtchar.isStatic(0, null);
0556: }
0557:
0558: return outValue;
0559: }
0560:
0561: //
0562: public ConceptTag getCopyHolderValueAsConceptTag() {
0563:
0564: ConceptTag outValue = null;
0565:
0566: ConceptTagCharacteristic localCtchar = getCopyHolderCharacteristic();
0567: outValue = localCtchar.getValueAsConceptTag(0, null);
0568:
0569: return outValue;
0570: }
0571:
0572: public boolean isCopyHolderAsConceptTag() {
0573:
0574: boolean outValue = false;
0575:
0576: if (isCopyHolderPresent()) {
0577: ConceptTagCharacteristic localCtchar = getCopyHolderCharacteristic();
0578: outValue = localCtchar.isHolderWithConceptTag(0, null);
0579: }
0580:
0581: return outValue;
0582: }
0583:
0584: //
0585: private ConceptTagCharacteristic getCopyHolderCharacteristic() {
0586:
0587: ConceptTagCharacteristic outValue = null;
0588:
0589: ConceptTagPreferences localCtp = this .currentApplicationRcth
0590: .getPreferences();
0591: String localPrefHandle = localCtp.getPreferencesHandle();
0592: //
0593: Object o = this .copyHolders.get(localPrefHandle);
0594: ////RootConceptTagHolder localRcth = ((RootConceptTagHolder)o);
0595: //////
0596: ////outValue = localRcth.getFirstCharacteristic();
0597: outValue = ((ConceptTagCharacteristic) o);
0598:
0599: return outValue;
0600: }
0601:
0602: //
0603: //private final static RootConceptTagHolder createEmptyRcth() {
0604: //
0605: // RootConceptTagHolder outValue = null;
0606: //
0607: // outValue = SystemEntityTagHelper.getGovernorCall();
0608: //
0609: // ConceptTagCharacteristic localRootCtchar =
0610: // outValue.getFirstCharacteristic();
0611: //
0612: // for (int i = (localRootCtchar.getValueLength() - 1); i >= 0; i--) {
0613: // localRootCtchar.removeValueWithLocalFiles(i);
0614: // }
0615: //
0616: // return outValue;
0617: //}
0618: //
0619: //
0620: ////////////////////////
0621: public void prepareConsolePageContentUsage() {
0622: super .prepareConsolePageContentUsage();
0623: }
0624:
0625: public void commitConsolePageContentUsage() {
0626: this .messageHolder.reset();
0627: super .commitConsolePageContentUsage();
0628: }
0629:
0630: public String getToggleLinkSubSectionAsHandle(int inIndex) {
0631:
0632: String outValue = null;
0633:
0634: ConceptTagPreferences localCtp = getCurrentApplicationRootHolder()
0635: .getPreferences();
0636: //
0637: outValue = MiscHelper.reassembleHandle(
0638: getToggleLinkSubSectionAsList(inIndex), localCtp
0639: .getHandleConjunction());
0640:
0641: return outValue;
0642: }
0643:
0644: protected void pushToggleLinkSection(String inLinkPart) {
0645: super .pushToggleLinkSection(inLinkPart);
0646: }
0647:
0648: //public int getSequenceCode() {
0649: // return this.sequenceCode;
0650: //}
0651: //
0652: //public void setSequenceCode(int inSequenceCode) {
0653: // this.sequenceCode = inSequenceCode;
0654: //}
0655:
0656: public UserHolder getUserHolder() {
0657: return this .uh;
0658: }
0659:
0660: ////////////////////////////////////////////////
0661: //public String getCurrentHighlightHandle() {
0662: // return this.currentHighlightHandle;
0663: //}
0664: //public void setCurrentHighlightHandle(String inCurrentHighlightHandle) {
0665: // ensureHandlePathInTree(inCurrentHighlightHandle);
0666: // this.currentHighlightHandle = inCurrentHighlightHandle;
0667: //}
0668:
0669: //
0670: //public String getConsoleError() {
0671: // return this.consoleError;
0672: //}
0673: //public void setConsoleError(String inError) {
0674: // this.consoleError = inError;
0675: //}
0676: public ConsolePageMessageHolder getMessageHolder() {
0677: return this .messageHolder;
0678: }
0679:
0680: //
0681: public void registerConsolePageContext(String inHandle,
0682: ConsolePageContext inCpc) {
0683:
0684: if (this .cpcHandles.containsKey(inHandle)) {
0685: throw new UnexpectedSystemException("ConceptPageContext '"
0686: + inHandle + "' already registered");
0687: } else {
0688: //
0689: ////maybe this lowers cache size?
0690: //actually, it looses its positioning
0691: //
0692: this .cpcHandles.put(inHandle, inCpc);
0693: inCpc.setHandle(inHandle);
0694: }
0695: }
0696:
0697: public void removeConsolePageContext(String inHandle) {
0698:
0699: if (!this .cpcHandles.containsKey(inHandle)) {
0700: throw new UnexpectedSystemException("ConceptPageContext '"
0701: + inHandle + "' is not registered");
0702: } else {
0703: //
0704: ////maybe this lowers cache size?
0705: //actually, it looses its positioning
0706: //
0707: this .cpcHandles.remove(inHandle);
0708: }
0709: }
0710:
0711: public boolean isConsolePageContextPresent(String inHandle) {
0712: return this .cpcHandles.containsKey(inHandle);
0713: }
0714:
0715: public ConsolePageContext getConsolePageContext(String inHandle) {
0716: return ((ConsolePageContext) (this .cpcHandles.get(inHandle)));
0717: }
0718:
0719: public void removeCachedConsolePageContextHandles() {
0720: this .cpcHandles = new HashMap();
0721: }
0722:
0723: //
0724: //
0725: //
0726: //
0727: public int getUserProjectSystemCount() {
0728:
0729: int outValue = 0;
0730:
0731: loadProjectSystems();
0732:
0733: outValue = this .userProjectSystemNames.size();
0734:
0735: return outValue;
0736: }
0737:
0738: public ProjectSystem getUserProjectSystem(int inIndex) {
0739:
0740: ProjectSystem outValue = null;
0741:
0742: loadProjectSystems();
0743:
0744: String projectName = (String) this .userProjectSystemNames
0745: .get(inIndex);
0746: outValue = getUserProjectSystem(projectName);
0747:
0748: return outValue;
0749: }
0750:
0751: public ProjectSystem getUserProjectSystem(String inName) {
0752:
0753: ProjectSystem outValue = null;
0754:
0755: loadProjectSystems();
0756:
0757: String uppName = inName.toUpperCase();
0758: if (isUserProjectSystemPresent(inName)) {
0759: //MiscHelper.println("ConPagSess getUsProSys uppName = " + uppName);
0760: //MiscHelper.println(
0761: // " - getUsPro = " + this.userProjectSystemValues);
0762: Object o[] = (Object[]) this .userProjectSystemValues
0763: .get(uppName);
0764: outValue = (ProjectSystem) o[0];
0765: } else {
0766: //MiscHelper.println("ConSess vals1 = "
0767: // + this.userProjectSystemValues);
0768: //MiscHelper.println("ConSess names1 = "
0769: // + this.userProjectSystemNames);
0770: throw new UnexpectedSystemException("Project '" + inName
0771: + "' not found");
0772: }
0773:
0774: return outValue;
0775: }
0776:
0777: public ConceptTagCharacteristic getUserProjectSystemCharacteristic(
0778: String inName) {
0779:
0780: ConceptTagCharacteristic outValue = null;
0781:
0782: loadProjectSystems();
0783:
0784: String uppName = inName.toUpperCase();
0785: if (isUserProjectSystemPresent(inName)) {
0786: Object o[] = (Object[]) this .userProjectSystemValues
0787: .get(uppName);
0788: outValue = (ConceptTagCharacteristic) o[1];
0789: } else {
0790: //MiscHelper.println("ConSess vals1 = "
0791: // + this.userProjectSystemValues);
0792: //MiscHelper.println("ConSess names1 = "
0793: // + this.userProjectSystemNames);
0794: throw new UnexpectedSystemException("Project '" + inName
0795: + "' not found");
0796: }
0797:
0798: return outValue;
0799: }
0800:
0801: public void addUserProjectSystem(ProjectSystem inPs,
0802: ConceptTagCharacteristic inPsCtchar) {
0803: //
0804: String name = inPs.getName();
0805: if (!isUserProjectSystemPresent(name)) {
0806: String upperName = name.toUpperCase();
0807: this .userProjectSystemNames.add(upperName);
0808: this .userProjectSystemValues.put(upperName, new Object[] {
0809: inPs, inPsCtchar });
0810: //MiscHelper.println("ConSess names2 = "
0811: // + this.userProjectSystemNames);
0812: //MiscHelper.println("ConSess vals2 = "
0813: // + this.userProjectSystemValues);
0814: } else {
0815: throw new UnexpectedSystemException("Project '" + name
0816: + "' already exists");
0817: }
0818: }
0819:
0820: public void removeUserProjectSystem(String inName) {
0821: if (isUserProjectSystemPresent(inName)) {
0822: String upperName = inName.toUpperCase();
0823: this .userProjectSystemNames.remove(upperName);
0824: this .userProjectSystemValues.remove(upperName);
0825: } else {
0826: throw new UnexpectedSystemException("Project '" + inName
0827: + "' does not exists");
0828: }
0829: }
0830:
0831: public boolean isUserProjectSystemPresent(String inName) {
0832: return this .userProjectSystemValues.containsKey(inName
0833: .toUpperCase());
0834: }
0835:
0836: //
0837: //
0838: public HashMap getDeployableProjects() {
0839:
0840: HashMap outValue = null;
0841:
0842: ProjectService projectService = ProjectServiceCallerFactory
0843: .getProjectService();
0844: outValue = projectService.accessDeployableProjects(
0845: GovernorCallHelper.getLocalDummyCharacteristic(), 0);
0846:
0847: return outValue;
0848: }
0849:
0850: //
0851: public int getServerProjectSystemCount() {
0852:
0853: int outValue = 0;
0854:
0855: loadProjectSystems();
0856:
0857: outValue = this .serverProjectSystemNames.size();
0858:
0859: return outValue;
0860: }
0861:
0862: public ProjectSystem getServerProjectSystem(int inIndex) {
0863:
0864: ProjectSystem outValue = null;
0865:
0866: loadProjectSystems();
0867:
0868: String projectName = (String) this .serverProjectSystemNames
0869: .get(inIndex);
0870: outValue = getServerProjectSystem(projectName);
0871:
0872: return outValue;
0873: }
0874:
0875: public ProjectSystem getServerProjectSystem(String inName) {
0876:
0877: ProjectSystem outValue = null;
0878:
0879: loadProjectSystems();
0880:
0881: String uppName = inName.toUpperCase();
0882: if (isServerProjectSystemPresent(inName)) {
0883: Object o[] = (Object[]) this .serverProjectSystemValues
0884: .get(uppName);
0885: outValue = (ProjectSystem) o[0];
0886: } else {
0887: //MiscHelper.println("ConSess vals1 = "
0888: // + this.serverProjectSystemValues);
0889: //MiscHelper.println("ConSess names1 = "
0890: // + this.serverProjectSystemNames);
0891: throw new UnexpectedSystemException("Project '" + inName
0892: + "' not found");
0893: }
0894:
0895: return outValue;
0896: }
0897:
0898: public ConceptTagCharacteristic getServerProjectSystemCharacteristic(
0899: String inName) {
0900:
0901: ConceptTagCharacteristic outValue = null;
0902:
0903: loadProjectSystems();
0904:
0905: String uppName = inName.toUpperCase();
0906: if (isServerProjectSystemPresent(inName)) {
0907: Object o[] = (Object[]) this .serverProjectSystemValues
0908: .get(uppName);
0909: outValue = (ConceptTagCharacteristic) o[1];
0910: } else {
0911: //MiscHelper.println("ConSess vals1 = "
0912: // + this.serverProjectSystemValues);
0913: //MiscHelper.println("ConSess names1 = "
0914: // + this.serverProjectSystemNames);
0915: throw new UnexpectedSystemException("Project '" + inName
0916: + "' not found");
0917: }
0918:
0919: return outValue;
0920: }
0921:
0922: public void addServerProjectSystem(ProjectSystem inPs,
0923: ConceptTagCharacteristic inPsCtchar) {
0924: //
0925: String name = inPs.getName();
0926: if (!isServerProjectSystemPresent(name)) {
0927: String upperName = name.toUpperCase();
0928: this .serverProjectSystemNames.add(upperName);
0929: this .serverProjectSystemValues.put(upperName, new Object[] {
0930: inPs, inPsCtchar });
0931: //MiscHelper.println("ConSess names2 = "
0932: // + this.serverProjectSystemNames);
0933: //MiscHelper.println("ConSess vals2 = "
0934: // + this.serverProjectSystemValues);
0935: } else {
0936: throw new UnexpectedSystemException("Project '" + name
0937: + "' already exists");
0938: }
0939: }
0940:
0941: public void removeServerProjectSystem(String inName) {
0942: if (isServerProjectSystemPresent(inName)) {
0943: String upperName = inName.toUpperCase();
0944: this .serverProjectSystemNames.remove(upperName);
0945: this .serverProjectSystemValues.remove(upperName);
0946: } else {
0947: throw new UnexpectedSystemException("Project '" + inName
0948: + "' already exists");
0949: }
0950: }
0951:
0952: public boolean isServerProjectSystemPresent(String inName) {
0953: return this .serverProjectSystemValues.containsKey(inName
0954: .toUpperCase());
0955: }
0956:
0957: public ArrayList getWebDocsDirs(ProjectSystem inPs) {
0958:
0959: ArrayList outValue = new ArrayList();
0960:
0961: outValue.add(inPs.getWebDocs());
0962: outValue.add(inPs.getWebDocsProperties());
0963: //outValue.add(inPs.getWebMacros());
0964: //outValue.add(inPs.getWebTemplates());
0965: //outValue.add(inPs.getWebServlets());
0966:
0967: return outValue;
0968: }
0969:
0970: private void loadProjectSystems() {
0971:
0972: if (!this .projectSystemInitialized) {
0973: //
0974: reloadProjectSystems();
0975: //
0976: this .projectSystemInitialized = true;
0977: }
0978: }
0979:
0980: public void reloadProjectSystems() {
0981: ProjectService ps = ProjectServiceCallerFactory
0982: .getProjectService();
0983: loadUserProjectSystems(ps);
0984: loadServerProjectSystems(ps);
0985: }
0986:
0987: private void loadUserProjectSystems(ProjectService inPs) {
0988: //
0989: this .userProjectSystemNames = new ArrayList();
0990: this .userProjectSystemValues = new HashMap();
0991: //
0992: RootConceptTagHolder dummyRcth = GovernorCallHelper
0993: .createGovernorRequest("dummy", "dummy");
0994: GovernorCall dummyGc = (GovernorCall) dummyRcth
0995: .getFirstChildConceptTag();
0996: ArrayList projectList = inPs.accessProjectSystemNames(dummyGc
0997: .addPrepareArgumentAsSEntity(), this .uh
0998: .getUserIdentity(), false, null);
0999: //
1000: for (int i = 0; i < projectList.size(); i++) {
1001: String nextName = projectList.get(i).toString()
1002: .toUpperCase();
1003: ConceptTagCharacteristic dummyCtchar = dummyGc
1004: .addPrepareArgumentAsSEntity();
1005: ProjectSystem nextProject = inPs.accessProjectSystem(
1006: dummyCtchar, 0, this .uh.getUserIdentity(), false,
1007: nextName);
1008: this .userProjectSystemNames.add(nextName);
1009: this .userProjectSystemValues.put(nextName, new Object[] {
1010: nextProject, dummyCtchar });
1011: }
1012: }
1013:
1014: private void loadServerProjectSystems(ProjectService inPs) {
1015: //
1016: this .serverProjectSystemNames = new ArrayList();
1017: this .serverProjectSystemValues = new HashMap();
1018: //
1019: RootConceptTagHolder dummyRcth = GovernorCallHelper
1020: .createGovernorRequest("dummy", "dummy");
1021: GovernorCall dummyGc = (GovernorCall) dummyRcth
1022: .getFirstChildConceptTag();
1023: ArrayList projectList = inPs.accessProjectSystemNames(dummyGc
1024: .addPrepareArgumentAsSEntity(), null, true, null);
1025: //
1026: for (int i = 0; i < projectList.size(); i++) {
1027: String nextName = projectList.get(i).toString()
1028: .toUpperCase();
1029: ConceptTagCharacteristic dummyCtchar = dummyGc
1030: .addPrepareArgumentAsSEntity();
1031: ProjectSystem nextProject = inPs.accessProjectSystem(
1032: dummyCtchar, 0, null, true, nextName);
1033: this .serverProjectSystemNames.add(nextName);
1034: this .serverProjectSystemValues.put(nextName, new Object[] {
1035: nextProject, dummyCtchar });
1036: }
1037: }
1038:
1039: public void setDataAccessResults(ArrayList inResults) {
1040: this .dataAccessResults = inResults;
1041: }
1042:
1043: public ArrayList getDataAccessResults() {
1044: return this .dataAccessResults;
1045: }
1046:
1047: public void setWorkflowInstance(WorkflowInstance inWorkflowInstance) {
1048: this .workflowInstance = inWorkflowInstance;
1049: }
1050:
1051: public WorkflowInstance getWorkflowInstance() {
1052: return this .workflowInstance;
1053: }
1054:
1055: public void registerCommonStem(String inValue) {
1056: getPageSetupContext().registerCommonStem(inValue);
1057: }
1058:
1059: //public void saveProjectApplicationSet() {
1060: // //WorkflowServiceCaller wsc =
1061: // // WorkflowServiceCallerFactory.getWorkflowServiceCaller();
1062: // //WorkflowLifecycle wl =
1063: // //WorkflowLifecycleFactory.getWorkflowLifecycle();
1064: // //wsc.setProjectApplicationSet(this.pas, this.uh);
1065: // //wl.close();
1066: // MiscHelper.println("ConsoleSession saveProjectApplSet not Impl");
1067: //}
1068:
1069: //
1070: public void setDocumentSystemRoot(DocumentFileSystemRoot inDsr) {
1071: this .dsr = inDsr;
1072: }
1073:
1074: public DocumentFileSystemRoot getDocumentSystemRoot() {
1075: return this .dsr;
1076: }
1077:
1078: //
1079: public boolean isAdministrator() {
1080:
1081: boolean outValue = false;
1082:
1083: if (this .accessAdmin != null) {
1084: outValue = this .accessAdmin.booleanValue();
1085: } else {
1086: outValue = ConsolePageSession
1087: .isAdministrator(getUserHolder());
1088: this .accessAdmin = new Boolean(outValue);
1089: }
1090:
1091: return outValue;
1092: }
1093:
1094: public boolean isDeveloper() {
1095:
1096: boolean outValue = false;
1097:
1098: if (this .accessDevel != null) {
1099: outValue = this .accessDevel.booleanValue();
1100: } else {
1101: outValue = ConsolePageSession.isDeveloper(getUserHolder());
1102: this .accessDevel = new Boolean(outValue);
1103: }
1104:
1105: return outValue;
1106: }
1107:
1108: //private boolean isGreatestCommonMultipleGreaterThanOne(int inA, int inB) {
1109: //
1110: // boolean outValue = false;
1111: //
1112: // int ceiling = inA;
1113: // if (ceiling > inB) {
1114: // ceiling = inB;
1115: // }
1116: //
1117: // for (int i = 2; i <= ceiling; i++) {
1118: // if (((inA%i) == 0) && ((inB%i) == 0)) {
1119: // outValue = true;
1120: // break;
1121: // }
1122: // }
1123: //
1124: // return outValue;
1125: //}
1126:
1127: //
1128: //
1129: //
1130: protected void setToggleLink(ArrayList inToggleLink) {
1131: super .setToggleLink(inToggleLink);
1132: }
1133:
1134: //protected int getMenuCount() {
1135: // return super.getMenuCount();
1136: //}
1137: //protected ArrayList getMenuToggleLink(int inIndex) {
1138: // return super.getMenuToggleLink(inIndex);
1139: //}
1140: protected MenuBranch getMenuBranch(int inIndex) {
1141: return super .getMenuBranch(inIndex);
1142: }
1143:
1144: protected HashMap getMenuTableProps(int inIndex) {
1145: return super .getMenuTableProps(inIndex);
1146: }
1147:
1148: protected HashMap getMenuTableStyles(int inIndex) {
1149: return super .getMenuTableStyles(inIndex);
1150: }
1151:
1152: protected HashMap getMenuCellProps(int inIndex) {
1153: return super .getMenuCellProps(inIndex);
1154: }
1155:
1156: protected HashMap getMenuCellStyles(int inIndex) {
1157: return super .getMenuCellStyles(inIndex);
1158: }
1159:
1160: protected Integer getMenuTextLimit(int inIndex) {
1161: return super .getMenuTextLimit(inIndex);
1162: }
1163:
1164: //
1165: private final static boolean isDeveloper(UserHolder inUser) {
1166:
1167: boolean outValue = false;
1168:
1169: SecurityLifecycle uaaac = SecurityLifecycleHelper
1170: .getSecurityLifecycle();
1171:
1172: GroupHolder group = uaaac
1173: .getSystemGroup(SystemGroups.DEVELOPERS);
1174:
1175: outValue = uaaac.isUserInGroup(inUser, group);
1176:
1177: return outValue;
1178: }
1179:
1180: private final static boolean isAdministrator(UserHolder inUser) {
1181:
1182: boolean outValue = false;
1183:
1184: SecurityLifecycle uaaac = SecurityLifecycleHelper
1185: .getSecurityLifecycle();
1186:
1187: GroupHolder group = uaaac
1188: .getSystemGroup(SystemGroups.ADMINISTRATORS);
1189:
1190: outValue = uaaac.isUserInGroup(inUser, group);
1191:
1192: return outValue;
1193: }
1194:
1195: //
1196: //
1197: //
1198: public String toString() {
1199:
1200: StringBuffer outValue = new StringBuffer();
1201:
1202: //
1203: outValue.append("ConsolePageSession Status {");
1204: outValue.append("\n");
1205: //
1206: //
1207: outValue.append(" ConsoleConfigs = " + this .consoleConfigs);
1208: outValue.append("\n");
1209: outValue.append(" ConsolePageContexts = " + this .cpcHandles);
1210: outValue.append("\n");
1211: outValue.append(" CopyHolders = " + this .copyHolders);
1212: outValue.append("\n");
1213: //
1214: //
1215: outValue.append("}");
1216: outValue.append("\n");
1217:
1218: return outValue.toString();
1219: }
1220:
1221: }
|