Example usage for java.lang NumberFormatException getMessage

List of usage examples for java.lang NumberFormatException getMessage

Introduction

In this page you can find the example usage for java.lang NumberFormatException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.impetus.client.cassandra.pelops.PelopsDataHandler.java

private CounterSuperColumn buildThriftCounterSuperColumn(String superColumnName, EmbeddedColumn superColumn,
        Object counterSuperColumnObject) {

    List<CounterColumn> thriftColumns = new ArrayList<CounterColumn>();
    for (com.impetus.kundera.metadata.model.Column column : superColumn.getColumns()) {
        Field field = column.getField();
        String name = column.getName();
        String value = null;/*  ww  w . ja va 2  s .  c o m*/
        try {
            value = PropertyAccessorHelper.getString(counterSuperColumnObject, field);

        } catch (PropertyAccessException exp) {
            // This is an entity column to be persisted in a super column
            // family. It will be stored as a super column that would
            // have just one column with the same name
            log.info(exp.getMessage()
                    + ". Possible case of entity column in a super column family. Will be treated as a super column.");
            value = counterSuperColumnObject.toString();
        }
        if (null != value) {
            try {
                CounterColumn thriftColumn = new CounterColumn();
                thriftColumn.setName(PropertyAccessorFactory.STRING.toBytes(name));
                thriftColumn.setValue(Long.parseLong(value));
                thriftColumns.add(thriftColumn);
            } catch (NumberFormatException nfe) {
                log.error("For counter column arguments should be numeric type, error caused by :"
                        + nfe.getMessage());
                throw new KunderaException("For counter column,arguments should be numeric type", nfe);
            }
        }
    }
    CounterSuperColumn thriftSuperColumn = new CounterSuperColumn();
    thriftSuperColumn.setName(PropertyAccessorFactory.STRING.toBytes(superColumnName));
    thriftSuperColumn.setColumns(thriftColumns);

    return thriftSuperColumn;

}

From source file:com.cloud.consoleproxy.ConsoleProxyManagerImpl.java

public void handleAgentDisconnect(long agentId, com.cloud.host.Status state) {
    if (state == com.cloud.host.Status.Alert || state == com.cloud.host.Status.Disconnected) {
        // be it either in alert or in disconnected state, the agent process
        // may be gone in the VM,
        // we will be reacting to stop the corresponding VM and let the scan
        // process to
        HostVO host = _hostDao.findById(agentId);
        if (host.getType() == Type.ConsoleProxy) {
            String name = host.getName();
            if (s_logger.isInfoEnabled()) {
                s_logger.info("Console proxy agent disconnected, proxy: " + name);
            }/*from   ww  w.java 2s .c o m*/
            if (name != null && name.startsWith("v-")) {
                String[] tokens = name.split("-");
                long proxyVmId = 0;
                try {
                    proxyVmId = Long.parseLong(tokens[1]);
                } catch (NumberFormatException e) {
                    s_logger.error("Unexpected exception " + e.getMessage(), e);
                    return;
                }

                final ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
                if (proxy != null) {

                    // Disable this feature for now, as it conflicts with
                    // the case of allowing user to reboot console proxy
                    // when rebooting happens, we will receive disconnect
                    // here and we can't enter into stopping process,
                    // as when the rebooted one comes up, it will kick off a
                    // newly started one and trigger the process
                    // continue on forever

                    /*
                     * _capacityScanScheduler.execute(new Runnable() { public void run() {
                     * if(s_logger.isInfoEnabled())
                     * s_logger.info("Stop console proxy " + proxy.getName() +
                     * " VM because of that the agent running inside it has disconnected" );
                     * stopProxy(proxy.getId()); } });
                     */
                } else {
                    if (s_logger.isInfoEnabled()) {
                        s_logger.info(
                                "Console proxy agent disconnected but corresponding console proxy VM no longer exists in DB, proxy: "
                                        + name);
                    }
                }
            } else {
                assert (false) : "Invalid console proxy name: " + name;
            }
        }
    }
}

From source file:org.schemaspy.Config.java

public int getMaxDetailedTables() {
    if (maxDetailedTables == null) {
        int max = 300; // default
        String param = pullParam("-maxdet");
        if (param != null) {
            try {
                max = Integer.parseInt(param);
            } catch (NumberFormatException e) {
                logger.log(Level.WARNING, e.getMessage(), e);
            }/*  ww w .  ja va 2 s. co  m*/
        }
        maxDetailedTables = new Integer(max);
    }

    return maxDetailedTables.intValue();
}

From source file:org.schemaspy.Config.java

/**
 * @return/*  w  w w.j av a2 s  .c om*/
 * @see #setFontSize(int)
 */
public int getFontSize() {
    if (fontSize == null) {
        int size = 11; // default
        String param = pullParam("-fontsize");
        if (param != null) {
            try {
                size = Integer.parseInt(param);
            } catch (NumberFormatException e) {
                logger.log(Level.WARNING, e.getMessage(), e);
            }
        }
        fontSize = Integer.valueOf(size);
    }

    return fontSize.intValue();
}

From source file:com.ephesoft.dcma.fuzzydb.FuzzyLuceneEngine.java

/**
 * This method updates the value of document level fields for each document by searching for similarities in input search text with
 * the data in database tables mapped for each document type.
 * /*  w ww.  j  a v a2 s. c  o  m*/
 * @param batchInstanceIdentifier {@link String}
 * @param documentType {@link String}
 * @param searchText {@link String}
 * @throws DCMAApplicationException for handling any exception.
 * @return {@link List<List<String>>}
 */
public List<List<String>> fuzzyTextSearch(final String batchInstanceIdentifier, final String documentType,
        final String searchText) throws DCMAApplicationException {
    LOGGER.info("Initializing properties...");
    String searchTextInLowerCase = searchText.toLowerCase(Locale.getDefault());
    List<List<String>> extractedData = null;
    String numOfPages = pluginPropertiesService.getPropertyValue(batchInstanceIdentifier,
            FuzzyDBSearchConstants.FUZZYDB_PLUGIN, FuzzyDBProperties.FUZZYDB_NO_OF_PAGES);
    String dbDriver = pluginPropertiesService.getPropertyValue(batchInstanceIdentifier,
            FuzzyDBSearchConstants.FUZZYDB_PLUGIN, FuzzyDBProperties.FUZZYDB_DB_DRIVER);
    String dbConnectionURL = pluginPropertiesService.getPropertyValue(batchInstanceIdentifier,
            FuzzyDBSearchConstants.FUZZYDB_PLUGIN, FuzzyDBProperties.FUZZYDB_CONNECTION_URL);
    String dbUserName = pluginPropertiesService.getPropertyValue(batchInstanceIdentifier,
            FuzzyDBSearchConstants.FUZZYDB_PLUGIN, FuzzyDBProperties.FUZZYDB_DB_USER_NAME);
    String thresholdValue = pluginPropertiesService.getPropertyValue(batchInstanceIdentifier,
            FuzzyDBSearchConstants.FUZZYDB_PLUGIN, FuzzyDBProperties.FUZZYDB_THRESHOLD_VALUE);
    String dbPassword = pluginPropertiesService.getPropertyValue(batchInstanceIdentifier,
            FuzzyDBSearchConstants.FUZZYDB_PLUGIN, FuzzyDBProperties.FUZZYDB_DB_PASSWORD);
    String dbName = FuzzyDBSearchConstants.EMPTY_STRING;
    if (dbConnectionURL != null && dbConnectionURL.length() > 0) {
        dbName = getDatabaseName(dbConnectionURL, dbDriver);
    }
    String queryDelimiters = pluginPropertiesService.getPropertyValue(batchInstanceIdentifier,
            FuzzyDBSearchConstants.FUZZYDB_PLUGIN, FuzzyDBProperties.FUZZYDB_QUERY_DELIMITERS);
    LOGGER.info("Properties Initialized Successfully");
    Batch batch = batchSchemaService.getBatch(batchInstanceIdentifier);
    String batchClassIdentifier = batch.getBatchClassIdentifier();
    String indexFolder = batchSchemaService.getFuzzyDBIndexFolder(batchClassIdentifier, false);

    if (dbName.length() <= 0) {
        LOGGER.info(FuzzyDBSearchConstants.WRONG_DB_NAME_MESSAGE);
        return extractedData;
    }

    File baseFuzzyDbIndexFolder = new File(indexFolder);
    if (baseFuzzyDbIndexFolder != null && !baseFuzzyDbIndexFolder.exists()) {
        LOGGER.info(FuzzyDBSearchConstants.FUZZY_DB_INDEX_FOLDER_DOES_NOT_EXIST_MESSAGE);
        return extractedData;
    }

    Map<String, Float> returnMap = new HashMap<String, Float>();
    Set<FuzzyDBResultInfo> resultSet = new TreeSet<FuzzyDBResultInfo>();

    List<com.ephesoft.dcma.da.domain.PageType> allPageTypes = pluginPropertiesService
            .getPageTypes(batchInstanceIdentifier);
    if (!(allPageTypes != null && !allPageTypes.isEmpty())) {
        LOGGER.info("Page Types not configured in Database");
        return extractedData;
    }

    BatchDynamicPluginConfiguration[] pluginPropsDocType = pluginPropertiesService.getDynamicPluginProperties(
            batchInstanceIdentifier, FuzzyDBSearchConstants.FUZZYDB_PLUGIN,
            FuzzyDBProperties.FUZZYDB_DOCUMENT_TYPE);
    if (pluginPropsDocType != null && pluginPropsDocType.length > 0) {
        for (BatchDynamicPluginConfiguration eachConfig : pluginPropsDocType) {
            if (eachConfig.getDescription().equals(documentType)) {
                String tableName = eachConfig.getValue();
                String fuzzyIndexFolder = indexFolder + File.separator + dbName + File.separator + tableName;
                File indexFolderDirectory = new File(fuzzyIndexFolder);
                if (indexFolderDirectory != null && indexFolderDirectory.exists()) {
                    String[] indexFiles = indexFolderDirectory.list();
                    if (indexFiles == null || indexFiles.length <= 0) {
                        LOGGER.info("No index files exist inside folder : " + indexFolderDirectory);
                        continue;
                    }
                } else {
                    LOGGER.info("No index created for : " + eachConfig.getDescription());
                    continue;
                }
                StringTokenizer tokens = new StringTokenizer(searchTextInLowerCase, queryDelimiters);

                StringBuffer query = createQueryForTextSearch(tokens);
                if (query != null && query.toString() != null && query.toString().length() > 0) {
                    LOGGER.info(FuzzyDBSearchConstants.GENERATING_CONFIDENCE_MESSAGE + searchTextInLowerCase);
                    try {
                        returnMap = SearchFiles.generateConfidence(fuzzyIndexFolder, query.toString(),
                                FuzzyDBSearchConstants.INDEX_FIELD, Integer.valueOf(numOfPages),
                                this.ignoreWordList);
                        for (String key : returnMap.keySet()) {
                            FuzzyDBResultInfo fuzzyDBResultInfo = new FuzzyDBResultInfo(returnMap.get(key),
                                    key);
                            resultSet.add(fuzzyDBResultInfo);
                        }
                    } catch (NumberFormatException e) {
                        LOGGER.error(FuzzyDBSearchConstants.CONFIDENCE_ERROR_MSG + searchTextInLowerCase, e);
                        continue;
                    } catch (Exception e) {
                        LOGGER.error(FuzzyDBSearchConstants.CONFIDENCE_ERROR_MSG + searchTextInLowerCase, e);
                        continue;
                    }
                    LOGGER.info(FuzzyDBSearchConstants.RETURN_MAP_MESSAGE + returnMap);
                    if (resultSet != null && resultSet.size() > 0) {
                        if (extractedData == null) {
                            extractedData = new ArrayList<List<String>>();
                        }
                        boolean isHeaderAdded = true;
                        Set<FuzzyDBResultInfo> set = fetchDocumentHavingThresholdValue(resultSet,
                                thresholdValue);
                        for (FuzzyDBResultInfo fuzzyDBResultInfo : set) {
                            Float confidenceScore = fuzzyDBResultInfo.getConfidence();
                            long keyLong = 0;
                            try {
                                keyLong = Long.parseLong(fuzzyDBResultInfo.getRowId());
                            } catch (NumberFormatException nfe) {
                                LOGGER.error(nfe.getMessage(), nfe);
                                return null;
                            }
                            extractedData.addAll(fetchFuzzySearchResult(keyLong, confidenceScore.toString(),
                                    tableName, dbConnectionURL, dbName, dbDriver, dbUserName, dbPassword,
                                    eachConfig, isHeaderAdded));
                            isHeaderAdded = false;
                            LOGGER.info(FuzzyDBSearchConstants.EXTRACTED_DATA_MESSAGE + extractedData);
                        }
                    } else {
                        LOGGER.info("No record found ");
                    }
                } else {
                    LOGGER.info(FuzzyDBSearchConstants.EMPTY_QUERY_MESSAGE + searchTextInLowerCase);
                }
            }
        }
    } else {
        LOGGER.info("No properties configured for FUZZYDB_DOCUMENT_TYPE");
    }
    if (extractedData != null && extractedData.isEmpty()) {
        return null;
    }
    return extractedData;
}

From source file:fr.paris.lutece.plugins.mylutece.modules.database.authentication.service.ImportDatabaseUserService.java

/**
 * {@inheritDoc}//  w w w  .j av a2  s. c  om
 */
@Override
protected List<CSVMessageDescriptor> readLineOfCSVFile(String[] strLineDataArray, int nLineNumber,
        Locale locale, String strBaseUrl) {
    Plugin databasePlugin = PluginService.getPlugin(DatabasePlugin.PLUGIN_NAME);
    Plugin mylutecePlugin = PluginService.getPlugin(MyLutecePlugin.PLUGIN_NAME);
    List<CSVMessageDescriptor> listMessages = new ArrayList<CSVMessageDescriptor>();
    int nIndex = 0;

    String strAccessCode = strLineDataArray[nIndex++];
    String strLastName = strLineDataArray[nIndex++];
    String strFirstName = strLineDataArray[nIndex++];
    String strEmail = strLineDataArray[nIndex++];

    boolean bUpdateUser = getUpdateExistingUsers();
    int nUserId = 0;

    if (bUpdateUser) {
        int nAccessCodeUserId = DatabaseUserHome.findDatabaseUserIdFromLogin(strAccessCode, databasePlugin);

        if (nAccessCodeUserId > 0) {
            nUserId = nAccessCodeUserId;
        }

        bUpdateUser = nUserId > 0;
    }

    String strStatus = strLineDataArray[nIndex++];
    int nStatus = 0;

    if (StringUtils.isNotEmpty(strStatus) && StringUtils.isNumeric(strStatus)) {
        nStatus = Integer.parseInt(strStatus);
    } else {
        Object[] args = { strLastName, strFirstName, nStatus };
        String strMessage = I18nService.getLocalizedString(MESSAGE_NO_STATUS, args, locale);
        CSVMessageDescriptor message = new CSVMessageDescriptor(CSVMessageLevel.INFO, nLineNumber, strMessage);
        listMessages.add(message);
    }

    // We ignore the password max valid date attribute because we changed the password.
    // String strPasswordMaxValidDate = strLineDataArray[nIndex++];
    nIndex++;
    // We ignore the account max valid date attribute
    // String strAccountMaxValidDate = strLineDataArray[nIndex++];
    nIndex++;

    DatabaseUser user = new DatabaseUser();

    user.setLogin(strAccessCode);
    user.setLastName(strLastName);
    user.setFirstName(strFirstName);
    user.setEmail(strEmail);
    user.setStatus(nStatus);

    if (bUpdateUser) {
        user.setUserId(nUserId);
        // We update the user
        DatabaseService.getService().doUpdateUser(user, databasePlugin);
    } else {
        // We create the user
        String strPassword = SecurityUtils.makePassword(_userParamService, databasePlugin);
        DatabaseService.getService().doCreateUser(user, strPassword, databasePlugin);
        notifyUserAccountCreated(user, strPassword, locale, AppPathService.getProdUrl(strBaseUrl));
    }

    // We remove old roles, groups and attributes of the user
    DatabaseHome.removeRolesForUser(user.getUserId(), databasePlugin);
    DatabaseHome.removeGroupsForUser(user.getUserId(), databasePlugin);
    MyLuteceUserFieldService.doRemoveUserFields(user.getUserId(), locale);

    // We get every attributes, roles and groups of the user
    Map<Integer, List<String>> mapAttributesValues = new HashMap<Integer, List<String>>();
    List<String> listRoles = new ArrayList<String>();
    List<String> listGroups = new ArrayList<String>();

    while (nIndex < strLineDataArray.length) {
        String strValue = strLineDataArray[nIndex];

        if (StringUtils.isNotBlank(strValue) && (strValue.indexOf(getAttributesSeparator()) > 0)) {
            int nSeparatorIndex = strValue.indexOf(getAttributesSeparator());
            String strLineId = strValue.substring(0, nSeparatorIndex);

            if (StringUtils.isNotBlank(strLineId)) {
                if (StringUtils.equalsIgnoreCase(strLineId, CONSTANT_ROLE)) {
                    listRoles.add(strValue.substring(nSeparatorIndex + 1));
                } else if (StringUtils.equalsIgnoreCase(strLineId, CONSTANT_GROUP)) {
                    listGroups.add(strValue.substring(nSeparatorIndex + 1));
                } else {
                    int nAttributeId = Integer.parseInt(strLineId);

                    String strAttributeValue = strValue.substring(nSeparatorIndex + 1);
                    List<String> listValues = mapAttributesValues.get(nAttributeId);

                    if (listValues == null) {
                        listValues = new ArrayList<String>();
                    }

                    listValues.add(strAttributeValue);
                    mapAttributesValues.put(nAttributeId, listValues);
                }
            }
        }

        nIndex++;
    }

    // We create roles
    for (String strRole : listRoles) {
        DatabaseHome.addRoleForUser(user.getUserId(), strRole, databasePlugin);
    }

    // We create groups
    for (String strGoup : listGroups) {
        DatabaseHome.addGroupForUser(user.getUserId(), strGoup, databasePlugin);
    }

    // We save the attributes found
    List<IAttribute> listAttributes = AttributeHome.findAll(locale, mylutecePlugin);

    for (IAttribute attribute : listAttributes) {
        List<String> listValues = mapAttributesValues.get(attribute.getIdAttribute());

        if ((listValues != null) && (listValues.size() > 0)) {
            int nIdField = 0;
            boolean bMyLuteceAttribute = (attribute.getPlugin() == null)
                    || StringUtils.equals(attribute.getPlugin().getName(), MyLutecePlugin.PLUGIN_NAME);

            for (String strValue : listValues) {
                int nSeparatorIndex = strValue.indexOf(getAttributesSeparator());

                if (nSeparatorIndex >= 0) {
                    nIdField = 0;

                    try {
                        nIdField = Integer.parseInt(strValue.substring(0, nSeparatorIndex));
                    } catch (NumberFormatException e) {
                        nIdField = 0;
                    }

                    strValue = strValue.substring(nSeparatorIndex + 1);
                } else {
                    nIdField = 0;
                }

                String[] strValues = { strValue };

                try {
                    List<MyLuteceUserField> listUserFields = attribute.getUserFieldsData(strValues,
                            user.getUserId());

                    for (MyLuteceUserField userField : listUserFields) {
                        if (userField != null) {
                            userField.getAttributeField().setIdField(nIdField);
                            MyLuteceUserFieldHome.create(userField, mylutecePlugin);
                        }
                    }

                    if (!bMyLuteceAttribute) {
                        for (MyLuteceUserFieldListenerService myLuteceUserFieldListenerService : SpringContextService
                                .getBeansOfType(MyLuteceUserFieldListenerService.class)) {
                            myLuteceUserFieldListenerService.doCreateUserFields(user.getUserId(),
                                    listUserFields, locale);
                        }
                    }
                } catch (Exception e) {
                    AppLogService.error(e.getMessage(), e);

                    String strErrorMessage = I18nService.getLocalizedString(MESSAGE_ERROR_IMPORTING_ATTRIBUTES,
                            locale);
                    CSVMessageDescriptor error = new CSVMessageDescriptor(CSVMessageLevel.ERROR, nLineNumber,
                            strErrorMessage);
                    listMessages.add(error);
                }
            }
        }
    }

    return listMessages;
}

From source file:de.nava.informa.parsers.RSS_2_0_Parser.java

/**
 * @see de.nava.informa.core.ChannelParserIF#parse(de.nava.informa.core.ChannelBuilderIF, org.jdom2.Element)
 *//* w  ww  . j a  v  a2s  . c om*/
public ChannelIF parse(ChannelBuilderIF cBuilder, Element root) throws ParseException {
    if (cBuilder == null) {
        throw new RuntimeException("Without builder no channel can be created.");
    }
    Date dateParsed = new Date();
    logger.debug("start parsing.");

    Namespace defNS = ParserUtils.getDefaultNS(root);
    if (defNS == null) {
        defNS = Namespace.NO_NAMESPACE;
        logger.info("No default namespace found.");
    }
    Namespace dcNS = ParserUtils.getNamespace(root, "dc");
    // fall back to default name space
    if (dcNS == null) {
        dcNS = defNS;
    }

    // Content namespace
    Namespace contentNS = ParserUtils.getNamespace(root, "content");
    // fall back to default name space
    if (contentNS == null) {
        contentNS = defNS;
    }

    ParserUtils.matchCaseOfChildren(root, "channel");

    // Get the channel element (only one occurs)
    Element channel = root.getChild("channel", defNS);
    if (channel == null) {
        logger.warn("Channel element could not be retrieved from feed.");
        throw new ParseException("No channel element found in feed.");
    }

    // --- read in channel information

    ParserUtils.matchCaseOfChildren(channel,
            new String[] { "title", "description", "link", "language", "item", "image", "textinput",
                    "copyright", "rating", "docs", "generator", "pubDate", "lastBuildDate", "category",
                    "managingEditor", "webMaster", "cloud" });

    // 1 title element
    ChannelIF chnl = cBuilder.createChannel(channel, channel.getChildTextTrim("title", defNS));

    // set channel format
    chnl.setFormat(ChannelFormat.RSS_2_0);

    // 1 description element
    chnl.setDescription(channel.getChildTextTrim("description", defNS));

    // 1 link element
    chnl.setSite(ParserUtils.getURL(channel.getChildTextTrim("link", defNS)));

    // 1 language element
    chnl.setLanguage(channel.getChildTextTrim("language", defNS));

    // 1..n item elements
    List items = channel.getChildren("item", defNS);
    for (Object item1 : items) {
        Element item = (Element) item1;

        ParserUtils.matchCaseOfChildren(item,
                new String[] { "title", "link", "encoded", "description", "subject", "category", "pubDate",
                        "date", "author", "creator", "comments", "guid", "source", "enclosure" });

        // get title element
        Element elTitle = item.getChild("title", defNS);
        String strTitle = "<No Title>";
        if (elTitle != null) {
            strTitle = elTitle.getTextTrim();
        }
        if (logger.isDebugEnabled()) {
            logger.debug("Item element found (" + strTitle + ").");
        }

        // get link element
        Element elLink = item.getChild("link", defNS);
        String strLink = "";
        if (elLink != null) {
            strLink = elLink.getTextTrim();
        }

        // get description element
        Element elDesc = item.getChild("encoded", contentNS);
        if (elDesc == null) {
            elDesc = item.getChild("description", defNS);
        }
        String strDesc = "";
        if (elDesc != null) {
            strDesc = elDesc.getTextTrim();
        }

        // generate new RSS item (link to article)
        ItemIF rssItem = cBuilder.createItem(item, chnl, strTitle, strDesc, ParserUtils.getURL(strLink));

        // get subject element
        Element elSubject = item.getChild("subject", defNS);
        if (elSubject == null) {
            // fallback mechanism: get dc:subject element
            elSubject = item.getChild("subject", dcNS);
        }
        if (elSubject != null) {
            rssItem.setSubject(elSubject.getTextTrim());
        }

        // get category list
        // get list of <category> elements
        List listCategory = item.getChildren("category", defNS);
        if (listCategory.size() < 1) {
            // fallback mechanism: get dc:category element
            listCategory = item.getChildren("category", dcNS);
        }
        if (listCategory.size() > 0) {
            RecursiveHashtable<String> catTable = new RecursiveHashtable<String>();

            // for each category, parse hierarchy
            for (Object aListCategory : listCategory) {
                RecursiveHashtable<String> currTable = catTable;
                Element elCategory = (Element) aListCategory;
                // get contents of category element
                String[] titles = elCategory.getTextNormalize().split("/");
                for (String title : titles) {
                    // tokenize category string to extract out hierarchy
                    if (!currTable.containsKey(title)) {
                        // if token does not exist in current map, add it with child Hashtable
                        currTable.put(title, new RecursiveHashtable<String>());
                    }
                    // reset current Hashtable to child's Hashtable then iterate to next token
                    currTable = currTable.get(title);
                }
            }
            ArrayList<CategoryIF> catList = new ArrayList<CategoryIF>();
            // transform cat list & hierarchy into list of CategoryIF elements
            Enumeration<String> enumCategories = catTable.keys();
            while (enumCategories.hasMoreElements()) {
                String key = enumCategories.nextElement();
                // build category list: getCategoryList(parent, title, children)
                CategoryIF cat = getCategoryList(null, key, catTable.get(key));
                catList.add(cat);
            }
            if (catList.size() > 0) {
                // if categories were actually created, then add list to item node
                rssItem.setCategories(catList);
            }
        }

        // get publication date
        Element elDate = item.getChild("pubDate", defNS);
        if (elDate == null) {
            // fallback mechanism: get dc:date element
            elDate = item.getChild("date", dcNS);
        }
        if (elDate != null) {
            rssItem.setDate(ParserUtils.getDate(elDate.getTextTrim()));
        }

        rssItem.setFound(dateParsed);

        // get Author element
        Element elAuthor = item.getChild("author", defNS);
        if (elAuthor == null) {
            // fallback mechanism: get dc:creator element
            elAuthor = item.getChild("creator", dcNS);
        }
        if (elAuthor != null)
            rssItem.setCreator(elAuthor.getTextTrim());

        // get Comments element
        Element elComments = item.getChild("comments", defNS);
        String strComments = "";
        if (elComments != null) {
            strComments = elComments.getTextTrim();
        }
        rssItem.setComments(ParserUtils.getURL(strComments));

        // get guid element
        Element elGuid = item.getChild("guid", defNS);
        if (elGuid != null) {
            String guidUrl = elGuid.getTextTrim();
            if (guidUrl != null) {
                boolean permaLink = true;
                Attribute permaLinkAttribute = elGuid.getAttribute("isPermaLink", defNS);
                if (permaLinkAttribute != null) {
                    String permaLinkStr = permaLinkAttribute.getValue();
                    if (permaLinkStr != null) {
                        permaLink = Boolean.valueOf(permaLinkStr);
                    }
                }
                ItemGuidIF itemGuid = cBuilder.createItemGuid(rssItem, guidUrl, permaLink);
                rssItem.setGuid(itemGuid);
            }
        }

        // get source element
        Element elSource = item.getChild("source", defNS);
        if (elSource != null) {
            String sourceName = elSource.getTextTrim();
            Attribute sourceAttribute = elSource.getAttribute("url", defNS);
            if (sourceAttribute != null) {
                String sourceLocation = sourceAttribute.getValue().trim();
                ItemSourceIF itemSource = cBuilder.createItemSource(rssItem, sourceName, sourceLocation, null);
                rssItem.setSource(itemSource);
            }
        }

        // get enclosure element
        Element elEnclosure = item.getChild("enclosure", defNS);
        if (elEnclosure != null) {
            URL location = null;
            String type = null;
            int length = -1;
            Attribute urlAttribute = elEnclosure.getAttribute("url", defNS);
            if (urlAttribute != null) {
                location = ParserUtils.getURL(urlAttribute.getValue().trim());
            }
            Attribute typeAttribute = elEnclosure.getAttribute("type", defNS);
            if (typeAttribute != null) {
                type = typeAttribute.getValue().trim();
            }
            Attribute lengthAttribute = elEnclosure.getAttribute("length", defNS);
            if (lengthAttribute != null) {
                try {
                    length = Integer.parseInt(lengthAttribute.getValue().trim());
                } catch (NumberFormatException e) {
                    logger.warn(e);
                }
            }
            ItemEnclosureIF itemEnclosure = cBuilder.createItemEnclosure(rssItem, location, type, length);
            rssItem.setEnclosure(itemEnclosure);
        }
    }

    // 0..1 image element
    Element image = channel.getChild("image", defNS);
    if (image != null) {

        ParserUtils.matchCaseOfChildren(image,
                new String[] { "title", "url", "link", "width", "height", "description" });

        ImageIF rssImage = cBuilder.createImage(image.getChildTextTrim("title", defNS),
                ParserUtils.getURL(image.getChildTextTrim("url", defNS)),
                ParserUtils.getURL(image.getChildTextTrim("link", defNS)));
        Element imgWidth = image.getChild("width", defNS);
        if (imgWidth != null) {
            try {
                rssImage.setWidth(Integer.parseInt(imgWidth.getTextTrim()));
            } catch (NumberFormatException e) {
                logger.warn("Error parsing width: " + e.getMessage());
            }
        }
        Element imgHeight = image.getChild("height", defNS);
        if (imgHeight != null) {
            try {
                rssImage.setHeight(Integer.parseInt(imgHeight.getTextTrim()));
            } catch (NumberFormatException e) {
                logger.warn("Error parsing height: " + e.getMessage());
            }
        }
        Element imgDescr = image.getChild("description", defNS);
        if (imgDescr != null) {
            rssImage.setDescription(imgDescr.getTextTrim());
        }
        chnl.setImage(rssImage);
    }

    // 0..1 textinput element
    Element txtinp = channel.getChild("textinput", defNS);
    if (txtinp != null) {

        ParserUtils.matchCaseOfChildren(txtinp, new String[] { "title", "description", "name", "link" });

        TextInputIF rssTextInput = cBuilder.createTextInput(txtinp.getChildTextTrim("title", defNS),
                txtinp.getChildTextTrim("description", defNS), txtinp.getChildTextTrim("name", defNS),
                ParserUtils.getURL(txtinp.getChildTextTrim("link", defNS)));
        chnl.setTextInput(rssTextInput);
    }

    // 0..1 copyright element
    Element copyright = channel.getChild("copyright", defNS);
    if (copyright != null) {
        chnl.setCopyright(copyright.getTextTrim());
    }

    // 0..1 Rating element
    Element rating = channel.getChild("rating", defNS);
    if (rating != null) {
        chnl.setRating(rating.getTextTrim());
    }

    // 0..1 Docs element
    Element docs = channel.getChild("docs", defNS);
    if (docs != null) {
        chnl.setDocs(docs.getTextTrim());
    }

    // 0..1 Generator element
    Element generator = channel.getChild("generator", defNS);
    if (generator != null) {
        chnl.setGenerator(generator.getTextTrim());
    }

    // 0..1 ttl element
    Element ttl = channel.getChild("ttl", defNS);
    if (ttl != null) {
        String ttlValue = ttl.getTextTrim();
        try {
            chnl.setTtl(Integer.parseInt(ttlValue));
        } catch (NumberFormatException e) {
            logger.warn("Invalid TTL format: '" + ttlValue + "'");
        }
    }

    // 0..1 pubDate element
    Element pubDate = channel.getChild("pubDate", defNS);
    if (pubDate != null) {
        chnl.setPubDate(ParserUtils.getDate(pubDate.getTextTrim()));
    }

    // 0..1 lastBuildDate element
    Element lastBuildDate = channel.getChild("lastBuildDate", defNS);
    if (lastBuildDate != null) {
        chnl.setLastBuildDate(ParserUtils.getDate(lastBuildDate.getTextTrim()));
    }

    // get category list
    // get list of <category> elements
    List listCategory = channel.getChildren("category", defNS);
    if (listCategory.size() < 1) {
        // fallback mechanism: get dc:category element
        listCategory = channel.getChildren("category", dcNS);
    }
    if (listCategory.size() > 0) {
        RecursiveHashtable<String> catTable = new RecursiveHashtable<String>();
        // for each category, parse hierarchy
        for (Object aListCategory : listCategory) {
            RecursiveHashtable<String> currTable = catTable;
            Element elCategory = (Element) aListCategory;
            // get contents of category element
            String[] titles = elCategory.getTextNormalize().split("/");
            for (String title : titles) {
                // tokenize category string to extract out hierarchy
                if (!currTable.containsKey(title)) {
                    // if token does not exist in current map, add it with child Hashtable
                    currTable.put(title, new RecursiveHashtable<String>());
                }
                // reset current Hashtable to child's Hashtable then iterate to next token
                currTable = currTable.get(title);
            }
        }
        ArrayList<CategoryIF> catList = new ArrayList<CategoryIF>();
        // transform cat list & hierarchy into list of CategoryIF elements
        Enumeration<String> enumCategories = catTable.keys();
        while (enumCategories.hasMoreElements()) {
            String key = enumCategories.nextElement();
            // build category list: getCategoryList(parent, title, children)
            CategoryIF cat = getCategoryList(null, key, catTable.get(key));
            catList.add(cat);
        }
        if (catList.size() > 0) {
            // if categories were actually created, then add list to item node
            chnl.setCategories(catList);
        }
    }

    // 0..1 managingEditor element
    Element managingEditor = channel.getChild("managingEditor", defNS);
    if (managingEditor != null) {
        chnl.setCreator(managingEditor.getTextTrim());
    }

    // 0..1 webMaster element
    Element webMaster = channel.getChild("webMaster", defNS);
    if (webMaster != null) {
        chnl.setPublisher(webMaster.getTextTrim());
    }

    // 0..1 cloud element
    Element cloud = channel.getChild("cloud", defNS);
    if (cloud != null) {
        String _port = cloud.getAttributeValue("port", defNS);
        int port = -1;
        if (_port != null) {
            try {
                port = Integer.parseInt(_port);
            } catch (NumberFormatException e) {
                logger.warn(e);
            }
        }
        chnl.setCloud(cBuilder.createCloud(cloud.getAttributeValue("domain", defNS), port,
                cloud.getAttributeValue("path", defNS), cloud.getAttributeValue("registerProcedure", defNS),
                cloud.getAttributeValue("protocol", defNS)));
    }

    chnl.setLastUpdated(dateParsed);

    // 0..1 skipHours element
    // 0..1 skipDays element

    return chnl;
}

From source file:de.interactive_instruments.ShapeChange.Target.SQL.SqlDdl.java

/**
 * @see de.interactive_instruments.ShapeChange.Target.Target#initialise(de.interactive_instruments.ShapeChange.Model.PackageInfo,
 *      de.interactive_instruments.ShapeChange.Model.Model,
 *      de.interactive_instruments.ShapeChange.Options,
 *      de.interactive_instruments.ShapeChange.ShapeChangeResult, boolean)
 *///  www.j  a v a 2s .  com
public void initialise(PackageInfo pi, Model m, Options o, ShapeChangeResult r, boolean diagOnly)
        throws ShapeChangeAbortException {

    schema = pi;
    model = m;
    options = o;
    result = r;
    diagnosticsOnly = diagOnly;

    result.addDebug(this, 1, pi.name());

    outputDirectory = options.parameter(this.getClass().getName(), "outputDirectory");
    if (outputDirectory == null)
        outputDirectory = options.parameter("outputDirectory");
    if (outputDirectory == null)
        outputDirectory = options.parameter(".");

    // create output directory, if necessary
    if (!this.diagnosticsOnly) {

        // Check whether we can use the given output directory
        File outputDirectoryFile = new File(outputDirectory);
        boolean exi = outputDirectoryFile.exists();
        if (!exi) {
            outputDirectoryFile.mkdirs();
            exi = outputDirectoryFile.exists();
        }
        boolean dir = outputDirectoryFile.isDirectory();
        boolean wrt = outputDirectoryFile.canWrite();
        boolean rea = outputDirectoryFile.canRead();
        if (!exi || !dir || !wrt || !rea) {
            result.addFatalError(this, 3, outputDirectory);
            return;
        }
    }

    if (pi.matches(RULE_TGT_SQL_ALL_ASSOCIATIVETABLES)) {
        this.createAssociativeTables = true;
    }

    String databaseSystem = options.parameter(this.getClass().getName(), PARAM_DATABASE_SYSTEM);
    if (databaseSystem == null || "postgresql".equalsIgnoreCase(databaseSystem)) {
        databaseStrategy = new PostgreSQLStrategy();
    } else if ("oracle".equalsIgnoreCase(databaseSystem)) {
        databaseStrategy = new OracleStrategy(result);
    } else {
        databaseStrategy = new NullDatabaseStrategy();
        result.addFatalError(this, 6, databaseSystem);
    }

    idColumnName = options.parameter(this.getClass().getName(), PARAM_ID_COLUMN_NAME);
    if (idColumnName == null) {
        idColumnName = DEFAULT_ID_COLUMN_NAME;
    }

    foreignKeyColumnSuffix = options.parameter(this.getClass().getName(), PARAM_FOREIGN_KEY_COLUMN_SUFFIX);
    if (foreignKeyColumnSuffix == null) {
        foreignKeyColumnSuffix = DEFAULT_FOREIGN_KEY_COLUMN_SUFFIX;
    }

    foreignKeyColumnSuffixDatatype = options.parameter(this.getClass().getName(),
            PARAM_FOREIGN_KEY_COLUMN_SUFFIX_DATATYPE);
    if (foreignKeyColumnSuffixDatatype == null) {
        foreignKeyColumnSuffixDatatype = DEFAULT_FOREIGN_KEY_COLUMN_SUFFIX_DATATYPE;
    }

    foreignKeyColumnDataType = options.parameter(this.getClass().getName(), PARAM_FOREIGN_KEY_COLUMN_DATA_TYPE);
    if (foreignKeyColumnDataType == null) {
        foreignKeyColumnDataType = databaseStrategy.primaryKeyDataType();
    }

    String defaultSizeByConfig = options.parameter(this.getClass().getName(), PARAM_SIZE);
    if (defaultSizeByConfig == null) {
        defaultSize = DEFAULT_SIZE;
    } else {
        try {
            defaultSize = Integer.parseInt(defaultSizeByConfig);
        } catch (NumberFormatException e) {
            MessageContext mc = result.addWarning(this, 4, PARAM_SIZE, e.getMessage(), "" + DEFAULT_SIZE);
            mc.addDetail(this, 0);
            defaultSize = DEFAULT_SIZE;
        }
    }

    String defaultSridByConfig = options.parameter(this.getClass().getName(), PARAM_SRID);
    if (defaultSridByConfig == null) {
        srid = DEFAULT_SRID;
    } else {
        try {
            srid = Integer.parseInt(defaultSridByConfig);
        } catch (NumberFormatException e) {
            MessageContext mc = result.addWarning(this, 4, PARAM_SRID, e.getMessage(), "" + DEFAULT_SRID);
            mc.addDetail(this, 0);
            srid = DEFAULT_SRID;
        }
    }

    String createReferencesByConfig = options.parameter(this.getClass().getName(), PARAM_CREATE_REFERENCES);
    if (createReferencesByConfig != null) {
        createReferences = Boolean.parseBoolean(createReferencesByConfig.trim());
    }

    String createDocumentationByConfig = options.parameter(this.getClass().getName(),
            PARAM_CREATE_DOCUMENTATION);
    if (createDocumentationByConfig != null) {
        createDocumentation = Boolean.parseBoolean(createDocumentationByConfig.trim());
    }

    // change the default documentation template?
    documentationTemplate = options.parameter(this.getClass().getName(), PARAM_DOCUMENTATION_TEMPLATE);
    documentationNoValue = options.parameter(this.getClass().getName(), PARAM_DOCUMENTATION_NOVALUE);

    // reset processed flags on all classes in the schema
    for (Iterator<ClassInfo> k = model.classes(pi).iterator(); k.hasNext();) {
        ClassInfo ci = k.next();
        ci.processed(getTargetID(), false);
    }

    // identify map entries defined in the target configuration
    List<ProcessMapEntry> mapEntries = options.getCurrentProcessConfig().getMapEntries();

    if (mapEntries == null || mapEntries.isEmpty()) {

        /*
         * It is unlikely but not impossible that an application schema does
         * not make use of types that require a type mapping in order to be
         * converted into a database schema.
         */
        result.addWarning(this, 15);

    } else {

        /*
         * Store map entries in map with key being the 'type'.
         */
        for (ProcessMapEntry pme : mapEntries) {

            this.mapEntryByType.put(pme.getType(), pme);
        }

        /*
         * Parse all parameter information
         */
        mepp = new MapEntryParamInfos(result, mapEntries);

        validateMapEntryParamInfos(mepp);
    }
}

From source file:no.kantega.kwashc.server.test.SSLCipherSuiteTest.java

@Override
protected TestResult testSite(Site site, TestResult testResult) throws Throwable {
    long startTime = System.nanoTime();

    int httpsPort;
    try {//from ww  w .  j  ava  2 s  .  c  o  m
        httpsPort = new Integer(site.getSecureport());
    } catch (NumberFormatException e) {
        testResult.setResultEnum(ResultEnum.failed);
        testResult.setMessage("No HTTPS port specified, test not run!");
        setDuration(testResult, startTime);
        return testResult;
    }

    HttpClient httpclient = HttpClientUtil.getHttpClient();

    try {

        String[] ciphers = new String[] { "SSL_RSA_WITH_3DES_EDE_CBC_SHA", "SSL_DHE_RSA_WITH_DES_CBC_SHA",
                "SSL_DHE_DSS_WITH_DES_CBC_SHA", "SSL_RSA_WITH_NULL_MD5", "SSL_RSA_WITH_NULL_SHA",
                "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5",
                "SSL_RSA_WITH_RC4_128_SHA", "SSL_RSA_WITH_RC4_128_MD5", "TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5",
                "TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA", "TLS_DH_anon_WITH_AES_128_GCM_SHA256",
                "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", "TLS_ECDHE_RSA_WITH_RC4_128_SHA",
                "TLS_ECDH_ECDSA_WITH_RC4_128_SHA", "TLS_ECDH_RSA_WITH_RC4_128_SHA" };

        HttpResponse response = checkClientForCiphers(site, httpsPort, httpclient, ciphers);

        if (response.getStatusLine().getStatusCode() == 200) {
            testResult.setResultEnum(ResultEnum.failed);
            testResult.setMessage("Your application accepts weak/anonymous SSL/TLS cipher suites!");
        }

    } catch (NoSuchAlgorithmException e) {
        return exitMissingCipherSuites(testResult);
    } catch (KeyManagementException e) {
        return exitIncorrectCertificate(testResult);
    } catch (IOException e) {
        if (e.getMessage().contains("peer not authenticated")) {

            HttpClient httpclient2 = HttpClientUtil.getHttpClient();
            try {
                String[] ciphers = new String[] { "TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
                        "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256", "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256",
                        "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA" };
                HttpResponse response = checkClientForCiphers(site, httpsPort, httpclient2, ciphers);

                if (response.getStatusLine().getStatusCode() == 200) {

                    HttpClient httpclient3 = HttpClientUtil.getHttpClient();
                    try {
                        String[] ciphers2 = new String[] { "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
                                "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256",
                                "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
                                "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
                                "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256",
                                "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA", "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
                                "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA" };

                        HttpResponse response2 = checkClientForCiphers(site, httpsPort, httpclient3, ciphers2);

                        if (response2.getStatusLine().getStatusCode() == 200) {
                            testResult.setResultEnum(ResultEnum.passed);
                            testResult.setMessage(
                                    "Top score, no weak/anonymous ciphers and supporting the best available Perfect Forward Secrecy ciphers are present.");
                        } else {
                            exitWrongHttpCode(testResult);
                        }
                        return testResult;
                    } catch (NoSuchAlgorithmException e1) {
                        return exitMissingCipherSuites(testResult);
                    } catch (KeyManagementException e1) {
                        return exitIncorrectCertificate(testResult);
                    } catch (IOException e1) {
                        testResult.setResultEnum(ResultEnum.partial);
                        testResult.setMessage(
                                "Almost there, no weak/anonymous ciphers and allows Perfect Forward Secrecy, but some of your ciphers require DSA keys, which are effectively limited to 1024 bits!");
                        return testResult;
                    } finally {
                        httpclient3.getConnectionManager().shutdown();
                    }
                } else {
                    exitWrongHttpCode(testResult);
                }
                return testResult;
            } catch (NoSuchAlgorithmException e1) {
                return exitMissingCipherSuites(testResult);
            } catch (KeyManagementException e1) {
                return exitIncorrectCertificate(testResult);
            } catch (IOException e1) {
                testResult.setResultEnum(ResultEnum.partial);
                testResult.setMessage(
                        "Looking better, your application does not allow SSL/TLS connection with anonymous/weak ciphers, but does not support Perfect Forward Secrecy!");
                return testResult;
            } finally {
                httpclient2.getConnectionManager().shutdown();
            }

        } else {
            testResult.setResultEnum(ResultEnum.failed);
            testResult.setMessage("Actual testing failed, check that the connection is working!");
        }
    } finally {
        httpclient.getConnectionManager().shutdown();
        setDuration(testResult, startTime);
    }

    return testResult;
}

From source file:com.collabnet.ccf.teamforge.TFWriter.java

private PlanningFolderDO updatePlanningFolder(GenericArtifact ga, String project, Connection connection)
        throws RemoteException, PlanningFolderRuleViolationException {

    String id = ga.getTargetArtifactId();

    String targetSystemTimezone = ga.getTargetSystemTimezone();

    GenericArtifactField description = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.description.getFieldName(), ga);

    GenericArtifactField title = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.title.getFieldName(), ga);

    GenericArtifactField statusField = null;
    GenericArtifactField releaseIdField = null;
    GenericArtifactField capacityField = null;
    GenericArtifactField pointsCapacityField = null;
    GenericArtifactField trackerUnitIdField = null;

    if (connection.supports54()) {
        statusField = GenericArtifactHelper
                .getMandatoryGAField(TFArtifactMetaData.TFFields.status.getFieldName(), ga);
        releaseIdField = GenericArtifactHelper
                .getMandatoryGAField(TFArtifactMetaData.TFFields.releaseId.getFieldName(), ga);
        capacityField = GenericArtifactHelper
                .getMandatoryGAField(TFArtifactMetaData.TFFields.capacity.getFieldName(), ga);
    }/*from www .j av a2  s .  c  o  m*/

    if (connection.supports62()) {
        trackerUnitIdField = GenericArtifactHelper
                .getMandatoryGAField(TFArtifactMetaData.TFFields.trackerUnitId.getFieldName(), ga);
    }

    if (connection.supports63()) {
        pointsCapacityField = GenericArtifactHelper
                .getMandatoryGAField(TFArtifactMetaData.TFFields.pointsCapacity.getFieldName(), ga);
    }

    GenericArtifactField startDateField = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.startDate.getFieldName(), ga);

    if (startDateField != null && startDateField.getFieldValueHasChanged()) {
        GregorianCalendar gc = (GregorianCalendar) startDateField.getFieldValue();
        if (gc != null) {
            Date dateValue = gc.getTime();
            if (DateUtil.isAbsoluteDateInTimezone(dateValue, "GMT")) {
                startDateField.setFieldValue(
                        DateUtil.convertGMTToTimezoneAbsoluteDate(dateValue, targetSystemTimezone));
            } else {
                startDateField.setFieldValue(dateValue);
            }
        }
    }

    GenericArtifactField endDateField = GenericArtifactHelper
            .getMandatoryGAField(TFArtifactMetaData.TFFields.endDate.getFieldName(), ga);

    if (endDateField != null && endDateField.getFieldValueHasChanged()) {
        GregorianCalendar gc = (GregorianCalendar) endDateField.getFieldValue();
        if (gc != null) {
            Date dateValue = gc.getTime();
            if (DateUtil.isAbsoluteDateInTimezone(dateValue, "GMT")) {
                endDateField.setFieldValue(
                        DateUtil.convertGMTToTimezoneAbsoluteDate(dateValue, targetSystemTimezone));
            } else {
                endDateField.setFieldValue(dateValue);
            }
        }
    }

    boolean planningFolderNotUpdated = true;
    PlanningFolderDO planningFolder = null;
    while (planningFolderNotUpdated) {
        try {
            planningFolderNotUpdated = false;
            planningFolder = connection.getPlanningClient().getPlanningFolderData(id);

            // do conflict resolution
            if (!AbstractWriter.handleConflicts(planningFolder.getVersion(), ga)) {
                return null;
            }

            if (title != null && title.getFieldValueHasChanged()) {
                planningFolder.setTitle((String) title.getFieldValue());
            }
            if (description != null && description.getFieldValueHasChanged()) {
                planningFolder.setDescription((String) description.getFieldValue());
            }
            if (startDateField != null && startDateField.getFieldValueHasChanged()) {
                planningFolder.setStartDate((Date) startDateField.getFieldValue());
            }
            if (endDateField != null && endDateField.getFieldValueHasChanged()) {
                planningFolder.setEndDate((Date) endDateField.getFieldValue());
            }

            if (statusField != null && statusField.getFieldValueHasChanged()) {
                planningFolder.setStatus((String) statusField.getFieldValue());
            }

            if (releaseIdField != null && releaseIdField.getFieldValueHasChanged()) {
                String releaseId = (String) releaseIdField.getFieldValue();
                if (translateTechnicalReleaseIds) {
                    releaseId = TFTrackerHandler.convertReleaseIdForProject(connection, releaseId, project,
                            isReleaseIdFieldsContainFileReleasePackageName()
                                    ? getPackageReleaseSeparatorString()
                                    : null);
                }

                planningFolder.setReleaseId(releaseId);
            }

            if (capacityField != null && capacityField.getFieldValueHasChanged()) {
                Object fieldValueObj = capacityField.getFieldValue();
                int fieldValue = 0;
                if (fieldValueObj instanceof String) {
                    String fieldValueString = (String) fieldValueObj;
                    try {
                        fieldValue = Integer.parseInt(fieldValueString);
                    } catch (NumberFormatException e) {
                        throw new CCFRuntimeException(
                                "Could not parse value of mandatory field capacity: " + e.getMessage(), e);
                    }
                } else if (fieldValueObj instanceof Integer) {
                    fieldValue = ((Integer) fieldValueObj).intValue();
                }
                planningFolder.setCapacity(fieldValue);

            }

            if (pointsCapacityField != null && pointsCapacityField.getFieldValueHasChanged()) {
                Object fieldValueObj = pointsCapacityField.getFieldValue();
                int fieldValue = 0;
                if (fieldValueObj instanceof String) {
                    String fieldValueString = (String) fieldValueObj;
                    try {
                        fieldValue = Integer.parseInt(fieldValueString);
                    } catch (NumberFormatException e) {
                        throw new CCFRuntimeException(
                                "Could not parse value of mandatory field points capacity: " + e.getMessage(),
                                e);
                    }
                } else if (fieldValueObj instanceof Integer) {
                    fieldValue = ((Integer) fieldValueObj).intValue();
                }
                planningFolder.setPointsCapacity(fieldValue);

                if (trackerUnitIdField != null && trackerUnitIdField.getFieldValueHasChanged()) {
                    String trackerUnitId = (String) trackerUnitIdField.getFieldValue();
                    String trackerUnitIdValue = !StringUtils.isEmpty(trackerUnitId) ? trackerUnitId : "Hours";
                    trackerUnitId = TFTrackerHandler.getTrackerUnitId(connection, trackerUnitIdValue, project);
                    planningFolder.setTrackerUnitId(trackerUnitId);
                }

            }
            connection.getPlanningClient().setPlanningFolderData(planningFolder);
        } catch (AxisFault e) {
            javax.xml.namespace.QName faultCode = e.getFaultCode();
            if (!faultCode.getLocalPart().equals("VersionMismatchFault")) {
                throw e;
            }
            logConflictResolutor.warn("Stale update for TF planning folder " + id + " in project " + project
                    + ". Trying again ...", e);
            planningFolderNotUpdated = true;
        }
    }

    planningFolder = connection.getPlanningClient().getPlanningFolderData(id);

    // now we have to cope with moving planning folders around
    String parentArtifactId = ga.getDepParentTargetArtifactId();
    // first of all, if parent is unknown or null, we do not change anything
    if (parentArtifactId != null && !parentArtifactId.equals(GenericArtifact.VALUE_UNKNOWN)) {
        // check for the special case this is a top level PF
        if (parentArtifactId.equals(GenericArtifact.VALUE_NONE)) {
            // check whether this is already a top level planning folder
            if (!planningFolder.getParentFolderId().startsWith("PlanningApp")) {
                // move to top
                connection.getPlanningClient().movePlanningFolder(id, project);
                planningFolder = connection.getPlanningClient().getPlanningFolderData(id);
            }
        } else {
            // check whether correct parent is already assigned
            if (!parentArtifactId.equals(planningFolder.getParentFolderId())) {
                connection.getPlanningClient().movePlanningFolder(id, parentArtifactId);
                planningFolder = connection.getPlanningClient().getPlanningFolderData(id);
            }
        }
    }
    log.info("Planning folder updated. TF Id: " + planningFolder.getId() + " in project " + project
            + " other system id: " + ga.getSourceArtifactId() + " in repository: "
            + ga.getSourceRepositoryId());
    return planningFolder;
}