Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -rbb9853953ff8cc6e70017a866d94fc2cfcb2cc35 -r5519ec0c3c96eabe88a9a5f9b98f6d86e5c2ffa9 Binary files differ Index: lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java =================================================================== diff -u -r34b959260a0f8f8285793a4481a95ca3580eabc5 -r5519ec0c3c96eabe88a9a5f9b98f6d86e5c2ffa9 --- lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java (.../LamsCoreToolService.java) (revision 34b959260a0f8f8285793a4481a95ca3580eabc5) +++ lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java (.../LamsCoreToolService.java) (revision 5519ec0c3c96eabe88a9a5f9b98f6d86e5c2ffa9) @@ -32,7 +32,6 @@ import org.lamsfoundation.lams.learningdesign.Activity; import org.lamsfoundation.lams.learningdesign.ToolActivity; import org.lamsfoundation.lams.lesson.Lesson; -import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.ToolContentIDGenerator; import org.lamsfoundation.lams.tool.ToolContentManager; import org.lamsfoundation.lams.tool.ToolSession; @@ -45,6 +44,7 @@ import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.util.AttributeNames; import org.springframework.beans.BeansException; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; @@ -176,15 +176,17 @@ */ public void notifyToolsToCreateSession(ToolSession toolSession, ToolActivity activity) throws ToolException { - // TODO remove call to isToolOnClasspath. Should throw an error if tool cannot be found. - if ( isToolOnClasspath(activity) ) { + try { ToolSessionManager sessionManager = (ToolSessionManager) findToolService(activity); sessionManager.createToolSession(toolSession.getToolSessionId(),toolSession.getToolSessionName(), activity.getToolContentId()); + } catch ( NoSuchBeanDefinitionException e ) { + String message = "A tool which is defined in the database appears to missing from the classpath. Unable to create tool session. ToolActivity "+activity; + log.error(message,e); + throw new ToolException(message,e); } } - /** * Calls the tool to copy the content for an activity. Used when copying a learning design. * @@ -196,11 +198,7 @@ throws DataMissingException, ToolException { Long newToolcontentID = contentIDGenerator.getNextToolContentIDFor(toolActivity.getTool()); - //This is just for testing purpose because only some tools are in the learning - // classpath - //TODO we need to remove this once all done. - if (isToolOnClasspath(toolActivity)) - { + try { ToolContentManager contentManager = (ToolContentManager) findToolService(toolActivity); contentManager.copyToolContent(toolActivity.getToolContentId(), newToolcontentID); @@ -212,7 +210,12 @@ toolActivity.getRunOffline().booleanValue() ) { contentManager.setAsRunOffline(newToolcontentID); } - } + } catch ( NoSuchBeanDefinitionException e ) { + String message = "A tool which is defined in the database appears to missing from the classpath. Unable to copy the tool content. ToolActivity "+toolActivity; + log.error(message,e); + throw new ToolException(message,e); + } + return newToolcontentID; } @@ -225,12 +228,14 @@ */ public void notifyToolToDeleteContent(ToolActivity toolActivity) throws ToolException { - //TODO we need to the classpath check once all tools done. - if (isToolOnClasspath(toolActivity)) - { + try { ToolContentManager contentManager = (ToolContentManager) findToolService(toolActivity); contentManager.removeToolContent(toolActivity.getToolContentId(),true); - } + } catch ( NoSuchBeanDefinitionException e ) { + String message = "A tool which is defined in the database appears to missing from the classpath. Unable to delete the tool content. ToolActivity "+toolActivity; + log.error(message,e); + throw new ToolException(message,e); + } } /** * @see org.lamsfoundation.lams.tool.service.ILamsCoreToolService#updateToolSession(org.lamsfoundation.lams.tool.ToolSession) @@ -359,28 +364,11 @@ * find different service such as EJB or Web service. * @param toolActivity the tool activity defined in the design. * @return the service object from tool. + * @throws NoSuchBeanDefinitionException if the tool is not the classpath or the supplied service name is wrong. */ - private Object findToolService(ToolActivity toolActivity) + private Object findToolService(ToolActivity toolActivity) throws NoSuchBeanDefinitionException { return context.getBean(toolActivity.getTool().getServiceName()); } - /** - * Is this one of the tools that is currently in the learning classpath. - * TODO remove when all tools in the test cases are implemented. - * @param toolActivity the tool activity defined in the design. - * @return - */ - private boolean isToolOnClasspath(ToolActivity toolActivity) - { - String serviceName = toolActivity.getTool().getServiceName(); - if ( serviceName == null ) - return false; - - return serviceName.equals("ImscpService") || serviceName.equals("nbService") - || serviceName.equals("qaService") || serviceName.equals("mcService") || - serviceName.equals("submitFilesService") || serviceName.equals("surveyService") - || serviceName.equals("forumService") || serviceName.equals("chatService") - || serviceName.equals("resourceService"); - } }