Example usage for java.util.regex Pattern quote

List of usage examples for java.util.regex Pattern quote

Introduction

In this page you can find the example usage for java.util.regex Pattern quote.

Prototype

public static String quote(String s) 

Source Link

Document

Returns a literal pattern String for the specified String .

Usage

From source file:com.epam.ta.reportportal.database.dao.TestItemRepositoryCustomImpl.java

@Override
public List<TestItem> findInIssueTypeItems(String issueType, String launchId) {
    Query query = query(where(LAUNCH_REFERENCE).is(launchId))
            .addCriteria(where(ISSUE_TYPE).regex(Pattern.quote(issueType)));
    return mongoTemplate.find(query, TestItem.class);
}

From source file:de.tarent.maven.plugins.pkg.AbstractMvnPkgPluginTestCase.java

protected boolean debDependsOn(String s) throws MojoExecutionException, IOException {
    final Pattern p = Pattern.compile("Depends:.*" + Pattern.quote(s) + ".*");
    return debContains(p, "--info");
}

From source file:org.jboss.as.test.integration.security.auditing.CustomAuditProviderModuleTest.java

@Test
public void testGooduser1() throws Exception {
    assertResponse(CustomLoginModule1.GOODUSER1_USERNAME, CustomLoginModule1.GOODUSER1_PASSWORD, 200);
    try (BufferedReader r = Files.newBufferedReader(AUDIT_LOG_PATH, UTF_8)) {
        assertAuditLog(r, Pattern.quote("INFO  " + CustomAuditProviderModule.class.getName()
                + " [Success]principal=" + CustomLoginModule1.GOODUSER1_USERNAME + ";"));
    }//  w  w w .  jav  a2 s  .  c  o m
}

From source file:com.demandware.appsec.csrf.StatelessCSRFTokenManager.java

/**
 * Tests the given token id + string for validity. Also does internal checking of string to attempt to detect
 * tampering/* w w w .j  a v a 2s. co m*/
 *
 * @param tokenId the random ID to use in key generation
 * @param sessionID the session of the current request
 * @param dataToCrypt (Optional) any other strings that should be used to validate the token. See class definition.
 * @param tokenString the token value to check against
 * @return true if the token is valid, false otherwise
 */
private boolean validateTokenInternal(String token, String sessionID, String... dataToCrypt) {
    boolean result = false;

    long timestamp = getCurrentTime();

    try {
        byte[] key = sessionID.getBytes(Charset.defaultCharset());

        byte[] tokenByte = decodeToken(token);
        byte[] iv = Arrays.copyOfRange(tokenByte, 0, TOKEN_SIZE);
        byte[] encryptedValue = Arrays.copyOfRange(tokenByte, TOKEN_SIZE, tokenByte.length);

        byte[] decrypted = crypt(key, iv, encryptedValue, Cipher.DECRYPT_MODE);
        String cryptText = new String(decrypted, "UTF-8");
        String[] decryptParts = cryptText.split(Pattern.quote(SEPARATOR));

        int cryptlen = dataToCrypt == null ? 0 : dataToCrypt.length;

        // 2 guaranteed pieces (session and timestamp) plus the additional data
        if (decryptParts.length == (2 + cryptlen)) {
            String decryptedSession = decryptParts[0];
            long decryptedTimestamp = Long.parseLong(decryptParts[1]);

            /*
             * verify sessions match verify that the timestamp in the 
             * token is within the permitted time allowance and verify 
             * all other possible data matches in order
             */
            if (!decryptedSession.equals(sessionID)) {
                String error = new StringBuilder().append("CSRF Token session ids don't match. Expected: ")
                        .append(sessionID).append("but received: ").append(decryptedSession).toString();

                this.handler.handleValidationError(error);
            } else if ((decryptedTimestamp + getAllowedExpiry()) < timestamp) {
                String error = new StringBuilder().append("CSRF Token has expired. Expected: ")
                        .append(timestamp).append(" but received: ").append(decryptedTimestamp).toString();

                this.handler.handleValidationError(error);
            } else if (cryptlen > 0) {
                for (int i = 0; i < cryptlen; i++) {
                    String decryptedData = decryptParts[2 + i];
                    String intendedData = dataToCrypt[i];
                    if (decryptedData.equals(intendedData)) {
                        result = true;
                    } else {
                        String error = new StringBuilder().append("CSRF Token data does not match. Excepted: ")
                                .append(intendedData).append(" but received: ").append(decryptedData)
                                .toString();

                        this.handler.handleValidationError(error);

                        result = false;

                        // if any fails, quit immediately
                        break;
                    }
                }
            } else {
                result = true;
            }
        }
    } catch (AEADBadTagException e) {
        String error = new StringBuilder().append("Could not validate token ").append(token)
                .append(" for different session ").append(sessionID).toString();

        this.handler.handleValidationError(error);
    } catch (Exception e) {
        String error = new StringBuilder().append("Could not validate token ").append(token)
                .append(" for session ").append(sessionID).append(" due to exception: ").append(e.getMessage())
                .toString();

        this.handler.handleFatalException(error, e);
    }

    return result;
}

From source file:hydrograph.ui.propertywindow.widgets.customwidgets.joinproperty.JoinMapGrid.java

/**
 * Create contents of the dialog./*w ww  . j av a  2s  . c  om*/
 * 
 * @param parent
 */
@Override
protected Control createDialogArea(Composite parent) {
    final Composite container = (Composite) super.createDialogArea(parent);
    container.getShell().setText("Join Mapping");
    container.setFocus();
    container.setLayout(new GridLayout(6, false));
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);
    new Label(container, SWT.NONE);

    Composite composite = new Composite(container, SWT.None);
    composite.setLayout(new GridLayout(1, false));
    GridData gd_composite = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_composite.heightHint = 595;
    gd_composite.widthHint = 281;
    composite.setLayoutData(gd_composite);

    final ScrolledComposite scrolledComposite = new ScrolledComposite(composite, SWT.BORDER | SWT.V_SCROLL);
    GridData gd_scrolledComposite = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_scrolledComposite.heightHint = 542;
    gd_scrolledComposite.widthHint = 240;
    scrolledComposite.setLayoutData(gd_scrolledComposite);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);

    final ExpandBar expandBar = new ExpandBar(scrolledComposite, SWT.NONE);
    expandBar.setLayoutData(new RowData(200, 550));

    for (int i = 0; i < inputPortValue; i++) {
        if (joinMappingGrid != null) {
            if (joinMappingGrid.getLookupInputProperties() != null
                    && !joinMappingGrid.getLookupInputProperties().isEmpty()) {
                if (i < joinMappingGrid.getLookupInputProperties().size())
                    joinInputList = joinMappingGrid.getLookupInputProperties().get(i);
                else
                    joinInputList = new ArrayList<>();
            } else {
                joinInputList = new ArrayList<>();
            }
        }
        if (joinInputSchemaList != null) {
            joinInputSchemaList.add(joinInputList);
        }
        expandItemComposite = (Composite) createComposite(expandBar, joinInputList, i);
    }

    if (joinMappingGrid.getLookupMapProperties() != null
            && !joinMappingGrid.getLookupMapProperties().isEmpty()) {
        joinOutputList = joinMappingGrid.getLookupMapProperties();
    } else {
        joinOutputList = new ArrayList<>();
    }
    expandBar.getItem(0).setExpanded(true);
    expandBar.setBackground(CustomColorRegistry.INSTANCE.getColorFromRegistry(250, 250, 250));
    Listener updateScrolledSize = new Listener() {
        @Override
        public void handleEvent(Event arg0) {
            Display.getDefault().asyncExec(new Runnable() {
                @Override
                public void run() {
                    scrolledComposite.setMinSize(expandBar.computeSize(SWT.DEFAULT, SWT.DEFAULT));
                }
            });
        }
    };

    expandBar.addListener(SWT.Expand, updateScrolledSize);
    expandBar.addListener(SWT.Collapse, updateScrolledSize);
    expandBar.addKeyListener(new KeyListener() {

        @Override
        public void keyReleased(KeyEvent event) {
        }

        @Override
        public void keyPressed(KeyEvent event) {
            if (event.character == SWT.ESC) {
                close();
                event.doit = false;
            }
        }
    });
    scrolledComposite.setContent(expandBar);
    scrolledComposite.setMinSize(expandBar.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    errorLabel = new Label(composite, SWT.None);
    errorLabel.setAlignment(SWT.LEFT_TO_RIGHT);
    GridData gd_lblNewLabel_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_lblNewLabel_1.heightHint = 20;
    gd_lblNewLabel_1.widthHint = 260;
    errorLabel.setLayoutData(gd_lblNewLabel_1);
    errorLabel.setForeground(CustomColorRegistry.INSTANCE.getColorFromRegistry(255, 0, 0));
    errorLabel.setText("PropertyError");
    errorLabel.setVisible(false);
    new Label(container, SWT.NONE);

    Composite composite_1 = new Composite(container, SWT.None);
    GridData gd_composite_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_composite_1.widthHint = 398;
    gd_composite_1.heightHint = 596;
    composite_1.setLayoutData(gd_composite_1);

    Composite composite_5 = new Composite(composite_1, SWT.None);
    composite_5.setBounds(290, 4, 100, 24);
    createLabel(composite_5);

    outputTableViewer = widget.createTableViewer(composite_1, COLUMN_NAME, new int[] { 0, 30, 398, 538 }, 196,
            new JoinContentProvider(), new LookupLabelProvider());

    Label lblNewLabel = new Label(composite_1, SWT.NONE);
    lblNewLabel.setBounds(10, 11, 92, 15);
    lblNewLabel.setText("Output Mapping");
    outputTableViewer.getTable().addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDoubleClick(MouseEvent e) {
            joinOutputProperty(outputTableViewer, null);
            changeColorOfNonMappedFields();
            if (joinOutputList.size() >= 1) {
                deleteButton.setEnabled(true);
            }
            if (joinOutputList.size() >= 2) {
                upButton.setEnabled(true);
                downButton.setEnabled(true);
            }
        }

        @Override
        public void mouseDown(MouseEvent e) {
            validateDuplicatesInOutputField();
            getListOfNonMappedFields(inputFieldMap);
            changeColorOfNonMappedFields();
        }
    });
    widget.createTableColumns(outputTableViewer.getTable(), COLUMN_NAME, 196);
    CellEditor[] editors = widget.createCellEditorList(outputTableViewer.getTable(), 2);
    editors[0].setValidator(
            sourceEditorValidator(outputTableViewer, Messages.EmptySourceFieldNotification, joinOutputList));
    editors[1].setValidator(outputFieldEditorValidator(outputTableViewer, Messages.EmptySourceFieldNotification,
            joinOutputList));
    outputTableViewer.setColumnProperties(COLUMN_NAME);
    outputTableViewer.setCellModifier(new LookupCellModifier(outputTableViewer));
    outputTableViewer.setCellEditors(editors);
    outputTableViewer.setInput(joinOutputList);
    outputTableViewer.getTable().addListener(SWT.Selection, new Listener() {
        @Override
        public void handleEvent(Event event) {
            if (((TableItem) event.item) != null) {
                if (StringUtils.isNotBlank(((TableItem) event.item).getText())) {
                    String[] data = (((TableItem) event.item).getText()).split(Pattern.quote("."));
                    if (data != null && data.length == 2) {
                        FilterProperties filter = new FilterProperties();
                        filter.setPropertyname(data[1]);
                        for (int i = 0; i < inputPortValue; i++) {
                            if (joinInputSchemaList != null) {
                                if (joinInputSchemaList.get(i).contains(filter)) {
                                    ExpandItem item = expandBar.getItem(i);
                                    item.setExpanded(true);
                                    inputTableViewer[i].getTable()
                                            .setSelection(joinInputSchemaList.get(i).indexOf(filter));
                                }
                            }
                        }
                    }
                }
            }
        }
    });
    errorLabel = new Label(composite_1, SWT.None);
    errorLabel.setBounds(0, 576, 350, 25);
    errorLabel.setForeground(CustomColorRegistry.INSTANCE.getColorFromRegistry(255, 0, 0));
    errorLabel.setVisible(false);

    new Label(container, SWT.NONE);

    Composite composite_2 = new Composite(container, SWT.BORDER);
    composite_2.setLayout(new RowLayout(SWT.HORIZONTAL));
    GridData gd_composite_2 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_composite_2.heightHint = 595;
    gd_composite_2.widthHint = 133;
    composite_2.setLayoutData(gd_composite_2);

    ScrolledComposite scrolledComposite_1 = new ScrolledComposite(composite_2, SWT.BORDER | SWT.V_SCROLL);
    scrolledComposite_1.setLayoutData(new RowData(100, 564));

    Composite composite_3 = new Composite(scrolledComposite_1, SWT.BORDER);
    composite_3.setLayout(new RowLayout(SWT.VERTICAL));

    radio[0] = widget.buttonWidget(composite_3, SWT.RADIO, new int[] { 0, 0, 90, 20 }, NONE);
    for (int i = 1, k = 0; i < radio.length; i++, k++) {
        radio[i] = widget.buttonWidget(composite_3, SWT.RADIO, new int[] { 0, j, 90, 20 },
                Constants.COPY_FROM_INPUT_PORT_PROPERTY + "in" + k);
        j = j + 20;
    }
    scrolledComposite_1.setContent(composite_3);
    scrolledComposite_1.setExpandHorizontal(true);
    scrolledComposite_1.setExpandVertical(true);
    scrolledComposite_1.setMinSize(composite_3.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    for (int i = 0; i < radio.length; i++) {
        final int inPortIndex = i;
        radio[i].addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent event) {

                Button button = (Button) event.widget;
                button.getSelection();
                if (button.getSelection()) {
                    if (NONE.equalsIgnoreCase(button.getText())) {
                        outputTableViewer.getTable().setEnabled(true);
                        joinMappingGrid.setButtonText(button.getText());
                        joinMappingGrid.setIsSelected(false);
                        if (!NONE.equals(previousRadioButtonSelection)) {
                            joinOutputList.clear();
                            outputTableViewer.refresh();
                        }
                        previousRadioButtonSelection = NONE;
                    } else {
                        okButton.setEnabled(true);
                        errorLabel.setVisible(false);
                        radio[0].setSelection(false);
                        outputTableViewer.getTable().setEnabled(false);
                        joinMappingGrid.setButtonText(button.getText());
                        joinMappingGrid.setIsSelected(true);
                        addAllFieldsFromSocketId(inPortIndex - 1);
                    }
                }
            }
        });
    }
    populate();
    if (joinOutputList != null) {
        dropData(outputTableViewer, joinOutputList, true);
    }
    populatePreviousItemsOfTable();

    outputTableViewer.getTable().addMouseTrackListener(new MouseTrackListener() {

        @Override
        public void mouseHover(MouseEvent e) {
            changeColorOfNonMappedFields();
        }

        @Override
        public void mouseExit(MouseEvent e) {
            changeColorOfNonMappedFields();

        }

        @Override
        public void mouseEnter(MouseEvent e) {
            changeColorOfNonMappedFields();
        }
    });

    inputFieldMap = setMapOfInputFieldsPerPort();
    nonMappedFieldList = getListOfNonMappedFields(inputFieldMap);
    return container;
}

From source file:de.tarent.maven.plugins.pkg.AbstractMvnPkgPluginTestCase.java

protected boolean ipkDependsOn(String s) throws MojoExecutionException, IOException {
    final Pattern p = Pattern.compile("Depends:.*" + Pattern.quote(s) + ".*");
    return ipkContains(p, "--info");
}

From source file:org.jboss.as.test.integration.security.auditing.CustomAuditProviderModuleTest.java

@Test
public void testGooduser1WithBadPassword() throws Exception {
    assertResponse(CustomLoginModule1.GOODUSER1_USERNAME, "bogus", 401);
    try (BufferedReader r = Files.newBufferedReader(AUDIT_LOG_PATH, UTF_8)) {
        assertAuditLog(r, Pattern.quote("INFO  " + CustomAuditProviderModule.class.getName() + " [Failure]"));
    }//www  . j a  v  a2s  . c  o  m
}

From source file:de.tarent.maven.plugins.pkg.AbstractMvnPkgPluginTestCase.java

protected boolean debDependsOn(String s, String filename) throws MojoExecutionException, IOException {
    final Pattern p = Pattern.compile("Depends:.*" + Pattern.quote(s) + ".*");
    return debContains(p, "--info", filename);
}

From source file:net.dv8tion.jda.core.entities.impl.ReceivedMessage.java

@Override
public String getContentStripped() {
    if (strippedContent != null)
        return strippedContent;
    synchronized (mutex) {
        if (strippedContent != null)
            return strippedContent;
        String tmp = getContentDisplay();
        //all the formatting keys to keep track of
        String[] keys = new String[] { "*", "_", "`", "~~" };

        //find all tokens (formatting strings described above)
        TreeSet<FormatToken> tokens = new TreeSet<>(Comparator.comparingInt(t -> t.start));
        for (String key : keys) {
            Matcher matcher = Pattern.compile(Pattern.quote(key)).matcher(tmp);
            while (matcher.find())
                tokens.add(new FormatToken(key, matcher.start()));
        }//from  www .  j a va2  s.c  om

        //iterate over all tokens, find all matching pairs, and add them to the list toRemove
        Deque<FormatToken> stack = new ArrayDeque<>();
        List<FormatToken> toRemove = new ArrayList<>();
        boolean inBlock = false;
        for (FormatToken token : tokens) {
            if (stack.isEmpty() || !stack.peek().format.equals(token.format)
                    || stack.peek().start + token.format.length() == token.start)

            {
                //we are at opening tag
                if (!inBlock) {
                    //we are outside of block -> handle normally
                    if (token.format.equals("`")) {
                        //block start... invalidate all previous tags
                        stack.clear();
                        inBlock = true;
                    }
                    stack.push(token);
                } else if (token.format.equals("`")) {
                    //we are inside of a block -> handle only block tag
                    stack.push(token);
                }
            } else if (!stack.isEmpty()) {
                //we found a matching close-tag
                toRemove.add(stack.pop());
                toRemove.add(token);
                if (token.format.equals("`") && stack.isEmpty())
                    //close tag closed the block
                    inBlock = false;
            }
        }

        //sort tags to remove by their start-index and iteratively build the remaining string
        toRemove.sort(Comparator.comparingInt(t -> t.start));
        StringBuilder out = new StringBuilder();
        int currIndex = 0;
        for (FormatToken formatToken : toRemove) {
            if (currIndex < formatToken.start)
                out.append(tmp.substring(currIndex, formatToken.start));
            currIndex = formatToken.start + formatToken.format.length();
        }
        if (currIndex < tmp.length())
            out.append(tmp.substring(currIndex));
        //return the stripped text, escape all remaining formatting characters (did not have matching
        // open/close before or were left/right of block
        return strippedContent = out.toString().replace("*", "\\*").replace("_", "\\_").replace("~", "\\~");
    }
}

From source file:de.tor.tribes.util.parser.SOSParser.java

/**
 * [b]Dorf:[/b] [coord]454|943[/coord] [b]Wallstufe:[/b] 20 [b]Verteidiger:[/b] 18314 13982 0 18659 353 0 0 4825 0 17 0 0
 *
 * LKAV?, 20 Checkpoint (465|883) , K84 [coord]465|883[/coord] --> Ankunftszeit: 24.08.11 23:38:53:674 [player]Frank R.[/player] Ramm,
 * 31 dieBrder 02 (460|888) , K84 [coord]460|888[/coord] --> Ankunftszeit: 25.08.11 17:14:33:064 [player]Frank R.[/player]
 *
 * [b]Dorf:[/b] [coord]453|943[/coord] [b]Wallstufe:[/b] 20 [b]Verteidiger:[/b] 14998 13360 5929 14998 100 2809 260 3000 300 40 0 0
 *
 * Ramm, 22 Checkpoint (452|898) , K84 [coord]452|898[/coord] --> Ankunftszeit: 25.08.11 12:01:23:952 [player]Frank R.[/player]
 *
 * [b]Dorf:[/b] [coord]452|944[/coord] [b]Wallstufe:[/b] 20 [b]Verteidiger:[/b] 18581 13354 0 18581 410 0 0 4994 0 19 0 0
 *
 * Ramm, 42 The White Knigth 04 (448|894) , K84 [coord]448|894[/coord] --> Ankunftszeit: 25.08.11 14:46:51:846 [player]Frank R.[/player]
 *
 * ================================================ Dorf: Just4Testing (454|943) K55 Wallstufe: 20 Verteidiger: 18314 13982 0 18659 353
 * 0 0 4825 0 17 0 0//from   w w  w  . j ava  2  s  .co  m
 *
 * LKAV?, 20 Checkpoint (465|883) , K84 Just4Testing (465|883) K55 --> Ankunftszeit: 24.08.11 23:38:53:674 Frank R. Ramm, 31 dieBrder
 * 02 (460|888) , K84 Just4Testing (460|888) K55 --> Ankunftszeit: 25.08.11 17:14:33:064 Frank R.
 *
 * Dorf: Just4Testing (453|943) K55 Wallstufe: 20 Verteidiger: 14998 13360 5929 14998 100 2809 260 3000 300 40 0 0
 *
 * Ramm, 22 Checkpoint (452|898) , K84 Just4Testing (452|898) K55 --> Ankunftszeit: 25.08.11 12:01:23:952 Torridity
 *
 * Dorf: Just4Testing (452|944) K55 Wallstufe: 20 Verteidiger: 18581 13354 0 18581 410 0 0 4994 0 19 0 0
 *
 * Ramm, 42 The White Knigth 04 (448|894) , K84 Just4Testing (448|894) K55 --> Ankunftszeit: 25.08.11 14:46:51:846 Torridity
 *
 */
private HashMap<Tribe, SOSRequest> parseRequestsShort(String pData) {
    String[] lines = pData.split("\n");
    HashMap<Tribe, SOSRequest> requests = new HashMap<>();
    Village destination = null;
    SOSRequest request = null;
    SimpleDateFormat dateFormat = null;

    boolean useMillis = ServerSettings.getSingleton().isMillisArrival();
    if (!useMillis) {
        dateFormat = new SimpleDateFormat(getVariable("sos.date.format"));
    } else {
        dateFormat = new SimpleDateFormat(getVariable("sos.date.format.ms"));
    }

    for (String line : lines) {
        // System.out.println("L " + line);
        String usedLine = line.trim();
        if (usedLine.contains(getVariable("sos.short.village"))) {
            print("Village line '" + usedLine + "'");
            if (request != null && destination != null) {
                print("Store last request");
                requests.put(destination.getTribe(), request);
            }

            destination = VillageParser.parseSingleLine(usedLine);
            //check if there is a village in the line
            if (destination != null) {
                print("Destination: " + destination);
                //check for existing request
                request = requests.get(destination.getTribe());

                if (request == null) {
                    print("New request");
                    //create new request
                    request = new SOSRequest(destination.getTribe());
                    requests.put(destination.getTribe(), request);
                }
                print("Adding target " + destination);
                request.addTarget(destination);
            }
        }

        if (destination != null) {
            print("Check destination in '" + usedLine + "'");
            if (usedLine.contains(getVariable("sos.short.wall.level"))) {
                print("Check wall in line '" + usedLine + "'");
                String wallSplit[] = usedLine.split(" ");
                if (wallSplit != null && wallSplit.length >= 2) {
                    print("Check for valid wall");
                    try {
                        Integer wall = Integer.parseInt(wallSplit[wallSplit.length - 1]);
                        print("Wall: " + wall);
                        request.getTargetInformation(destination).setWallLevel(wall);
                    } catch (Exception e) {
                        print("Failed to get Wall " + e.getMessage());
                    }
                } else {
                    print("Invalid wall entry '" + Arrays.toString(wallSplit) + "'");
                }
            } else if (usedLine.contains(getVariable("sos.short.defender"))) {
                print("Get units from line '" + usedLine + "'");
                int[] units = parseUnits(usedLine);
                if (units.length != 0) {
                    print("Valid units, add to destination");
                    int cnt = 0;
                    for (UnitHolder unit : DataHolder.getSingleton().getUnits()) {
                        request.getTargetInformation(destination).addTroopInformation(unit, units[cnt]);
                        cnt++;
                    }
                }
            } else if (usedLine.contains("-->")) {
                //got attack?
                print("Check attack in line '" + usedLine + "'");
                String[] attackSplit = usedLine.split(getVariable("sos.short.movement"));
                if (attackSplit != null && attackSplit.length >= 2) {
                    print("Try to get attacker in split '" + attackSplit[0]);
                    Village source = VillageParser.parseSingleLine(attackSplit[0]);
                    if (source != null) {
                        print("Got source");
                        Date arrive = null;
                        UnitHolder unit = null;
                        boolean fake = false;
                        unit = guessUnit(attackSplit[0].replaceAll(Pattern.quote(source.getName()), ""));
                        fake = markedAsFake(attackSplit[0].replaceAll(Pattern.quote(source.getName()), ""));

                        try {
                            String[] arriveSplit = attackSplit[1].trim().split(" ");
                            if (arriveSplit != null && arriveSplit.length >= 4) {
                                print("Try to check arrive time");
                                String arriveValue = arriveSplit[1] + " " + arriveSplit[2];
                                // System.out.println("AV " + arriveValue);
                                arrive = dateFormat.parse(arriveValue);
                                // System.out.println("HAVE AR ");
                                if (!useMillis) {//add current millis to be able to compare times
                                    //    System.out.println("ADD CM");
                                    arrive = new Date(arrive.getTime()
                                            + Calendar.getInstance().get(Calendar.MILLISECOND));
                                }
                            } else {
                                print("Invalid arrive '" + attackSplit[1]);
                            }
                        } catch (Exception e) {
                            print("Failed to parse date (" + e.getMessage() + ")");
                            // e.printStackTrace();
                        }
                        if (arrive != null) {
                            try {
                                //  System.out.println("T " + dateFormat.format(arrive));
                                if (unit != null && unit.getPlainName().equals("ag")) {
                                    request.getTargetInformation(destination).addAttack(source, arrive, unit,
                                            false, true);
                                } else if (fake) {
                                    request.getTargetInformation(destination).addAttack(source, arrive, unit,
                                            true, false);
                                } else {
                                    request.getTargetInformation(destination).addAttack(source, arrive, unit);
                                }
                            } catch (Throwable t) {
                                logger.info(
                                        "Failed to add attack with unit. Using old target information format");
                                //old target information format!?
                                request.getTargetInformation(destination).addAttack(source, arrive);
                            }
                        }
                    }
                } else {
                    print("Invalid split");
                }
            }
        }
    }

    if (request != null && destination != null) {
        print("Store last request");
        requests.put(destination.getTribe(), request);
    }
    return requests;
}