KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > engines > deletecontainer > DeleteContainer_Engine


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12

13 //
14
// EV 28.01.20001
15
//
16

17 package org.jahia.engines.deletecontainer;
18
19 import java.util.ArrayList JavaDoc;
20 import java.util.Enumeration JavaDoc;
21 import java.util.HashMap JavaDoc;
22 import java.util.HashSet JavaDoc;
23 import java.util.Iterator JavaDoc;
24 import java.util.Set JavaDoc;
25 import java.util.Vector JavaDoc;
26
27 import javax.servlet.http.HttpSession JavaDoc;
28
29 import org.jahia.content.ContentContainerKey;
30 import org.jahia.content.ContentContainerListsXRefManager;
31 import org.jahia.content.ContentObject;
32 import org.jahia.data.JahiaData;
33 import org.jahia.data.containers.JahiaContainer;
34 import org.jahia.data.containers.JahiaContainerList;
35 import org.jahia.data.containers.JahiaContentContainerFacade;
36 import org.jahia.data.events.JahiaEvent;
37 import org.jahia.data.fields.FieldTypes;
38 import org.jahia.data.fields.JahiaField;
39 import org.jahia.data.fields.LoadFlags;
40 import org.jahia.engines.EngineToolBox;
41 import org.jahia.engines.JahiaEngine;
42 import org.jahia.engines.lock.LockEngine;
43 import org.jahia.exceptions.JahiaException;
44 import org.jahia.exceptions.JahiaForbiddenAccessException;
45 import org.jahia.exceptions.JahiaSessionExpirationException;
46 import org.jahia.params.ParamBean;
47 import org.jahia.registries.ServicesRegistry;
48 import org.jahia.services.containers.ContentContainer;
49 import org.jahia.services.lock.LockKey;
50 import org.jahia.services.lock.LockService;
51 import org.jahia.services.pages.JahiaPage;
52 import org.jahia.services.pages.PageLoadFlags;
53 import org.jahia.services.usermanager.JahiaUser;
54 import org.jahia.services.version.EntryLoadRequest;
55 import org.jahia.services.version.StateModificationContext;
56 import org.jahia.services.cache.HtmlCache;
57 import org.jahia.services.cache.CacheFactory;
58 import org.jahia.utils.LanguageCodeConverters;
59 import org.jahia.content.ContentPageKey;
60 import org.jahia.content.ObjectLink;
61 import org.jahia.content.ObjectKey;
62 import org.jahia.content.JahiaObject;
63 import org.jahia.content.ContentDefinition;
64 import org.jahia.services.version.ContentObjectEntryState;
65 import org.jahia.content.PageReferenceableInterface;
66 import org.jahia.services.fields.ContentField;
67 import org.jahia.services.pages.ContentPage;
68 import java.util.Map JavaDoc;
69
70 public class DeleteContainer_Engine implements JahiaEngine {
71
72     /** The engine's name */
73     public static final String JavaDoc ENGINE_NAME = "deletecontainer";
74
75     /** logging */
76     private static final org.apache.log4j.Logger logger =
77             org.apache.log4j.Logger.getLogger (DeleteContainer_Engine.class);
78
79     /** unique instance of this class */
80     private static DeleteContainer_Engine instance = null;
81
82     private static final String JavaDoc TEMPLATE_JSP = "delete_container";
83     private EngineToolBox toolBox;
84
85
86     /**
87      * Default constructor, creates a new <code>DeleteContainer_Engine</code> instance.
88      */

89     private DeleteContainer_Engine () {
90         logger.debug (
91                 "***** Starting " + DeleteContainer_Engine.class.getName () + " engine *****");
92         toolBox = EngineToolBox.getInstance ();
93     }
94
95     /**
96      * Returns the unique instance of this class
97      *
98      * @return the unique instance of this class
99      */

100     public static DeleteContainer_Engine getInstance () {
101         if (instance == null) {
102             instance = new DeleteContainer_Engine ();
103         }
104         return instance;
105     }
106
107     /**
108      * authoriseRender
109      */

110     public boolean authoriseRender (ParamBean jParams) {
111         return toolBox.authoriseRender (jParams);
112     } // end authoriseRender
113

114     /**
115      * renderLink
116      */

117     public String JavaDoc renderLink (ParamBean jParams, Object JavaDoc theObj)
118             throws JahiaException {
119         ContentContainer contentContainer = (ContentContainer) theObj;
120         String JavaDoc params = EMPTY_STRING;
121         params += "?mode=display";
122         params += "&cid=" + contentContainer.getID ();
123         return jParams.composeEngineUrl (ENGINE_NAME, params);
124     } // end renderLink
125

126     /**
127      * needsJahiaData
128      */

129     public boolean needsJahiaData (ParamBean jParams) {
130         return false;
131     } // end needsJahiaData
132

133     /**
134      * handles the engine actions
135      *
136      * @param jParams a ParamBean object
137      * @param jData a JahiaData object (not mandatory)
138      */

139     public void handleActions (ParamBean jParams, JahiaData jData)
140             throws JahiaException,
141             JahiaSessionExpirationException,
142             JahiaForbiddenAccessException {
143         // initalizes the hashmap
144
HashMap JavaDoc engineMap = initEngineMap (jParams);
145
146         // checks if the user has the right to display the engine
147
JahiaContainer theContainer = (JahiaContainer) engineMap.get (
148                 "theContainer");
149         JahiaUser theUser = jParams.getUser ();
150
151         if (theContainer.checkWriteAccess (theUser)) {
152             // #ifdef LOCK
153
LockService lockRegistry = ServicesRegistry.getInstance ().
154                     getLockService ();
155             if (jParams.settings ().areLocksActivated ()) {
156                 LockKey lockKey = LockKey.composeLockKey (LockKey.
157                         DELETE_CONTAINER_TYPE,
158                         theContainer.getID (), theContainer.getPageID ());
159                 if (lockRegistry.acquire (lockKey, jParams.getUser (),
160                         jParams.getSessionID (),
161                         jParams.getSession ().
162                         getMaxInactiveInterval ())) {
163                     // #endif
164
flushPageCacheThatDisplayContainer (jParams, theContainer);
165                     engineMap.put ("writeAccess", Boolean.TRUE);
166                     processScreen (jParams, engineMap);
167                     // #ifdef LOCK
168
} else {
169                     // Prerequisites are NOT completed ! Damned ! Redirect the JSP
170
// output to lock informations.
171
LockEngine.getInstance ().redirect (jParams, engineMap,
172                             lockKey);
173                 }
174             }
175             // #endif
176
} else {
177             throw new JahiaForbiddenAccessException ();
178         }
179
180         // displays the screen
181
toolBox.displayScreen (jParams, engineMap);
182
183     } // end handleActions
184

185
186     /**
187      * Retrieve the engine name.
188      *
189      * @return the engine name.
190      */

191     public final String JavaDoc getName () {
192         return ENGINE_NAME;
193     }
194
195
196     /**
197      * prepares the screen requested by the user
198      *
199      * @param jParams a ParamBean object
200      */

201     public void processScreen (ParamBean jParams, HashMap JavaDoc engineMap)
202             throws JahiaException {
203         // gets the current screen
204
// screen = edit, rights, logs
205
String JavaDoc theScreen = (String JavaDoc) engineMap.get ("screen");
206         JahiaContainer theContainer = (JahiaContainer) engineMap.get (
207                 "theContainer");
208
209         // #ifdef LOCK
210
LockKey lockKey = LockKey.composeLockKey (LockKey.DELETE_CONTAINER_TYPE,
211                 theContainer.getID (),
212                 theContainer.getPageID ());
213         LockService lockRegistry = ServicesRegistry.getInstance ().
214                 getLockService ();
215         // #endif
216

217         // dispatches to the appropriate sub engine
218
if (theScreen.equals ("edit")) {
219             composeWarningMessages (jParams, engineMap);
220         } else if (theScreen.equals ("save")) {
221             if (engineMap.get ("writeAccess") != null) {
222
223                 // #ifdef LOCK
224
// Did somebody steal the lock ? Panpan cucul !
225
if (jParams.settings ().areLocksActivated () &&
226                         lockRegistry.isStealedInContext (lockKey, jParams.getUser (),
227                                 jParams.getSessionID ())) {
228                     engineMap.put ("screen",
229                             jParams.getRequest ().getParameter ("lastscreen"));
230                     engineMap.put ("jspSource", "apply");
231                     return;
232                 }
233                 // #endif
234

235                 JahiaEvent theEvent = new JahiaEvent (this, jParams,
236                         theContainer);
237                 ServicesRegistry.getInstance ().getJahiaEventService ().
238                         fireDeleteContainer (theEvent);
239
240                 // ServicesRegistry.getInstance().getJahiaContainersService().deleteContainer( theContainer.getID(), jParams );
241
ContentContainer contentContainer = ContentContainer.
242                         getContainer (theContainer.getID ());
243
244                 // we only need to remove the shared language since this will
245
// automatically mark all sub languages for deletion too...
246
Set JavaDoc curLanguageCodes = new HashSet JavaDoc ();
247                 curLanguageCodes.add (ContentObject.SHARED_LANGUAGE);
248
249                 StateModificationContext stateModifContext =
250                         new StateModificationContext (new
251                                 ContentContainerKey (
252                                         theContainer.getID ()), curLanguageCodes, true);
253                 stateModifContext.pushAllLanguages (true);
254
255                 contentContainer.markLanguageForDeletion (
256                         jParams.getUser (),
257                         ContentObject.SHARED_LANGUAGE,
258                         stateModifContext);
259
260                 flushPageCacheThatDisplayContainer (jParams, theContainer);
261
262                 // #ifdef LOCK
263
if (jParams.settings ().areLocksActivated ()) {
264                     lockRegistry.release (lockKey, jParams.getUser (),
265                             jParams.getSessionID ());
266                 }
267                 // #endif
268
} else {
269                 throw new JahiaForbiddenAccessException ();
270             }
271         } else if (theScreen.equals ("cancel")) {
272             // #ifdef LOCK
273
if (jParams.settings ().areLocksActivated ()) {
274                 lockRegistry.release (lockKey, jParams.getUser (),
275                         jParams.getSessionID ());
276                 flushPageCacheThatDisplayContainer (jParams, theContainer);
277             }
278             // #endif
279
engineMap.put ("jspSource", "close");
280         }
281     } // end processScreen
282

283     private void flushPageCacheThatDisplayContainer (ParamBean jParams,
284                                                      JahiaContainer theContainer)
285             throws JahiaException {
286         EntryLoadRequest loadVersion = EntryLoadRequest.CURRENT;
287         if (ServicesRegistry.getInstance ().getJahiaVersionService ().
288                 isStagingEnabled (theContainer.getJahiaID ()))
289             loadVersion = EntryLoadRequest.STAGED;
290
291         JahiaContainerList theList = ServicesRegistry.getInstance ().
292                 getJahiaContainersService ().
293                 loadContainerListInfo (theContainer.
294                 getListID (), loadVersion);
295
296         // Get the cache instance and invalidate the related page entries
297
HtmlCache htmlCache = CacheFactory.getHtmlCache ();
298         if (htmlCache == null)
299             logger.warn ("Could not get the HTML cache instance!!");
300
301         // since we have made modifications concerning this page, let's flush
302
// the content cache for all the users and browsers as well as all
303
// pages that display this containerList...
304
if (theList != null) {
305             Set JavaDoc containerPageRefs = ContentContainerListsXRefManager.
306                     getInstance ().
307                     getAbsoluteContainerListPageIDs (
308                             theList.getID ());
309             if (containerPageRefs != null) {
310                 Iterator JavaDoc pageRefIDs = containerPageRefs.iterator ();
311                 while (pageRefIDs.hasNext ()) {
312                     Integer JavaDoc curPageID = (Integer JavaDoc) pageRefIDs.next ();
313
314                     if (htmlCache != null)
315                         htmlCache.invalidatePageEntries (curPageID.toString (),jParams.getEntryLoadRequest().getWorkflowState());
316                 }
317             } else {
318                 logger.debug ("Why is cross ref list empty ?");
319             }
320         } else {
321             logger.debug ("Couldn't retrieve parent containerList, why is that ?");
322         }
323
324         // since we have made modifications concerning this page, let's flush
325
// the content cache for all the users and browsers...
326
if (htmlCache != null)
327             htmlCache.invalidatePageEntries (Integer.toString (jParams.getPageID()).toString(),
328                                              jParams.getEntryLoadRequest().getWorkflowState());
329     }
330
331     /**
332      * inits the engine map
333      *
334      * @param jParams a ParamBean object (with request and response)
335      *
336      * @return a HashMap object containing all the basic values needed by an engine
337      */

338     private HashMap JavaDoc initEngineMap (ParamBean jParams)
339             throws JahiaException,
340             JahiaSessionExpirationException {
341         HashMap JavaDoc engineMap;
342         JahiaContainer theContainer;
343
344         // gets session values
345
//HttpSession theSession = jParams.getRequest().getSession( true );
346
HttpSession JavaDoc theSession = jParams.getSession ();
347
348         // gets container id
349
String JavaDoc ctnidStr = jParams.getRequest ().getParameter ("cid");
350         int ctnid;
351         try {
352             ctnid = Integer.parseInt (ctnidStr);
353         } catch (NumberFormatException JavaDoc nfe) {
354             String JavaDoc errorMsg = "Error in parameters : cid (" + ctnidStr +
355                     ") cannot be converted in int";
356             throw new JahiaException ("Error in parameters", errorMsg,
357                     JahiaException.DATA_ERROR,
358                     JahiaException.CRITICAL_SEVERITY);
359         }
360
361         // Resolve language code
362
String JavaDoc languageCode = jParams.getRequest ().getParameter ("engine_lang");
363         if (languageCode == null) {
364             languageCode = jParams.settings ().getDefaultLanguageCode ();
365         }
366         String JavaDoc prevLanguageCode = jParams.getRequest ().getParameter (
367                 "prev_engine_lang");
368         if (prevLanguageCode == null) {
369             prevLanguageCode = languageCode;
370         }
371
372         EntryLoadRequest entryLoadRequest =
373                 new EntryLoadRequest (EntryLoadRequest.STAGING_WORKFLOW_STATE,
374                         0, new ArrayList JavaDoc ());
375         entryLoadRequest.getLocales ()
376                 .add (LanguageCodeConverters.languageCodeToLocale (languageCode));
377         EntryLoadRequest prevEntryLoadRequest =
378                 new EntryLoadRequest (EntryLoadRequest.STAGING_WORKFLOW_STATE,
379                         0, new ArrayList JavaDoc ());
380         prevEntryLoadRequest.getLocales ()
381                 .add (LanguageCodeConverters.languageCodeToLocale (prevLanguageCode));
382
383         // tries to find if this is the first screen generated by the engine
384
String JavaDoc theScreen = jParams.getRequest ().getParameter ("screen");
385         if (theScreen != null) {
386             // if no, load the field value from the session
387
engineMap = (HashMap JavaDoc) theSession.getAttribute (
388                     "jahia_session_engineMap");
389
390             ///////////////////////////////////////////////////////////////////////////////////////
391
// FIXME -Fulco-
392
//
393
// This is a quick hack, engineMap should not be null if the session didn't
394
// expired. Maybe there are other cases where the engineMap can be null, I didn't
395
// checked them at all.
396
///////////////////////////////////////////////////////////////////////////////////////
397
if (engineMap == null) {
398                 throw new JahiaSessionExpirationException ();
399             }
400
401             theContainer = (JahiaContainer) engineMap.get ("theContainer");
402         } else {
403
404             JahiaContentContainerFacade jahiaContentContainerFacade
405                     = new JahiaContentContainerFacade (ctnid,
406                             LoadFlags.ALL,
407                             jParams,
408                             jParams.getSite ().
409                     getLanguageSettingsAsLocales (true),
410                             false);
411             theContainer = jahiaContentContainerFacade.getContainer (
412                     entryLoadRequest, true);
413             if (theContainer == null &&
414                     jahiaContentContainerFacade.getContainers ().hasMoreElements ()) {
415                 // requested language not found, return the first available language
416
theContainer =
417                         (JahiaContainer) jahiaContentContainerFacade.getContainers ().
418                         nextElement ();
419             }
420
421             theScreen = "edit";
422             // init engine map
423
engineMap = new HashMap JavaDoc ();
424             engineMap.put ("theContainer", theContainer);
425             engineMap.put (RENDER_TYPE_PARAM,
426                     new Integer JavaDoc (JahiaEngine.RENDERTYPE_FORWARD));
427             engineMap.put (ENGINE_NAME_PARAM, ENGINE_NAME);
428             engineMap.put (ENGINE_URL_PARAM,
429                     jParams.composeEngineUrl (ENGINE_NAME,
430                             "?cid=" + theContainer.getID ()));
431             theSession.setAttribute ("jahia_session_engineMap", engineMap);
432         }
433
434         // sets screen
435
engineMap.put ("screen", theScreen);
436         if (!theScreen.equals ("save")) {
437             engineMap.put ("jspSource", TEMPLATE_JSP);
438         } else {
439             engineMap.put ("jspSource", "close");
440         }
441
442         // sets engineMap for JSPs
443
jParams.getRequest ().setAttribute ("org.jahia.engines.EngineHashMap",
444                 engineMap);
445
446         return engineMap;
447     } // end initEngineMap
448

449     /**
450      * composes warning messages
451      *
452      * @param jParams a ParamBean object (with request and response)
453      * @param engineMap the engine parameters
454      */

455     private void composeWarningMessages (ParamBean jParams, HashMap JavaDoc engineMap)
456             throws JahiaException {
457         JahiaContainer theContainer = (JahiaContainer) engineMap.get (
458                 "theContainer");
459
460         engineMap.put ("deletedPages", new Vector JavaDoc ());
461         engineMap.put ("deletedLinks", new Vector JavaDoc ());
462         engineMap.put ("futureBrokenLinkObjects", new ArrayList JavaDoc ());
463         engineMap.put ("warning", Boolean.FALSE);
464
465         Enumeration JavaDoc theFields = theContainer.getFields ();
466
467         JahiaPage page = ServicesRegistry.getInstance ().getJahiaPageService ().
468                 lookupPage (theContainer.getPageID (), jParams);
469         int pageDefID = page.getPageTemplateID ();
470
471         Set JavaDoc objectKeysPointingToDeletedContent = new HashSet JavaDoc ();
472
473         while (theFields.hasMoreElements ()) {
474             JahiaField theField = (JahiaField) theFields.nextElement ();
475             int fieldType = theField.getDefinition ().getType (pageDefID);
476             fieldType = (fieldType != 0) ? fieldType : theField.getType ();
477
478             // checks if deleting the container means deleting pages
479
if (fieldType == FieldTypes.PAGE) {
480                 JahiaPage thePage = (JahiaPage) theField.getObject ();
481                 if (thePage != null) {
482
483                     objectKeysPointingToDeletedContent.addAll (
484                             contentObjectPointingOnPage (thePage.getID ()));
485
486                     Vector JavaDoc deletedPages = ServicesRegistry.getInstance().
487                                           getJahiaPageService().
488                                           getPageSubTree(thePage.getID(),
489                         PageLoadFlags.DIRECT, jParams);
490
491                     // now let's check if some of these pages have already been
492
// deleted or marked for deletion.
493
/**
494                      * @todo this shouldn't be necessary, we should have a way
495                      * to specify we only want non-deleted or marked for
496                      * deletion pages
497                      */

498                     Vector JavaDoc pageChildsWithoutDeleted = new Vector JavaDoc();
499                     for (int i=0; i < deletedPages.size(); i++) {
500                         JahiaPage curJahiaPage = (JahiaPage) deletedPages.get(i);
501                         ContentPage curContentPage = curJahiaPage.getContentPage();
502                         if ((curContentPage.getDeleteVersionID() == -1)) {
503                             // we must now still check if the page has been marked
504
// for deletion in all the languages.
505
Map JavaDoc languageStates = curContentPage.getLanguagesStates(false);
506                             boolean markedInAllLanguages = true;
507                             Iterator JavaDoc languageCodeIter = languageStates.keySet().iterator();
508                             while (languageCodeIter.hasNext()) {
509                                 String JavaDoc curLanguageCode = (String JavaDoc) languageCodeIter.next();
510                                 if (!curContentPage.isStagedEntryMarkedForDeletion(curLanguageCode)) {
511                                     markedInAllLanguages = false;
512                                     break;
513                                 }
514                             }
515                             if (!markedInAllLanguages) {
516                                 pageChildsWithoutDeleted.add(curJahiaPage);
517                             }
518                         }
519                     }
520                     deletedPages = pageChildsWithoutDeleted;
521
522                     Vector JavaDoc deletedLinks = new Vector JavaDoc();
523                     deletedLinks.addAll(ServicesRegistry.getInstance().
524                                         getJahiaPageService().
525                                         getPagesPointingOnPage(thePage.getID(),
526                         jParams));
527                     for (int i = 0; i < deletedPages.size(); i++) {
528                         JahiaPage aPage = (JahiaPage) deletedPages.elementAt(i);
529                         objectKeysPointingToDeletedContent.addAll(
530                             contentObjectPointingOnPage(aPage.getID()));
531                         deletedLinks.addAll(ServicesRegistry.getInstance().
532                                             getJahiaPageService().
533                                             getPagesPointingOnPage(aPage.getID(),
534                             jParams));
535                     }
536                     engineMap.put ("deletedPages", deletedPages);
537                     engineMap.put ("deletedLinks", deletedLinks);
538                     ArrayList JavaDoc hardcodedLinkSourceObject =
539                             buildHardcodedSourceInfo (
540                                     objectKeysPointingToDeletedContent, jParams);
541                     engineMap.put ("futureBrokenLinkObjects",
542                             hardcodedLinkSourceObject);
543                     if ((deletedPages.size () > 0) || (deletedLinks.size () > 0) ||
544                             (objectKeysPointingToDeletedContent.size () > 0)) {
545                         engineMap.put ("warning", Boolean.TRUE);
546                     }
547                 }
548             }
549
550         }
551
552         /**
553          * @todo we should also be checking in sub container lists here for
554          * all containers and all fields that contain pages.
555          */

556
557     } // end composeWarningMessages
558

559     private Set JavaDoc contentObjectPointingOnPage (int pageID)
560             throws JahiaException {
561         ArrayList JavaDoc objectLinks = ObjectLink.findByTypeAndRightObjectKey (
562                 "hardcodedLink", new ContentPageKey (pageID));
563         Iterator JavaDoc objectLinkIter = objectLinks.iterator ();
564         Set JavaDoc objectKeysPointingToPage = new HashSet JavaDoc ();
565         while (objectLinkIter.hasNext ()) {
566             ObjectLink curLink = (ObjectLink) objectLinkIter.next ();
567             ObjectKey objectKey = curLink.getLeftObjectKey ();
568             try {
569                 ContentObject contentObject = (ContentObject) JahiaObject.
570                         getInstance (objectKey);
571                 if (contentObject != null) {
572                     if (!contentObject.getActiveAndStagingEntryStates ().isEmpty ()) {
573                         objectKeysPointingToPage.add (objectKey);
574                     } else {
575                         logger.debug (
576                                 "No active or staging entries found for objectKey=" +
577                                 objectKey +
578                                 ", not displaying deleted or archived references");
579                     }
580                 } else {
581                     logger.warn (
582                             "Hardcoded URL link found for object that no longer exists:" +
583                             objectKey + ", removing reference");
584                     curLink.remove ();
585                 }
586             } catch (ClassNotFoundException JavaDoc cnfe) {
587                 logger.error ("Error while loading Jahia object from objectKey=" +
588                         objectKey, cnfe);
589             }
590         }
591         return objectKeysPointingToPage;
592     }
593
594     private ArrayList JavaDoc buildHardcodedSourceInfo (Set JavaDoc objectKeys,
595                                                 ParamBean paramBean)
596             throws JahiaException {
597         ArrayList JavaDoc sourceObjectList = new ArrayList JavaDoc ();
598         Iterator JavaDoc objectKeyIter = objectKeys.iterator ();
599         ContentObjectEntryState entryState = new ContentObjectEntryState (
600                 ContentObjectEntryState.WORKFLOW_STATE_START_STAGING,
601                 0, paramBean.getLocale ().toString ());
602         while (objectKeyIter.hasNext ()) {
603             ObjectKey curObjectKey = (ObjectKey) objectKeyIter.next ();
604             HardcodedLinkSourceInfo curLinkInfo = new HardcodedLinkSourceInfo ();
605             curLinkInfo.setID (curObjectKey.getIDInType ());
606             curLinkInfo.setObjectType (curObjectKey.getType ());
607             try {
608                 JahiaObject jahiaObject = JahiaObject.getInstance (curObjectKey);
609                 if (jahiaObject instanceof ContentObject) {
610                     ContentObject curContentObject = (ContentObject)
611                             jahiaObject;
612                     ObjectKey definitionKey = curContentObject.getDefinitionKey (
613                             paramBean.getEntryLoadRequest ());
614                     ContentDefinition definition = ContentDefinition.
615                             getInstance (definitionKey);
616                     curLinkInfo.setName (definition.getName ());
617                     curLinkInfo.setTitle (definition.getTitle (curContentObject,
618                             entryState));
619                     if (curContentObject instanceof ContentField) {
620                         ContentField curContentField = (ContentField)
621                                 curContentObject;
622                         curLinkInfo.setObjectSubType (FieldTypes.typeName[
623                                 curContentField.getType ()]);
624                     }
625                 }
626                 if (jahiaObject instanceof PageReferenceableInterface) {
627                     PageReferenceableInterface pageObject = (
628                             PageReferenceableInterface) jahiaObject;
629                     curLinkInfo.setPageID (pageObject.getPageID ());
630                 }
631                 sourceObjectList.add (curLinkInfo);
632             } catch (ClassNotFoundException JavaDoc cnfe) {
633                 logger.error (
634                         "Error while loading content object, will not be added to hardcoded source objects",
635                         cnfe);
636             }
637         }
638         return sourceObjectList;
639     }
640
641 } // end DeleteContainer_Engine
642
Popular Tags