1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.exoplatform.services.wcm.core.impl;
19
20 import javax.jcr.Node;
21
22 import org.apache.commons.chain.Context;
23 import org.exoplatform.services.command.action.Action;
24 import org.exoplatform.services.jcr.ext.common.SessionProvider;
25 import org.exoplatform.services.log.ExoLogger;
26 import org.exoplatform.services.log.Log;
27 import org.exoplatform.services.wcm.core.WebSchemaConfigService;
28 import org.exoplatform.services.wcm.utils.WCMCoreUtils;
29
30
31
32
33
34
35
36 public class WebSchemaCreationAction implements Action {
37 private static final Log LOG = ExoLogger.getLogger(WebSchemaCreationAction.class.getName());
38
39 public boolean execute(Context context) throws Exception {
40 Node node = (Node)context.get("currentItem");
41 WebSchemaConfigService schemaConfigService = WCMCoreUtils.getService(WebSchemaConfigService.class);
42 SessionProvider sessionProvider = WCMCoreUtils.getSystemSessionProvider();
43 try {
44 schemaConfigService.createSchema(sessionProvider, node);
45 } catch (Exception e) {
46 if (LOG.isErrorEnabled()) {
47 LOG.error("Error when creat web schema for node"+node.getPath() , e);
48 }
49 }
50 return false;
51 }
52
53 }