001    /**
002     * Copyright 2010-2013 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.maven.wagon;
017    
018    import org.kuali.common.aws.s3.S3Utils;
019    import org.kuali.common.threads.ElementHandler;
020    import org.kuali.common.threads.ListIteratorContext;
021    
022    import com.amazonaws.services.s3.AmazonS3Client;
023    import com.amazonaws.services.s3.model.PutObjectRequest;
024    import com.amazonaws.services.s3.transfer.TransferManager;
025    
026    public class FileHandler implements ElementHandler<PutFileContext> {
027    
028            public void handleElement(ListIteratorContext<PutFileContext> context, int index, PutFileContext element) {
029                    RequestFactory factory = element.getFactory();
030                    TransferManager manager = element.getTransferManager();
031                    AmazonS3Client client = element.getClient();
032                    PutObjectRequest request = factory.getPutObjectRequest(element);
033                    S3Utils.getInstance().upload(element.getSource(), request, client, manager);
034            }
035    
036    }