001package org.kuali.ole.ingest;
002
003import com.thoughtworks.xstream.XStream;
004import org.kuali.ole.ingest.pojo.*;
005
006import java.io.IOException;
007import java.net.URISyntaxException;
008
009/**
010 * ProfileObjectGeneratorFromXML used to build the Profile based on fileContent
011 */
012public class ProfileObjectGeneratorFromXML {
013    /**
014     * This method return Profile Object.
015     * This method build the Profile based on fileContent.
016     * @param fileContent
017     * @return  Profile
018     * @throws java.net.URISyntaxException
019     * @throws java.io.IOException
020     */
021    public Profile buildProfileFromFileContent(String fileContent) throws URISyntaxException, IOException {
022        XStream xStream = new XStream();
023        xStream.alias("profile", Profile.class);
024        xStream.alias("attribute", ProfileAttributeBo.class);
025        xStream.alias("rule", OleRule.class);
026        xStream.alias("action", OleAction.class);
027        xStream.alias("routeTo", OleRoute.class);
028        xStream.alias("incomingField", MatchPoint.class);
029        xStream.alias("existingField", MatchPoint.class);
030        xStream.registerConverter(new ProfileAttributeConverter());
031        Object object = xStream.fromXML(fileContent);
032        return (Profile) object;
033    }
034}