diff --git a/config/alfresco/slingshot-context.xml b/config/alfresco/slingshot-context.xml index ed1891b719..646b9c4a8c 100644 --- a/config/alfresco/slingshot-context.xml +++ b/config/alfresco/slingshot-context.xml @@ -11,7 +11,6 @@ classpath*:alfresco/extension/custom-vti.properties - 0 @@ -35,6 +34,8 @@ + + slingshotDocLib @@ -44,6 +45,9 @@ + + + diff --git a/source/java/org/alfresco/repo/jscript/app/GoogleDocsCustomResponse.java b/source/java/org/alfresco/repo/jscript/app/GoogleDocsCustomResponse.java new file mode 100644 index 0000000000..8162aef528 --- /dev/null +++ b/source/java/org/alfresco/repo/jscript/app/GoogleDocsCustomResponse.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2005-2011 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +package org.alfresco.repo.jscript.app; + +import org.alfresco.repo.googledocs.GoogleDocsService; +import org.alfresco.repo.management.subsystems.ApplicationContextFactory; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.context.ConfigurableApplicationContext; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * Return current status of Google Docs subsystem + * + * @author: mikeh + */ +public class GoogleDocsCustomResponse implements CustomResponse, ApplicationContextAware +{ + private static Log logger = LogFactory.getLog(GoogleDocsCustomResponse.class); + + private ApplicationContext applicationContext; + + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException + { + this.applicationContext = applicationContext; + } + + /** + * Populates the DocLib webscript response with custom metadata + * + * @return JSONObject or null + */ + public Serializable populate() + { + try + { + ApplicationContextFactory subsystem = (ApplicationContextFactory)applicationContext.getBean("googledocs"); + ConfigurableApplicationContext childContext = (ConfigurableApplicationContext)subsystem.getApplicationContext(); + GoogleDocsService googleDocsService = (GoogleDocsService)childContext.getBean("googleDocsService"); + + Map jsonObj = new LinkedHashMap(4); + jsonObj.put("enabled", googleDocsService.isEnabled()); + + return (Serializable)jsonObj; + } + catch (Exception e) + { + logger.warn("Could not add custom Google Docs status response to DocLib webscript"); + } + return null; + } +}