Package org.structr.common.error

Examples of org.structr.common.error.FrameworkException


      // notify listener
      context.transmissionFinished();

    } catch (IOException  ioex) {

      throw new FrameworkException(504, "Unable to connect to remote server: " + ioex.getMessage());

    } finally {

      if (client != null) {
        client.close();
View Full Code Here


      importer.createChildNodes(parent, page);

    } else {

      // report error to ui
      throw new FrameworkException(422, errorBuffer);
    }
  }
View Full Code Here

      final App app                     = StructrApp.getInstance();
      final String fileName             = (String)attributes.get("name");

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

        throw new FrameworkException(400, "Please specify name.");
      }

      try (final Tx tx = app.tx()) {

        final File file = FileHelper.createFile(securityContext, new byte[0], "application/zip", File.class, fileName);

        // make file visible for auth. users
        file.setProperty(File.visibleToAuthenticatedUsers, true);

        // Don't include files
        SyncCommand.exportToStream(file.getOutputStream(), app.nodeQuery(NodeInterface.class).getAsList(), app.relationshipQuery(RelationshipInterface.class).getAsList(), null, false);

        tx.success();
      }

    } catch (Throwable t) {

      throw new FrameworkException(500, t.getMessage());
    }
  }
View Full Code Here

        return new Result(entries, entries.size(), true, false);
      }
    }

    // no request object, this is fatal
    throw new FrameworkException(500, "No request object present, aborting.");
  }
View Full Code Here

          return new RestMethodResult(200);

        } catch (IOException ioex) {

          ioex.printStackTrace();
          throw new FrameworkException(500, ioex.getMessage());
        }

      } else {

        final ErrorBuffer errorBuffer = new ErrorBuffer();

        if (StringUtils.isEmpty(subjectId)) {
          errorBuffer.add("LogFile", new EmptyPropertyToken(subjectProperty));
        }

        if (StringUtils.isEmpty(objectId)) {
          errorBuffer.add("LogFile", new EmptyPropertyToken(objectProperty));
        }

        if (StringUtils.isEmpty(action)) {
          errorBuffer.add("LogFile", new EmptyPropertyToken(actionProperty));
        }

        throw new FrameworkException(422, errorBuffer);
      }
    }

    // no request object, this is fatal
    throw new FrameworkException(500, "No request object present, aborting.");
  }
View Full Code Here

      try {
        Collections.sort(result.getResults(), new GraphObjectComparator(sortKey, sortOrder));
       
      } catch(Throwable t) {
       
        throw new FrameworkException("base", new InvalidSortKey(sortKey));
      }

      return result;
    }
View Full Code Here

         
        } catch (DOMException dex) {
         
          dex.printStackTrace();
         
          throw new FrameworkException(422, dex.getMessage());
        }
      }
     
    } catch (FrameworkException fex) {
   
View Full Code Here

        // create error
        if (doValidation) {

          tx.failure();

          throw new FrameworkException(422, errorBuffer);
        }
      }
     
      // 1.5: execute validatable post-transaction action
      if (doValidation && !modificationQueue.doPostProcessing(securityContext, errorBuffer)) {

        tx.failure();

        throw new FrameworkException(422, errorBuffer);
      }

      // 2. fetch all types of entities modified in this tx
      Set<String> synchronizationKeys = modificationQueue.getSynchronizationKeys();

      // we need to protect the validation and indexing part of every transaction
      // from being entered multiple times in the presence of validators
      // 3. acquire semaphores for each modified type
      try { semaphore.acquire(synchronizationKeys); } catch (InterruptedException iex) { return; }

      // finally, do validation under the protection of the semaphores for each type
      if (!modificationQueue.doValidation(securityContext, errorBuffer, doValidation)) {

        tx.failure();

        // release semaphores as the transaction is now finished
        semaphore.release(synchronizationKeys)// careful: this can be null

        // create error
        throw new FrameworkException(422, errorBuffer);
      }

      try {
        tx.success();
View Full Code Here

      } catch (NotFoundException nfe) {

        logger.log(Level.WARNING, "Node with id {0} not found in database!", id);

        throw new FrameworkException("FindRelationshipCommand", new IdNotFoundToken(id));
      }
    }

    return null;
  }
View Full Code Here

    if (propertyContainer != null) {

      if (!TransactionCommand.inTransaction()) {

        logger.log(Level.SEVERE, "setProperty outside of transaction");
        throw new FrameworkException(500, "setProperty outside of transaction.");
      }

      // notify only non-system properties
      if (!unvalidated) {

        // collect modified properties
        if (obj instanceof AbstractNode) {

          TransactionCommand.nodeModified(
            (AbstractNode)obj,
            AbstractPrimitiveProperty.this,
            propertyContainer.hasProperty(dbName()) ? propertyContainer.getProperty(dbName()) : null,
            value
          );

        } else if (obj instanceof AbstractRelationship) {

          TransactionCommand.relationshipModified(
            (AbstractRelationship)obj,
            AbstractPrimitiveProperty.this,
            propertyContainer.hasProperty(dbName()) ? propertyContainer.getProperty(dbName()) : null,
            value
          );
        }
      }

      // catch all sorts of errors and wrap them in a FrameworkException
      try {
       
        // save space
        if (convertedValue == null) {

          propertyContainer.removeProperty(dbName());

        } else {

          // Setting last modified date explicetely is not allowed
          if (!AbstractPrimitiveProperty.this.equals(AbstractNode.lastModifiedDate)) {

            propertyContainer.setProperty(dbName(), convertedValue);

            // set last modified date if not already happened
            propertyContainer.setProperty(AbstractNode.lastModifiedDate.dbName(), System.currentTimeMillis());

          } else {

            logger.log(Level.FINE, "Tried to set lastModifiedDate explicitly (action was denied)");

          }
        }
       
      } catch (Throwable t) {
       
        t.printStackTrace();
       
        // throw FrameworkException with the given cause
        throw new FrameworkException(500, t);
      }

      if (isIndexed()) {

        // do indexing, needs to be done after
View Full Code Here

TOP

Related Classes of org.structr.common.error.FrameworkException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.