public static CallNumber replaceCallNumberPrefix(CallNumber originalCallNumber,
            String newPrefix, boolean addPrefixIfNoneExists) throws MarcException {
        CallNumber newCallNumber = null;

        if (newPrefix == null) {
            throw new MarcException("Call number prefix cannot be null.");
        }
        if (MarcWorxStringHelper.find(newPrefix, " ") >= 0) {
            throw new MarcException("Call number prefix cannot include a space.");
        }
        if (MarcWorxStringHelper.isNotEmpty(new CallNumber(newPrefix).getDeweyNumber())) {
            throw new MarcException("Call number prefix cannot be a Dewey number.");
        }

        String originalPrefix = originalCallNumber.getCallNumberPrefix();
        String workingCallNumber = originalCallNumber.getCallNumber();

        if (MarcWorxStringHelper.isNotEmpty(originalPrefix)) {
            String otherStuff = MarcWorxStringHelper.splitString(workingCallNumber, " ", true, false);

            // If we didn't find a space, the call number is all localPrefix, so just replace everything
            if (otherStuff.length() == workingCallNumber.length()) {

                if (!addPrefixIfNoneExists || MarcWorxStringHelper.isNotEmpty(newPrefix)) {
                    otherStuff = "";
                }
            }

            workingCallNumber = newPrefix + " " + otherStuff.trim();
        } else if (addPrefixIfNoneExists) {
            workingCallNumber = newPrefix + " " + workingCallNumber.trim();
        }

        if (!MarcWorxStringHelper.isEmptyOrWhitespace(workingCallNumber)) {
            workingCallNumber = workingCallNumber.trim();
            newCallNumber = new CallNumber(workingCallNumber);
        }

        return newCallNumber;
    }