001/**
002 * Copyright 2011-2013 The Kuali Foundation Licensed under the
003 * Educational Community License, Version 2.0 (the "License"); you may
004 * not use this file except in compliance with the License. You may
005 * obtain a copy of the License at
006 *
007 * http://www.osedu.org/licenses/ECL-2.0
008 *
009 * Unless required by applicable law or agreed to in writing,
010 * software distributed under the License is distributed on an "AS IS"
011 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
012 * or implied. See the License for the specific language governing
013 * permissions and limitations under the License.
014 */
015package org.kuali.mobility.academics.service;
016
017import org.apache.cxf.annotations.Policies;
018import org.apache.cxf.annotations.Policy;
019import org.apache.cxf.jaxrs.ext.MessageContext;
020import org.apache.log4j.Logger;
021import org.kuali.mobility.academics.dao.GradesPostedNoticeDao;
022import org.springframework.context.ApplicationContext;
023import org.springframework.context.ApplicationContextAware;
024
025import javax.jws.WebMethod;
026import javax.jws.WebParam;
027import javax.jws.soap.SOAPBinding;
028import javax.ws.rs.core.Context;
029import java.util.List;
030
031/**
032 *
033 * @author Kuali Mobility Team (mobility.dev@kuali.org)
034 * @since 2.3.0
035 */
036
037public class GradeAlertServiceImpl implements GradeAlertService, ApplicationContextAware {
038    private static final Logger LOG = Logger.getLogger(GradeAlertServiceImpl.class);
039    private ApplicationContext context;
040    @Context
041    private MessageContext messageContext;
042    private GradesPostedNoticeDao dao;
043
044
045    @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
046    @WebMethod( operationName="publishGradeAlerts", action="publishGradeAlerts")
047    @Policies(
048            @Policy(uri="#UsernamePasswordPolicy",
049                    placement = Policy.Placement.BINDING_OPERATION_INPUT)
050    )
051    //@GET
052    //@Path("/")
053    @Override
054    public String publishGradeAlerts(@WebParam(name="uniqname") final List<String> uniqnameList) {
055        String response;
056        if (null!=uniqnameList && !uniqnameList.isEmpty()) {
057            response = "ok";
058            LOG.debug("Graded:" + uniqnameList.size());
059            for (String s: uniqnameList) {
060                LOG.debug(s);
061
062            }
063
064            dao.uploadGradesPostedNotice(uniqnameList);
065        }
066        else {
067            response = "error";
068        }
069        
070        return response;
071    }
072
073    /**
074     * @return the context
075     */
076    public ApplicationContext getApplicationContext() {
077            return context;
078    }
079
080    /**
081     * @param context the context to set
082     */
083    @Override
084    public void setApplicationContext(ApplicationContext context) {
085            this.context = context;
086    }
087
088    /**
089     * @return the messageContext
090     */
091    public MessageContext getMessageContext() {
092        return messageContext;
093    }
094
095    /**
096     * @param messageContext the messageContext to set
097     */
098    public void setMessageContext(MessageContext messageContext) {
099        this.messageContext = messageContext;
100    }
101
102    public GradesPostedNoticeDao getDao() {
103        return dao;
104    }
105
106    public void setDao(GradesPostedNoticeDao dao) {
107        this.dao = dao;
108    }
109}