AnsweredAssumed Answered

insert calendar event from sdk

Question asked by general.richiter on Aug 13, 2009
Hi,

I use Alfresco sdk 3.1 and Alfresco Community 3.2.
I'm trying to insert calendar event from java code - I succeeded. When I'm logging to alfresco, in my site, I can see calendar event.
But when I'm logging to alfresco-share, I can't see any !!! After deleting inserted (from java) calendars, everything is right - I can see others events.

I use code:
      
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar c = Calendar.getInstance();
c.set(2009, 12, 12);
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:alfresco/application-context.xml");
Repository repository = (Repository)context.getBean("JCR.Repository");
Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
Node rootNode = session.getRootNode();
Node companyHome = rootNode.getNode("app:company_home");
Node siteNode = companyHome.getNode("st:sites");
Node mySite = siteNode.getNode("cm:mojaStrona");
Node calendarNode = mySite.getNode("cm:calendar");            
Node content = calendarNode.addNode("cm:" + “aa” + System.currentTimeMillis(), "ia:calendarEvent");
content.setProperty("cm:name", “aa” + System.currentTimeMillis());     
content.setProperty("cm:title", “title”);
content.setProperty("cm:description", “description”);
content.setProperty("ia:whatEvent", “whatEvent”);
content.setProperty("ia:fromDate", myCalendar);
content.setProperty("ia:whereEvent", “whereEvent”);
content.setProperty("cm:modifier","admin" );
content.setProperty("cm:modified", "admin" );
content.setProperty("cm:creator","admin");
content.setProperty("ia:toDate", myCalendar);
setMimeType(context, content, MimetypeMap.MIMETYPE_TEXT_PLAIN);
session.logout();
System.exit(0);

When I use alfresco-share, in /opt/Alfresco/alfresco.log I have exception:

16:40:32,797 ERROR [org.alfresco.web.scripts.AbstractRuntime] Exception from executeScript - redirecting to status template error: 07130005 Wrapped Exception (with status template): 07130004 Failed to execute script '/org/alfresco/slingshot/calendar/userevents.get.js (in classpath store file:/opt/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts)': 07130003 TypeError: Cannot call method "getHours" of null (file:/opt/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/userevents.get.js#95)
org.alfresco.web.scripts.WebScriptException: 07130005 Wrapped Exception (with status template): 07130004 Failed to execute script '/org/alfresco/slingshot/calendar/userevents.get.js (in classpath store file:/opt/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts)': 07130003 TypeError: Cannot call method "getHours" of null (file:/opt/Alfresco/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/slingshot/calendar/userevents.get.js#95)
at org.alfresco.web.scripts.AbstractWebScript.createStatusException(AbstractWebScript.java:613)
at org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:165)
at org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:357)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:326)

Outcomes