Example usage for java.lang String contentEquals

List of usage examples for java.lang String contentEquals

Introduction

In this page you can find the example usage for java.lang String contentEquals.

Prototype

public boolean contentEquals(CharSequence cs) 

Source Link

Document

Compares this string to the specified CharSequence .

Usage

From source file:com.openarc.nirmal.nestle.LoginActivity.java

private boolean isSameLastLoginUser(String newUserName) {
    String previousUserName = sharedPreferences.getString(SharedPreferencesName.previousLoginUserName, "");
    return newUserName.contentEquals(previousUserName)
            || !(!newUserName.contentEquals(previousUserName) && !previousUserName.contentEquals(""));
}

From source file:com.jacr.instagramtrendreader.Main.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.activity_main);

    /* Customizing ActionBar */
    Resources r = getResources();
    ActionBar ab = super.getActionBar(false);
    ab.setIcon(r.getDrawable(R.drawable.ic_menu_home));
    ab.setTitle(Util.getTitleActivity(getString(R.string.title_my_gallery_app)));

    /* Views *//*from  w w  w  .  j ava2  s  .  com*/
    layoutThumbnail = (TableLayout) findViewById(R.id.layoutThumbnail);
    layoutThumbnail.setPadding(1, 1, 1, 1);

    /* Setting Viewpager and Indicator */
    mPager = (ViewPager) findViewById(R.id.pagerMain);
    mAdapter = new ViewPagerAdapter<MainFragment>(getSupportFragmentManager());
    mPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageSelected(int arg0) {
            int key = feedReader.getListThumbnailKeys().get(arg0);
            feedReader.highlightThumbnail(key);

        }

    });

    /* Receiver */
    mReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            Bundle extras = intent.getExtras();
            if (action.contentEquals(ACTION_IMAGE_CLICK)) {
                int key = extras.getInt(ACTION_IMAGE_CLICK);
                if (key != -1) {
                    Intent in = new Intent(Main.this, ImageDetails.class);
                    Bundle b = new Bundle();

                    /*
                     * Warning with Error FAILED BINDED TRANSACTION: it
                     * happens When the transfer of "extras" out of memory.
                     * in This case, when images are sent in intent.
                     */
                    b.putSerializable(ImageDetails.KEY_THUMBNAIL_DATA, feedReader.getListThumbnailData());
                    b.putSerializable(ImageDetails.KEY_THUMBNAIL_KEYS, feedReader.getListThumbnailKeys());
                    b.putInt(ImageDetails.KEY_THUMBNAIL_ACTUAL_KEY, key);
                    in.putExtras(b);
                    startActivity(in);
                }

            }
        }
    };
    IntentFilter filter = new IntentFilter();
    filter.addAction(ACTION_IMAGE_CLICK);
    registerReceiver(mReceiver, filter);

    /* Load data from Instagram */
    cargarFeedReader();
}

From source file:com.smash.revolance.ui.model.page.api.PageBean.java

public List<ElementBean> getClickableContent() {
    List<ElementBean> clickables = new ArrayList<ElementBean>();

    String impl = "";
    for (ElementBean element : getContent()) {
        impl = element.getImpl();//from w w w  .  j av a 2  s .c  o  m
        if (impl.contentEquals("Link") || impl.contains("Button")) {
            clickables.add(element);
        }
    }

    return clickables;
}

From source file:com.openarc.nirmal.nestle.LoginActivity.java

private void automaticLogin() {
    String userName = sharedPreferences.getString(SharedPreferencesName.loginUserName, "");
    String password = sharedPreferences.getString(SharedPreferencesName.loginPassword, "");
    if ((!userName.contentEquals("")) && (!password.contentEquals(""))) {
        actvUserName.setText(userName);/* w w w .j a  v a 2  s .  c om*/
        etPassword.setText(password);
        cbLoginRemember.setChecked(true);
        login(userName, password);
    }
}

From source file:sapience.injectors.stax.inject.StringBasedStaxStreamInjector.java

/**
 * Helper method, taking a XML string like <ows:Metadata xmlns:ows=\"http://ogc.org/ows\" xmlns:xlink=\"http://wrc.org/xlink\" 
 * xlink:href=\"http://dude.com\"></ows:Metadata> from the reference 
 * and checks if //  w ww. j a v  a  2s.  co m
 * a  the used prefixes match the globally used ones and
 * b) any of the declared namespaces are redundant 
 * 
 * The same is true for the XPath definition
 * 
 * @param resultingXMLString
 * @param context
 */
private void processNamespace(StringBuilder sb, NamespaceContext global, LocalNamespaceContext local) {

    Matcher prefixMatcher = prefixPattern.matcher(sb);
    Matcher nsMatcher = nsPattern.matcher(sb);
    String prefix;
    String uri;

    /* process the local namespaces */
    while (nsMatcher.find()) {
        int start = nsMatcher.start();
        int end = nsMatcher.end();
        StringBuilder sbu = new StringBuilder(sb.substring(start, end));
        String thisPrefix = sbu.substring(sbu.indexOf(":") + 1, sbu.lastIndexOf("="));
        String thisUri = sbu.substring(sbu.indexOf("\"") + 1, sbu.lastIndexOf("\""));
        // add to local namespace context
        local.put(thisPrefix, thisUri);

        if ((prefix = global.getPrefix(thisUri)) != null) {
            // namespace is registered, let's remove it
            sb.delete(start - 1, end);

            // we have to reset, since we changed the state of the matched string with the deletion
            nsMatcher.reset();
        }

    }

    /* change the prefixes */
    try {
        while (prefixMatcher.find()) {
            int start = prefixMatcher.start();
            int end = prefixMatcher.end();

            String localprefix = sb.substring(start + 1, end - 1);
            if ((global.getNamespaceURI(localprefix) == null)
                    && (uri = local.getNamespaceURI(localprefix)) != null) {
                // get the other prefix
                prefix = global.getPrefix(uri);

                if ((prefix != null) && (!(localprefix.contentEquals(prefix)))) {
                    sb.replace(start + 1, end - 1, prefix);
                    prefixMatcher.reset();
                }
            }
        }
    } catch (StringIndexOutOfBoundsException e) {
        // we do nothing here
    }

}

From source file:org.bimserver.servlets.ServiceRunnerServlet.java

@Override
public void service(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    if (request.getRequestURI().endsWith("/servicelist")) {
        processServiceList(request, response);
        return;/*from  w  ww .j av  a2 s.com*/
    }
    String token = null;
    if (request.getHeader("Authorization") != null) {
        String a = request.getHeader("Authorization");
        if (a.startsWith("Bearer")) {
            token = a.substring(7);
        }
    }
    if (token == null) {
        token = request.getHeader("Token");
    }

    LOGGER.info("Token: " + token);
    if (token == null) {
        response.sendError(403, "Token required");
    }

    String serviceName = request.getHeader("ServiceName");
    if (serviceName == null) {
        serviceName = request.getRequestURI();
        LOGGER.info("Request URI: " + serviceName);
        if (serviceName.startsWith("/services/")) {
            serviceName = serviceName.substring(10);
        }
    }
    if (serviceName == null || serviceName.trim().contentEquals("") || serviceName.trim().contentEquals("/")
            || serviceName.contentEquals("/services") || serviceName.contentEquals("/services/")) {
        // Get it from the token
        try {
            Authorization authorization = Authorization.fromToken(getBimServer().getEncryptionKey(), token);
            LOGGER.info("Authorization: " + authorization);
            if (authorization instanceof RunServiceAuthorization) {
                RunServiceAuthorization runServiceAuthorization = (RunServiceAuthorization) authorization;
                serviceName = "" + runServiceAuthorization.getSoid();
                LOGGER.info("Got SOID from token (" + serviceName + ")");
            }
        } catch (AuthenticationException e) {
            LOGGER.error("", e);
        }
    }
    LOGGER.info("ServiceName: " + serviceName);
    long serviceOid = Long.parseLong(serviceName);

    String inputType = request.getHeader("Input-Type");
    LOGGER.info("Input-Type: " + inputType);

    Set<String> acceptedFlows = new LinkedHashSet<>();
    if (request.getHeader("Accept-Flow") == null) {
        // Default
        acceptedFlows.add("SYNC");
    } else {
        String[] flows = request.getHeader("Accept-Flow").split(",");
        for (String flow : flows) {
            acceptedFlows.add(flow);
        }
    }

    try (DatabaseSession session = getBimServer().getDatabase().createSession()) {
        Authorization authorization = Authorization.fromToken(getBimServer().getEncryptionKey(), token);
        User user = session.get(authorization.getUoid(), OldQuery.getDefault());
        if (user == null) {
            LOGGER.error("Service \"" + serviceName + "\" not found for this user");
            throw new UserException("No user found with uoid " + authorization.getUoid());
        }
        if (user.getState() == ObjectState.DELETED) {
            LOGGER.error("User has been deleted");
            throw new UserException("User has been deleted");
        }
        InternalServicePluginConfiguration foundService = null;
        UserSettings userSettings = user.getUserSettings();
        for (InternalServicePluginConfiguration internalServicePluginConfiguration : userSettings
                .getServices()) {
            if (internalServicePluginConfiguration.getOid() == serviceOid) {
                foundService = internalServicePluginConfiguration;
                break;
            }
        }
        if (foundService == null) {
            LOGGER.info("Service \"" + serviceName + "\" not found for this user");
            throw new ServletException("Service \"" + serviceName + "\" not found for this user");
        }
        PluginDescriptor pluginDescriptor = foundService.getPluginDescriptor();
        ServicePlugin servicePlugin = getBimServer().getPluginManager()
                .getServicePlugin(pluginDescriptor.getPluginClassName(), true);
        if (servicePlugin instanceof BimBotsServiceInterface) {
            LOGGER.info("Found service " + servicePlugin);
            BimBotsServiceInterface bimBotsServiceInterface = (BimBotsServiceInterface) servicePlugin;
            EndPoint endPoint = getBimServer().getEndPointManager().get(token);
            InputStream inputStream = request.getInputStream();
            String contextId = request.getHeader("Context-Id");
            if (endPoint == null || !acceptedFlows.contains("ASYNC_WS")) {
                // Don't use a websocket, so synchronously process bimbot
                BimBotsOutput bimBotsOutput = new BimBotRunner(getBimServer(), inputStream, contextId,
                        inputType, authorization, foundService, bimBotsServiceInterface).runBimBot();

                response.setContentLength(bimBotsOutput.getData().length);
                response.setHeader("Output-Type", bimBotsOutput.getSchemaName());
                response.setHeader("Data-Title", bimBotsOutput.getTitle());
                response.setHeader("Content-Type", bimBotsOutput.getContentType());
                response.setHeader("Content-Disposition", bimBotsOutput.getContentDisposition());
                if (bimBotsOutput.getContextId() != null) {
                    response.setHeader("Context-Id", bimBotsOutput.getContextId());
                }
                response.getOutputStream().write(bimBotsOutput.getData());
            } else {
                TopicKey topicKey = new TopicKey();
                response.setHeader("Output-Type", "Async");
                response.setHeader("Topic-Id", "" + topicKey.getId());
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                IOUtils.copy(inputStream, baos);
                // When storing bimbot runs, a streaming deserialzer is used later in the process, memory usage can be reduced by 
                // streaming the data, but that would require the http socket to stay open (and the response witheld), which is not an option, hence the copy.

                // TODO this can only start as soon as the response has been sent
                getBimServer().getExecutorService()
                        .submit(new BimBotRunner(getBimServer(), new ByteArrayInputStream(baos.toByteArray()),
                                contextId, inputType, authorization, foundService, bimBotsServiceInterface,
                                endPoint.getStreamingSocketInterface(), topicKey.getId(),
                                endPoint.getEndPointId()));
            }
        } else {
            throw new ServletException(
                    "Service \"" + serviceName + "\" does not implement the BimBotsServiceInterface");
        }
    } catch (AuthenticationException e) {
        LOGGER.error("", e);
    } catch (BimserverDatabaseException e) {
        LOGGER.error("", e);
    } catch (UserException e) {
        LOGGER.error("", e);
    }
}

From source file:org.openhab.binding.maxcube.internal.MaxCubeBinding.java

/**
 * {@inheritDoc}/*from  w  w  w.j ava2  s .  c  o m*/
 */
@Override
public void internalReceiveCommand(String itemName, Command command) {
    logger.debug("Received command from {}", itemName);

    // resolve serial number for item
    String serialNumber = null;

    for (MaxCubeBindingProvider provider : providers) {
        serialNumber = provider.getSerialNumber(itemName);

        if (StringUtils.isBlank(serialNumber)) {
            continue;
        }

        // send command to MAX!Cube LAN Gateway
        Device device = findDevice(serialNumber, devices);

        if (device == null) {
            logger.debug("Cannot send command to device with serial number {}, device not listed.",
                    serialNumber);
            continue;
        }

        String rfAddress = device.getRFAddress();
        String commandString = null;

        if (command instanceof DecimalType || command instanceof OnOffType) {
            DecimalType decimalType = DEFAULT_OFF_TEMPERATURE;
            if (command instanceof DecimalType) {
                decimalType = (DecimalType) command;
            } else if (command instanceof OnOffType) {
                decimalType = OnOffType.ON.equals(command) ? DEFAULT_ON_TEMPERATURE : DEFAULT_OFF_TEMPERATURE;
            }

            S_Command cmd = new S_Command(rfAddress, device.getRoomId(), ((HeatingThermostat) device).getMode(),
                    decimalType.doubleValue());
            commandString = cmd.getCommandString();
        } else if (command instanceof StringType) {
            String commandContent = command.toString().trim().toUpperCase();
            S_Command cmd = null;
            ThermostatModeType commandThermoType = null;
            if (commandContent.contentEquals(ThermostatModeType.AUTOMATIC.toString())) {
                commandThermoType = ThermostatModeType.AUTOMATIC;
                cmd = new S_Command(rfAddress, device.getRoomId(), commandThermoType);
            } else if (commandContent.contentEquals(ThermostatModeType.BOOST.toString())) {
                commandThermoType = ThermostatModeType.BOOST;
                Double setTemp = Double
                        .parseDouble(((HeatingThermostat) device).getTemperatureSetpoint().toString());
                cmd = new S_Command(rfAddress, device.getRoomId(), commandThermoType, setTemp);
            } else if (commandContent.contentEquals(ThermostatModeType.MANUAL.toString())) {
                commandThermoType = ThermostatModeType.MANUAL;
                Double setTemp = Double
                        .parseDouble(((HeatingThermostat) device).getTemperatureSetpoint().toString());
                cmd = new S_Command(rfAddress, device.getRoomId(), commandThermoType, setTemp);
                logger.debug("updates to MANUAL mode with temperature '{}'", setTemp);
            } else {
                logger.debug("Only updates to AUTOMATIC, MANUAL & BOOST supported, received value ;'{}'",
                        commandContent);
                continue;
            }
            commandString = cmd.getCommandString();
        }

        if (commandString != null) {

            try {
                if (socket == null) {
                    this.socketConnect();
                }
                /*DataOutputStream stream = new DataOutputStream(socket.getOutputStream());
                        
                byte[] b = commandString.getBytes();
                stream.write(b);*/
                writer.write(commandString);
                logger.debug(commandString);
                writer.flush();

                Message message = null;
                String raw = reader.readLine();
                try {
                    while (!this.messageProcessor.isMessageAvailable()) {
                        this.messageProcessor.addReceivedLine(raw);
                        raw = reader.readLine();
                    }

                    message = this.messageProcessor.pull();
                } catch (Exception e) {
                    logger.info("Error while handling response from MAX! Cube lan gateway!");
                    logger.debug(Utils.getStackTrace(e));
                    this.messageProcessor.reset();
                }

                if (message != null) {
                    if (message.getType() == MessageType.S) {
                        sMessageProcessing((S_Message) message);
                    }
                }
                if (!exclusive) {
                    socket.close();
                    socket = null;
                }
            } catch (UnknownHostException e) {
                logger.info("Host error occurred while connecting to MAX! Cube lan gateway '{}': {}", ip,
                        e.getMessage());
                socketClose();
            } catch (IOException e) {
                logger.info("IO error occurred while writing to MAX! Cube lan gateway '{}': {}", ip,
                        e.getMessage());
                socketClose(); //reconnect on next execution
            } catch (Exception e) {
                logger.info("Error occurred while writing to MAX! Cube lan gateway '{}': {}", ip,
                        e.getMessage());
                logger.info(Utils.getStackTrace(e));
                socketClose(); //reconnect on next execution
            }
            logger.debug("Command Sent to {}", ip);
        } else {
            logger.debug("Null Command not sent to {}", ip);
        }
    }
}

From source file:uk.chromis.pos.promotion.PromotionEditor.java

private void showProducts() {

    boolean bDirtyFlag = m_Dirty.isDirty();

    if (m_ID == null) {
        m_ModelProducts = new ListValModel();
        jListProducts.setModel(m_ModelProducts);
    } else {/* w ww  . ja v  a2 s . c  o m*/
        m_SentenceProducts = m_dlPromotions.getPromotedProductsSentence(m_ID, m_criteria);
        try {
            m_ModelProducts = new ListValModel(m_SentenceProducts.list());
        } catch (BasicException ex) {
            JMessageDialog.showMessage(this,
                    new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotexecute"), ex));
        }
        jListProducts.setModel(m_ModelProducts);

        int count = m_ModelProducts.getSize();
        List<Integer> aIndexes = new ArrayList<Integer>();

        for (int i = 0; i < count; ++i) {
            Object[] avalues = (Object[]) m_ModelProducts.getElementAt(i);
            String pid = (String) avalues[DataLogicPromotions.INDEX_PROMOTEDPRODUCT_PROMOTIONID];
            if (pid != null && pid.contentEquals(m_ID)) {
                aIndexes.add(i);
            }
        }

        int list[] = new int[aIndexes.size()];
        for (int i = 0; i < aIndexes.size(); ++i)
            list[i] = aIndexes.get(i);

        jListProducts.setSelectedIndices(list);
    }
    m_Dirty.setDirty(bDirtyFlag);
}

From source file:org.odk.collect.android.tasks.DownloadFormsTask.java

private String downloadManifestAndMediaFiles(String mediaPath, FormDetails fd, int count, int total) {
    if (fd.manifestUrl == null)
        return null;

    publishProgress(Collect.getInstance().getString(R.string.fetching_manifest, fd.formName),
            Integer.valueOf(count).toString(), Integer.valueOf(total).toString());

    List<MediaFile> files = new ArrayList<MediaFile>();
    // get shared HttpContext so that authentication and cookies are retained.
    HttpContext localContext = Collect.getInstance().getHttpContext();

    HttpClient httpclient = WebUtils.createHttpClient(WebUtils.CONNECTION_TIMEOUT);

    DocumentFetchResult result = WebUtils.getXmlDocument(fd.manifestUrl, localContext, httpclient);

    if (result.errorMessage != null) {
        return result.errorMessage;
    }/*from  w  w  w  . j a v a  2  s.  c  om*/

    String errMessage = Collect.getInstance().getString(R.string.access_error, fd.manifestUrl);

    if (!result.isOpenRosaResponse) {
        errMessage += Collect.getInstance().getString(R.string.manifest_server_error);
        Log.e(t, errMessage);
        return errMessage;
    }

    // Attempt OpenRosa 1.0 parsing
    Element manifestElement = result.doc.getRootElement();
    if (!manifestElement.getName().equals("manifest")) {
        errMessage += Collect.getInstance().getString(R.string.root_element_error, manifestElement.getName());
        Log.e(t, errMessage);
        return errMessage;
    }
    String namespace = manifestElement.getNamespace();
    if (!isXformsManifestNamespacedElement(manifestElement)) {
        errMessage += Collect.getInstance().getString(R.string.root_namespace_error, namespace);
        Log.e(t, errMessage);
        return errMessage;
    }
    int nElements = manifestElement.getChildCount();
    for (int i = 0; i < nElements; ++i) {
        if (manifestElement.getType(i) != Element.ELEMENT) {
            // e.g., whitespace (text)
            continue;
        }
        Element mediaFileElement = (Element) manifestElement.getElement(i);
        if (!isXformsManifestNamespacedElement(mediaFileElement)) {
            // someone else's extension?
            continue;
        }
        String name = mediaFileElement.getName();
        if (name.equalsIgnoreCase("mediaFile")) {
            String filename = null;
            String hash = null;
            String downloadUrl = null;
            // don't process descriptionUrl
            int childCount = mediaFileElement.getChildCount();
            for (int j = 0; j < childCount; ++j) {
                if (mediaFileElement.getType(j) != Element.ELEMENT) {
                    // e.g., whitespace (text)
                    continue;
                }
                Element child = mediaFileElement.getElement(j);
                if (!isXformsManifestNamespacedElement(child)) {
                    // someone else's extension?
                    continue;
                }
                String tag = child.getName();
                if (tag.equals("filename")) {
                    filename = XFormParser.getXMLText(child, true);
                    if (filename != null && filename.length() == 0) {
                        filename = null;
                    }
                } else if (tag.equals("hash")) {
                    hash = XFormParser.getXMLText(child, true);
                    if (hash != null && hash.length() == 0) {
                        hash = null;
                    }
                } else if (tag.equals("downloadUrl")) {
                    downloadUrl = XFormParser.getXMLText(child, true);
                    if (downloadUrl != null && downloadUrl.length() == 0) {
                        downloadUrl = null;
                    }
                }
            }
            if (filename == null || downloadUrl == null || hash == null) {
                errMessage += Collect.getInstance().getString(R.string.manifest_tag_error, Integer.toString(i));
                Log.e(t, errMessage);
                return errMessage;
            }
            files.add(new MediaFile(filename, hash, downloadUrl));
        }
    }

    // OK we now have the full set of files to download...
    Log.i(t, "Downloading " + files.size() + " media files.");
    int mediaCount = 0;
    if (files.size() > 0) {
        FileUtils.createFolder(mediaPath);
        File mediaDir = new File(mediaPath);
        for (MediaFile toDownload : files) {
            if (isCancelled()) {
                return "cancelled";
            }
            ++mediaCount;
            publishProgress(
                    Collect.getInstance().getString(R.string.form_download_progress, fd.formName, mediaCount,
                            files.size()),
                    Integer.valueOf(count).toString(), Integer.valueOf(total).toString());
            try {
                File mediaFile = new File(mediaDir, toDownload.filename);

                String currentFileHash = FileUtils.getMd5Hash(mediaFile);
                String downloadFileHash = toDownload.hash.substring(MD5_COLON_PREFIX.length());

                if (!mediaFile.exists()) {
                    downloadFile(mediaFile, toDownload.downloadUrl);
                } else {
                    if (!currentFileHash.contentEquals(downloadFileHash)) {
                        // if the hashes match, it's the same file
                        // otherwise delete our current one and replace it with the new one
                        mediaFile.delete();
                        downloadFile(mediaFile, toDownload.downloadUrl);
                    } else {
                        // exists, and the hash is the same
                        // no need to download it again
                    }
                }
            } catch (Exception e) {
                return e.getLocalizedMessage();
            }
        }
    }
    return null;
}

From source file:com.mpower.mintel.android.tasks.DownloadFormsTask.java

private String downloadManifestAndMediaFiles(String mediaPath, FormDetails fd, int count, int total) {
    if (fd.manifestUrl == null)
        return null;

    publishProgress(MIntel.getInstance().getString(R.string.fetching_manifest, fd.formName),
            Integer.valueOf(count).toString(), Integer.valueOf(total).toString());

    List<MediaFile> files = new ArrayList<MediaFile>();
    // get shared HttpContext so that authentication and cookies are retained.
    HttpContext localContext = MIntel.getInstance().getHttpContext();

    HttpClient httpclient = WebUtils.createHttpClient(WebUtils.CONNECTION_TIMEOUT);

    DocumentFetchResult result = WebUtils.getXmlDocument(fd.manifestUrl, localContext, httpclient, mAuth);

    if (result.errorMessage != null) {
        return result.errorMessage;
    }/*  w  w w.j  a  v  a 2 s  . c om*/

    String errMessage = MIntel.getInstance().getString(R.string.access_error, fd.manifestUrl);

    if (!result.isOpenRosaResponse) {
        errMessage += MIntel.getInstance().getString(R.string.manifest_server_error);
        Log.e(t, errMessage);
        return errMessage;
    }

    // Attempt OpenRosa 1.0 parsing
    Element manifestElement = result.doc.getRootElement();
    if (!manifestElement.getName().equals("manifest")) {
        errMessage += MIntel.getInstance().getString(R.string.root_element_error, manifestElement.getName());
        Log.e(t, errMessage);
        return errMessage;
    }
    String namespace = manifestElement.getNamespace();
    if (!isXformsManifestNamespacedElement(manifestElement)) {
        errMessage += MIntel.getInstance().getString(R.string.root_namespace_error, namespace);
        Log.e(t, errMessage);
        return errMessage;
    }
    int nElements = manifestElement.getChildCount();
    for (int i = 0; i < nElements; ++i) {
        if (manifestElement.getType(i) != Element.ELEMENT) {
            // e.g., whitespace (text)
            continue;
        }
        Element mediaFileElement = (Element) manifestElement.getElement(i);
        if (!isXformsManifestNamespacedElement(mediaFileElement)) {
            // someone else's extension?
            continue;
        }
        String name = mediaFileElement.getName();
        if (name.equalsIgnoreCase("mediaFile")) {
            String filename = null;
            String hash = null;
            String downloadUrl = null;
            // don't process descriptionUrl
            int childCount = mediaFileElement.getChildCount();
            for (int j = 0; j < childCount; ++j) {
                if (mediaFileElement.getType(j) != Element.ELEMENT) {
                    // e.g., whitespace (text)
                    continue;
                }
                Element child = mediaFileElement.getElement(j);
                if (!isXformsManifestNamespacedElement(child)) {
                    // someone else's extension?
                    continue;
                }
                String tag = child.getName();
                if (tag.equals("filename")) {
                    filename = XFormParser.getXMLText(child, true);
                    if (filename != null && filename.length() == 0) {
                        filename = null;
                    }
                } else if (tag.equals("hash")) {
                    hash = XFormParser.getXMLText(child, true);
                    if (hash != null && hash.length() == 0) {
                        hash = null;
                    }
                } else if (tag.equals("downloadUrl")) {
                    downloadUrl = XFormParser.getXMLText(child, true);
                    if (downloadUrl != null && downloadUrl.length() == 0) {
                        downloadUrl = null;
                    }
                }
            }
            if (filename == null || downloadUrl == null || hash == null) {
                errMessage += MIntel.getInstance().getString(R.string.manifest_tag_error, Integer.toString(i));
                Log.e(t, errMessage);
                return errMessage;
            }
            files.add(new MediaFile(filename, hash, downloadUrl));
        }
    }

    // OK we now have the full set of files to download...
    Log.i(t, "Downloading " + files.size() + " media files.");
    int mediaCount = 0;
    if (files.size() > 0) {
        FileUtils.createFolder(mediaPath);
        File mediaDir = new File(mediaPath);
        for (MediaFile toDownload : files) {
            if (isCancelled()) {
                return "cancelled";
            }
            ++mediaCount;
            publishProgress(
                    MIntel.getInstance().getString(R.string.form_download_progress, fd.formName, mediaCount,
                            files.size()),
                    Integer.valueOf(count).toString(), Integer.valueOf(total).toString());
            try {
                File mediaFile = new File(mediaDir, toDownload.filename);

                String currentFileHash = FileUtils.getMd5Hash(mediaFile);
                String downloadFileHash = toDownload.hash.substring(MD5_COLON_PREFIX.length());

                if (!mediaFile.exists()) {
                    downloadFile(mediaFile, toDownload.downloadUrl);
                } else {
                    if (!currentFileHash.contentEquals(downloadFileHash)) {
                        // if the hashes match, it's the same file
                        // otherwise delete our current one and replace it with the new one
                        mediaFile.delete();
                        downloadFile(mediaFile, toDownload.downloadUrl);
                    } else {
                        // exists, and the hash is the same
                        // no need to download it again
                    }
                }
            } catch (Exception e) {
                return e.getLocalizedMessage();
            }
        }
    }
    return null;
}