Package com.nineteendrops.tracdrops.client.core

Examples of com.nineteendrops.tracdrops.client.core.TracException


    private Log log = LogFactory.getLog(AttachmentToPutAttachmentEncoder.class);

    public Object encode(TracProperties tracProperties, Object parameter) {

        if(parameter == null){
            throw new TracException(MessageUtils.getMessage("core.parameter.not.found", "TicketAttachment", this.getClass().getName()));
        }

        WikiAttachment wikiAttachment = (WikiAttachment)parameter;

        // check for mandatory fields
        String pageName = wikiAttachment.getPageName();
        if(pageName == null || pageName.trim().equals("")){
            throw new TracException(MessageUtils.getMessage("core.parameter.not.found", "TicketAttachment.pageName", this.getClass().getName()));
        }

        String fileName = wikiAttachment.getFileName();
        if(fileName == null || fileName.trim().equals("")){
            throw new TracException(MessageUtils.getMessage("core.parameter.not.found", "TicketAttachment.fileName", this.getClass().getName()));
        }

        String description = wikiAttachment.getDescription();
        if(description == null) description = "";

        String fullFileName = wikiAttachment.getFullFileName();
        if(fullFileName == null || fullFileName.trim().equals("")){
            throw new TracException(MessageUtils.getMessage("core.parameter.not.found", "TicketAttachment.fullFileName", this.getClass().getName()));        }

        byte[] binaryData = Utils.getBinaryData(fullFileName, tracProperties);

        String pathToAttachment = pageName + "/" + fileName;
View Full Code Here


public class VersionToCreateUpdateFormatEncoder implements ParameterEncoder {

    public Object encode(TracProperties tracProperties, Object parameter) {

        if(parameter == null){
            throw new TracException(MessageUtils.getMessage("core.parameter.not.found", "Version", this.getClass().getName()));
        }

        Version version = (Version)parameter;

        // check for mandatory fields
        String name = version.getName();
        if(name == null || name.trim().equals("")){
            throw new TracException(MessageUtils.getMessage("core.parameter.not.found", "Version.name", this.getClass().getName()));
        }

        Date time = version.getTime();
        if(time == null){
            throw new TracException(MessageUtils.getMessage("core.parameter.not.found", "Version.time", this.getClass().getName()));
        }

        String description = version.getDescription();
        if(description == null){
            description = "";
View Full Code Here

    public TicketQueryFilter(String field, String operator, String value) {

        // Basic checks
        if(field == null){
            throw new TracException(MessageUtils.getMessage("api.ticket.ticket.query.wrong.field", field));
        }

        if(operator == null){
            throw new TracException(MessageUtils.getMessage("api.ticket.ticket.query.wrong.operator", operator));
        }

        if(value == null){
            throw new TracException(MessageUtils.getMessage("api.ticket.ticket.query.wrong.value", value));
        }

        this.field = field.trim();
        this.operator = operator.trim();
        this.value = value.trim();

        // Complementary checks
        if(!TicketKeys.FIELDS_ARRAY.contains(field)){
            throw new TracException(MessageUtils.getMessage("api.ticket.ticket.query.wrong.field", field));
        }

        if(!TicketKeys.OPERATORS_ARRAY.contains(operator)){
            throw new TracException(MessageUtils.getMessage("api.ticket.ticket.query.wrong.operator", operator));
        }
    }
View Full Code Here

public class TicketToUpdateFormatEncoder implements ParameterEncoder{

    public Object encode(TracProperties tracProperties, Object parameter) {

        if(parameter == null){
            throw new TracException(MessageUtils.getMessage("core.parameter.not.found", "Ticket", this.getClass().getName()));
        }

        Ticket ticket = (Ticket)parameter;

        // check for mandatory fields
        Integer idTicket = ticket.getIdTicket();
        if(idTicket == 0){
            throw new TracException(MessageUtils.getMessage("core.parameter.not.found", "Ticket.idTicket", this.getClass().getName()));
        }

        String comment = ticket.getComment();
        if(comment == null || comment.trim().equals("")){
            throw new TracException(MessageUtils.getMessage("core.parameter.not.found", "Ticket.comment", this.getClass().getName()));
        }


        MultiParameter multiParameter = new MultiParameter();
        multiParameter.addParameter(idTicket);
View Full Code Here

            if(value != null && !value.trim().equals("")){
                attachmentUploadMaxSize = convertNumber(value);
            }
            setProperty(ATTACHMENT_UPLOAD_MAX_SIZE, attachmentUploadMaxSize);
        } catch (Exception e) {
            throw new TracException(MessageUtils.getMessage("core.trac.config.wrong.property.value", ATTACHMENT_UPLOAD_MAX_SIZE, value), e);
        }

        try {
            value = properties.getProperty(ATTACHMENT_DOWNLOAD_PATH_BASE);
            if(value == null || value.trim().equals("")){
                value = ATTACHMENT_DOWNLOAD_PATH_BASE_DEFAULT;
            }
            setProperty(ATTACHMENT_DOWNLOAD_PATH_BASE, convertPath(value));
        } catch (Exception e) {
            throw new TracException(MessageUtils.getMessage("core.trac.config.wrong.property.value", ATTACHMENT_DOWNLOAD_PATH_BASE, value), e);
        }

        try {
            value = properties.getProperty(TRAC_INVOCATION_METHOD_FAILURE_PATTERN);
            if(value == null || value.trim().equals("")){
                value = TRAC_INVOCATION_METHOD_FAILURE_PATTERN_DEFAULT;
            }
            setProperty(TRAC_INVOCATION_METHOD_FAILURE_PATTERN, normalizeString(value));
        } catch (Exception e) {
            throw new TracException(MessageUtils.getMessage("core.trac.config.wrong.property.value", TRAC_INVOCATION_METHOD_FAILURE_PATTERN, value), e);
        }

    }
View Full Code Here

            InputStream is =  this.getClass().getClassLoader().getResourceAsStream("TRACdropsConfig.properties");
            propertiesFromFile.load(is);

        } catch (IOException e) {
            throw new TracException(MessageUtils.getMessage("core.trac.config.file.not.found"), e);
        }

        tracConfigProperties.populate(propertiesFromFile);

        return tracConfigProperties;
View Full Code Here

            pathBase = tracProperties.getStringProperty(TracProperties.ATTACHMENT_DOWNLOAD_PATH_BASE);
        }


        if(fileName == null || fileName.trim().equals("")){
            throw new TracException(MessageUtils.getMessage("core.parameter.not.found", "filename", this.getClass().getName()));
        }
       
        // remove from filename any "/"
        fileName = fileName.replace("/", "_");


        if(pathBase == null || pathBase.trim().equals("")){
            throw new TracException(MessageUtils.getMessage("core.parameter.not.found", "pathBase", this.getClass().getName()));
        }

        pathBase = pathBase.trim();
        if(!pathBase.endsWith("/")){
            pathBase = pathBase + "/";
        }

        String fullFileName = pathBase + fileName.trim();
        File file = new File(fullFileName);
        if(file.exists()){
            fullFileName = fullFileName + "_" + new Date().getTime();
            file = new File(fullFileName);
        }
       
        if(!new File(pathBase).canWrite()){
            throw new TracException(MessageUtils.getMessage("core.unable.to.write.to.file", pathBase));
        }

        try {
            byte[] fileFromTrac = (byte[])result;
            FileOutputStream fos = new FileOutputStream(file);
View Full Code Here

    }

    public void connect() {

        if(tracConnectionConfig == null){
            throw new TracException(MessageUtils.getMessage("core.connection.configuration.not.initialized"));
        }

        String url = tracConnectionConfig.getUrl();
        String user = tracConnectionConfig.getUser();
        String password = tracConnectionConfig.getPassword();

        if(url == null
            || user == null
            || password == null
            || url.trim().equals("")
            || user.trim().equals("")
            || password.trim().equals("")){
            throw new IllegalArgumentException(MessageUtils.getMessage("core.connection.configuration.parameters.not.initialized"));
        }

        XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
        config.setBasicUserName(user.trim());
        config.setBasicPassword(password.trim());

        config.setEnabledForExceptions(true);

        try {

            config.setServerURL(new URL(url.trim()));

        } catch (MalformedURLException e) {
            throw new TracException(MessageUtils.getMessage("core.connection.configuration.malformed.url", url), e);
        }

        XmlRpcClient xmlRpcClient = new XmlRpcClient();
        xmlRpcClient.setConfig(config);
        if(tracConnectionConfig.getXmlRpcTransportFactory() != null){
View Full Code Here

TOP

Related Classes of com.nineteendrops.tracdrops.client.core.TracException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.