示例#1
0
 @Override
 protected RunTransactionalReturnData runTransactional() throws Exception {
   PrivateSignatory authorizer;
   if (statement instanceof RootContext) {
     if (!delegate.equals(statementAuthority.getAuthor(getTransaction())))
       throw new SignCommandException("Not the author");
     authorizer = delegate.getPrivateSignatory(getTransaction());
   } else {
     StatementAuthority parentAuth =
         statement.getContext(getTransaction()).getAuthority(getTransaction());
     Identifier identifier = statement.getIdentifier();
     Namespace namespace = identifier == null ? RootNamespace.instance : identifier;
     DelegateAuthorizer da =
         parentAuth.delegateAuthorizerMap(getTransaction(), namespace).get(delegate);
     if (da == null) throw new SignCommandException("Not a delegate");
     Signatory authorizer_ = da.getAuthorizer(getTransaction());
     if (authorizer_ == null) {
       authorizer = da.createAuthorizer(getTransaction());
       da.sign(getTransaction());
       da.persistenceUpdate(getTransaction());
     } else {
       if (!(authorizer_ instanceof PrivateSignatory))
         throw new SignCommandException(
             "Haven't got private data for this authorizer. Maybe try entering the passphrase?");
       authorizer = (PrivateSignatory) authorizer_;
     }
   }
   statementAuthority.createSignature(getTransaction(), authorizer);
   return null;
 }
  public AuthorityHeaderJPanel(
      AuthorityJPanel authorityJPanel, StatementAuthority statementAuthority) {
    super();
    this.authorityJPanel = authorityJPanel;
    this.statementAuthority = statementAuthority;
    GridBagLayout gridBagLayout = new GridBagLayout();
    setLayout(gridBagLayout);
    setBackground(Color.white);
    Transaction transaction = getPersistenceManager().beginTransaction(transactionTimeOut);
    try {
      Insets insets = new Insets(0, 0, 0, 10);
      {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.insets = insets;
        gbc.anchor = GridBagConstraints.WEST;
        add(new BoldTextLabelRenderer("Author"), gbc);
      }
      {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.insets = insets;
        gbc.anchor = GridBagConstraints.WEST;
        add(new PersonLabelRenderer(statementAuthority.getAuthor(transaction)), gbc);
      }
      {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.insets = insets;
        gbc.anchor = GridBagConstraints.WEST;
        add(new BoldTextLabelRenderer("Created"), gbc);
      }
      {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 1;
        gbc.insets = insets;
        gbc.anchor = GridBagConstraints.WEST;
        add(new DateLabelRenderer(statementAuthority.getCreationDate()), gbc);
      }
      {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 2;
        gbc.insets = insets;
        gbc.anchor = GridBagConstraints.WEST;
        add(new BoldTextLabelRenderer("Status"), gbc);
      }
      {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 2;
        gbc.insets = insets;
        gbc.anchor = GridBagConstraints.WEST;
        add(new SignatureStatusLabelRenderer(statementAuthority.signatureStatus()), gbc);
      }
      Statement statement = statementAuthority.getStatement(transaction);
      if (statement != null) {
        this.dependenciesListJTable =
            new MyStatementListJTable(
                "Dependencies", new BufferedList<>(statement.dependencies(transaction)));
        {
          GridBagConstraints gbc = new GridBagConstraints();
          gbc.gridx = 2;
          gbc.gridy = 0;
          gbc.gridheight = 4;
          gbc.insets = insets;
          gbc.anchor = GridBagConstraints.WEST;
          gbc.fill = GridBagConstraints.BOTH;
          JScrollPane depPane = new JScrollPane(this.dependenciesListJTable);
          add(depPane, gbc);
          this.dependenciesListFocusBorderManager =
              new FocusBorderManager(depPane, dependenciesListJTable);
        }
        if (statement instanceof Context) {
          Context context = (Context) statement;
          this.solverListJTable =
              new MyStatementListJTable(
                  "Solvers", new BufferedList<>(context.solvers(transaction)));
          {
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.gridx = 3;
            gbc.gridy = 0;
            gbc.gridheight = 4;
            gbc.insets = insets;
            gbc.anchor = GridBagConstraints.WEST;
            gbc.fill = GridBagConstraints.BOTH;
            JScrollPane solPane = new JScrollPane(this.solverListJTable);
            add(solPane, gbc);
            this.solverListFocusBorderManager = new FocusBorderManager(solPane, solverListJTable);
          }
        } else {
          this.solverListJTable = null;
          this.solverListFocusBorderManager = null;
        }
        DelegateTreeRootNode delegateTreeRootNode =
            statementAuthority.getDelegateTreeRootNode(transaction);
        if (delegateTreeRootNode != null && !delegateTreeRootNode.successorEntries().isEmpty()) {

          {
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.gridx = 4;
            gbc.gridy = 0;
            gbc.gridheight = 4;
            gbc.insets = insets;
            gbc.anchor = GridBagConstraints.WEST;
            gbc.fill = GridBagConstraints.BOTH;
            JLabel label = new JLabel("             ");
            label.setFont(FontManager.instance.defaultFont());
            add(label, gbc);
          }
          this.successorListJTable =
              new SuccessorsJTable(getPersistenceManager(), delegateTreeRootNode);
          {
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.gridx = 5;
            gbc.gridy = 0;
            gbc.gridheight = 4;
            gbc.insets = insets;
            gbc.anchor = GridBagConstraints.WEST;
            gbc.fill = GridBagConstraints.BOTH;
            JScrollPane sucPane = new JScrollPane(this.successorListJTable);
            add(sucPane, gbc);
            this.successorListFocusBorderManager =
                new FocusBorderManager(sucPane, successorListJTable);
          }
        } else {
          this.successorListJTable = null;
          this.successorListFocusBorderManager = null;
        }
      } else {
        this.dependenciesListJTable = null;
        this.dependenciesListFocusBorderManager = null;
        this.solverListJTable = null;
        this.solverListFocusBorderManager = null;
        this.successorListJTable = null;
        this.successorListFocusBorderManager = null;
      }

    } finally {
      transaction.abort();
    }
  }