Java 类javax.ejb.CreateException 实例源码

项目:swan    文件:Service.java   
/**
 * Removes a scheme.
 * 
 * @param schemeId
 * @throws CreateException is thrown when the scheme references projects
 */
public void removeScheme(Long schemeId) throws CreateException {

    try {
        Scheme scheme = (Scheme) schemeDAO.find(schemeId, false);
        Set<Project> projectList = scheme.getProjects();

        if (!projectList.isEmpty()) {
            throw new CreateException("Service: The scheme references projects.");
        }

        schemeDAO.remove(scheme);
    } catch (NoResultException e) {
        throw new CreateException(e.getMessage());
    }
}
项目:swan    文件:Service.java   
public Annotation changeSpanType(Long annoId, SpanType spanType) throws CreateException {

        try {
            Annotation anno = (Annotation) annotationDAO.find(annoId, false);
            updateDocument(anno.getDocument(), anno.getUser());

            spanType = (SpanType) spanTypeDAO.find(spanType.getId(), false);

            anno.setSpanType(spanType);

            // Delete all links connected to the Annotation
            List<Link> linkList = linkDAO.getAllLinksByAnnoId(annoId);

            for (Link l : linkList) {
                linkDAO.remove(l);
            }

            annotationDAO.merge(anno);

            return anno;
        } catch (NoResultException e) {
            throw new CreateException(e.getMessage());
        }
    }
项目:libreacs    文件:DataModelBean.java   
public java.lang.String ejbCreate(java.lang.String name, String type,
        long min, long max, int length, String description, String version,
        String def, boolean writable, String trname) throws CreateException {
    if (name == null) {
        throw new CreateException("The field \"name\" must not be null");
    }
    if (type == null) {
        throw new CreateException("The field \"name\" must not be null");
    }

    // TODO add additional validation code, throw CreateException if data is not valid
    setName(name);
    setType(type);
    setMin(min);
    setMax(max);
    setLength(length);
    setDescription(description.getBytes());
    setVersion(version);
    setDefaultvalue(def);
    setWritable(writable);
    setTrname(trname);

    return null;

}
项目:sistra    文件:PadAplicacionFacadeEJB.java   
/**
   * @ejb.create-method
   * @ejb.permission role-name="${role.todos}"
   * @ejb.permission role-name="${role.auto}"
   */
  public void ejbCreate() throws CreateException 
  {
      super.ejbCreate();
      try{
    InitialContext initialContext = new InitialContext();            
    roleAuto = (( String ) initialContext.lookup( "java:comp/env/roleAuto" ));          
    roleDelegacion = (( String ) initialContext.lookup( "java:comp/env/roleDelegacion" ));
    roleHelpdesk = (( String ) initialContext.lookup( "java:comp/env/roleHelpdesk" ));
    roleGestor = (( String ) initialContext.lookup( "java:comp/env/roleGestor" ));

    // Obtenemos prefijo para alta automatica
        String prefijo = ConfigurationUtil.getInstance().obtenerPropiedades().getProperty("usuario.prefijoAuto");
        if (StringUtils.isBlank(prefijo)) {
            throw new Exception("No se ha configurado prefijo para el alta automatica de usuario");
        }
        prefijoAuto = StringUtils.trim(prefijo);            
}catch(Exception ex){
    log.error(ex);
}
  }
项目:swan    文件:Service.java   
public void process(Users currUser, Users newUser) throws CreateException {

    // Check user roles
    List<Users.RoleType> allowedRoles = userPermissionMap.get(currUser.getRole());
    if (!allowedRoles.contains(newUser.getRole())) {
        throw new CreateException("Service: The requested user role is not allowed.");
    }

    Set<Project> proSet = new HashSet<>();
    for (Project p : newUser.getProjects()) {
        Project proj = (Project) projectDAO.find(p.getId(), false);
        proSet.add(proj);
    }
    newUser.setProjects(proSet);
    newUser.setCreateDate(Utility.getCurrentTime());
    newUser.setPassword(
            Utility.hashPassword(
                    newUser.getPassword()));
}
项目:swan    文件:Service.java   
public void removeUserFromProject(Long projId, Long userId) throws CreateException {
    try {
        Project proj = (Project) projectDAO.find(projId, false);
        Users user = (Users) usersDAO.find(userId, false);

        proj.removeUsers(user);
        user.removeProject(proj);

        removeStatesFromProject(proj, user);

        projectDAO.merge(proj);
        usersDAO.merge(user);
    } catch (NoResultException e) {
        throw new CreateException(e.getMessage());
    }
}
项目:sistra    文件:InstanciaProcessorEJB.java   
/**
 * Prepara una nueva instancia con los datos guardados.
 * @ejb.create-method
 */
public void ejbCreate(InstanciaBean bean) throws CreateException {
    ejbCreate(bean.getModelo(), bean.getLocale(), bean.getPerfil(), bean.getVersion());
    for (int i = 0; i < bean.getDataMaps().size(); i++) {
        Map map = (Map) bean.getDataMaps().get(i);
        if (map == null) {
            throw new CreateException("Encontrado DataMap nulo en InstanciaBean");
        }
        introducirDatosPantalla(map);
        avanzarPantalla();
    }
    // Dejar la ultima pantalla en la que se habia estado.
    retrocederPantalla();
    // Afegir anexos.
    anexos.putAll(bean.getAnexos());
}
项目:libreacs    文件:HostPropertyBean.java   
public HostPropertyPK ejbCreate(Integer parentId, String name, String value) throws CreateException {
    if (parentId == null) {
        throw new CreateException("The field \"parentId\" must not be null");
    }
    if (name == null) {
        throw new CreateException("The field \"name\" must not be null");
    }

    setParentId(parentId);
    setName(name);
    setValue(value);

    return null;
}
项目:libreacs    文件:DSLStatsBean.java   
public org.openacs.DSLStatsPK ejbCreate(Integer hostid, Timestamp time) throws CreateException {
    if (hostid == null) {
        throw new CreateException("The field \"hostid\" must not be null");
    }
    if (time == null) {
        throw new CreateException("The field \"time\" must not be null");
    }

    setHostid(hostid);
    setTime(time);

    return null;
}
项目:swan    文件:Service.java   
/**
 * Removes a label from an annotation.
 * The Label must exist in the annotation otherwise an
 * IllegalArgumentException will be thrown.
 * 
 * @param anno
 * @param label 
 */
public void removeLabelFromAnnotation(Annotation anno, Label label) throws CreateException {

    Set<Label> labels = anno.getLabels();

    if (!labels.contains(label)) {
        throw new CreateException("Service: Label does not exist in Annotation.");
    }

    anno.removeLabel(label);
    annotationDAO.merge(anno);
    return;
}
项目:sistra    文件:EntradaPreregistroFacadeEJB.java   
/**
    * @ejb.create-method
    * @ejb.permission role-name="${role.todos}"
    * @ejb.permission role-name="${role.auto}"
    */
public void ejbCreate() throws CreateException {
    super.ejbCreate();
    try{
        InitialContext initialContext = new InitialContext();            
        roleHelpDesk = (( String ) initialContext.lookup( "java:comp/env/roleHelpDesk" ));  
        roleRegistro = (( String ) initialContext.lookup( "java:comp/env/roleRegistro" ));      
        roleGestor = (( String ) initialContext.lookup( "java:comp/env/roleGestor" ));
    }catch(Exception ex){
        log.error(ex);
    }
}
项目:libreacs    文件:ATMErrorsStatsLocalHome.java   
org.openacs.ATMErrorsStatsLocal create(Integer hostid, Timestamp time, int type,
Timestamp intervalStart,
Long ATUCCRCErrors, Long ATUCFECErrors, Long ATUCHECErrors, Long CellDelin,
Long CRCErrors, Long FECErrors, Long HECErrors, Long ErroredSecs,
Long InitErrors, Long InitTimeouts, Long LinkRetrain, Long LossOfFraming,
Long ReceiveBlocks, Long SeverelyErroredSecs, Long TransmitBlocks,
Long LossOfPower, Long LossOfSignal) throws CreateException;
项目:libreacs    文件:SoftwareJsfBean.java   
public String Create() {
    System.out.println("Software.Create: hwid=" + hwid + " version=" + version + " filename=" + filename);
    try {
        SoftwareLocal s = Ejb.lookupSoftwareBean().create(hwid, version, null, null);
        File f = new File(getFwPath() + filename);
        s.setFilename(filename);
        s.setSize(f.length());
    } catch (CreateException ex) {
        setErrorMessage(ex.getMessage());
        return null;
    }
    return "swcreated";
}
项目:swan    文件:LinkFacadeREST.java   
@POST
@Consumes({MediaType.APPLICATION_JSON})
public Response create(Link entity) {

    try {
        LoginUtil.check(usersDAO.checkLogin(getSessionID(), Users.RoleType.annotator));
        service.process(entity);
        return usersDAO.create(entity);
    } catch (SecurityException e) {
        return Response.status(Response.Status.FORBIDDEN).build();
    } catch (CreateException ex) {
        return Response.status(Response.Status.BAD_REQUEST).build();
    }

}
项目:swan    文件:Service.java   
public void removeProjectManagerFromProject(Long projId, Long userId) throws CreateException {
    try {
        Project proj = (Project) projectDAO.find(projId, false);
        Users user = (Users) usersDAO.find(userId, false);

        proj.removeProjectManager(user);
        user.removeManagingProjects(proj);

        projectDAO.merge(proj);
        usersDAO.merge(user);
    } catch (NoResultException e) {
        throw new CreateException(e.getMessage());
    }
}
项目:sistra    文件:TramitePersistenteFacadeEJB.java   
/**
    * @ejb.create-method
    * @ejb.permission role-name="${role.auto}"
    * @ejb.permission role-name="${role.todos}"
    */
public void ejbCreate() throws CreateException {
    super.ejbCreate();
    try{
        InitialContext initialContext = new InitialContext();            
        roleAuto = (( String ) initialContext.lookup( "java:comp/env/roleAuto" ));      
        roleHelpdesk = (( String ) initialContext.lookup( "java:comp/env/roleHelpdesk" ));
    }catch(Exception ex){
        log.error(ex);
    }           
}
项目:swan    文件:ProjectsTest.java   
public Annotation testAddAnnotation2(Document doc, Users user, LabelSet labelSet) throws CloneNotSupportedException, CreateException {

    Annotation anno = TestDataProvider.getAnnotation2();

    SpanType spanType = anno.getSpanType();
    persistAndFlush(spanType);
    anno.setSpanType(spanType);

    anno.setUser(user);
    anno.setDocument(doc);
    service.process(anno);
    persistAndFlush(anno);

    Annotation retAnno = em.find(Annotation.class, anno.getId());
    assertNotNull(retAnno);
    assertTrue(retAnno.isNotSure());
    assertTrue(retAnno.getText().equals("the"));
    assertTrue(retAnno.getDocument().getId().equals(doc.getId()));
    assertTrue(retAnno.getUser().getId().equals(user.getId()));
    assertTrue(retAnno.getStart() == 65);
    assertTrue(retAnno.getEnd() == 68);
    assertTrue(retAnno.getLabels().isEmpty());
    assertTrue(retAnno.getSpanType().getName().equals("passage"));

    // Add label to annotation 1
    Label label = TestDataProvider.getLabel1();
    label.setLabelSet(labelSet);
    persistAndFlush(label);
    service.addLabelToAnnotation(retAnno.getId(), label);

    Set<Label> labels = retAnno.getLabels();
    Object[] labelArr = labels.toArray();
    Label newLabel = (Label) labelArr[0];

    assertTrue(labels.size() == 1);
    assertTrue(newLabel.getName().equals(label.getName()));

    return anno;
}
项目:swan    文件:Service.java   
public Response resetUserPassword(Users entity) throws CreateException {
    try {
        Users user = usersDAO.find(entity.getId(), false);
        String newPwd = Utility.getRandomString(14);
        String hashedPwd = Utility.hashPassword(newPwd);

        emailProvider.sendPasswordResetNotification(user, newPwd);

        user.setPassword(hashedPwd);
        return usersDAO.merge(user);
    } catch (NoResultException e) {
        throw new CreateException(e.getMessage());
    }
}
项目:libreacs    文件:ScriptJsfBean.java   
public String Create() {
//        System.out.println ("ScriptJsfBean.Create () name="+name);
        try {
            ScriptLocal s = Ejb.lookupScriptBean().create(name);
            s.setDescription(description);
            s.setScript(text.getBytes());
        } catch (CreateException ex) {
            Logger.getLogger(ScriptJsfBean.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }
项目:swan    文件:Service.java   
public void process(Link entity) throws CreateException {
    try {
        Users user = (Users) usersDAO.find(entity.getUser().getId(), false);
        entity.setUser(user);

        Document doc = (Document) documentDAO.find(entity.getDocument().getId(), false);
        entity.setDocument(doc);
        updateDocument(doc, user);

        // Annotation 1
        Annotation anno1 = entity.getAnnotation1();
        if (anno1.getId() == null) { // does not exist already
            process(anno1);
        } else {
            anno1 = (Annotation) annotationDAO.find(entity.getAnnotation1().getId(), false);
        }
        entity.setAnnotation1(anno1);

        // Annotation 2
        Annotation anno2 = entity.getAnnotation2();
        if (anno2.getId() == null) { // does not exist already
            process(anno2);
        } else {
            anno2 = (Annotation) annotationDAO.find(entity.getAnnotation2().getId(), true);
        }
        entity.setAnnotation2(anno2);

        Set<LinkLabel> linkLabels = new HashSet<>();
        for (LinkLabel l : entity.getLinkLabels()) {
            LinkLabel newLabel = (LinkLabel) linkLabelDAO.find(l.getId(), false);
            linkLabels.add(newLabel);
        }
        entity.setLinkLabels(linkLabels);

    } catch (NoResultException e) {
        throw new CreateException(e.getMessage());
    }
}
项目:libreacs    文件:DeviceProfileBean.java   
public String AddFw() {
//        System.out.println("DeviceProfileBean.AddFw name="+name+" hwid="+hwid+" version="+version);
        DeviceProfile2SoftwareLocalHome h = Ejb.lookupDeviceProfile2SoftwareBean();
        try {
            h.create(name, hwid, version);
        } catch (CreateException ex) {
            setErrorMessage(ex.getMessage());
        }
        return null;
    }
项目:sistra    文件:TramiteBandejaFacadeEJB.java   
/**
    * @ejb.create-method
    * @ejb.permission role-name="${role.admin}"
    * @ejb.permission role-name="${role.todos}"
    * @ejb.permission role-name="${role.gestor}"
    * @ejb.permission role-name="${role.auto}"
    */
public void ejbCreate() throws CreateException {
    super.ejbCreate();

    try {
        InitialContext ctx = new InitialContext();
        ROLE_AUTO = (String) ctx.lookup("java:comp/env/roleAuto");
    } catch (NamingException e) {
        throw new CreateException("No se ha especificado role auto");
    }


}
项目:sistra    文件:BteFacadeEJB.java   
/**
    * @ejb.create-method
    * @ejb.permission role-name="${role.gestor}"
    * @ejb.permission role-name="${role.auto}"
    */
public void ejbCreate() throws CreateException {    
    try
    {
        javax.naming.InitialContext initialContext = new javax.naming.InitialContext();
        roleAuto = ( String ) initialContext.lookup( "java:comp/env/role.auto" );
    }
    catch( Exception exc )
    {
        exc.printStackTrace();
    }
}
项目:sistra    文件:ConsultaPADEJB.java   
/**
    * @ejb.create-method
    * @ejb.permission role-name="${role.todos}"
    * @ejb.permission role-name="${role.auto}"
    */
public void ejbCreate() throws CreateException {
    log.info("ejbCreate: " + this.getClass());
    try
    {
        javax.naming.InitialContext initialContext = new javax.naming.InitialContext();

        ROLE_AUTO = (String) initialContext.lookup( "java:comp/env/roleAuto" );         
    }
    catch( Exception exc )
    {           
        log.error( exc );
        throw new CreateException( exc.getLocalizedMessage() );
    }
}
项目:swan    文件:Service.java   
public void reimportProject(InputStream is) throws CreateException {
    try {

    } catch (NoResultException e) {
        throw new CreateException(e.getMessage());
    }
}
项目:libreacs    文件:SoftwareDetailBean.java   
public org.openacs.SoftwareDetailPK ejbCreate(Integer hwid, String version, byte[] paramNames, byte[] methods) throws CreateException {
    setHwid(hwid);
    setVersion(version);
    setParamNames(paramNames);
    setMethods(methods);
    return null;
}
项目:swan    文件:TimeLoggingFacadeREST.java   
@POST
@Consumes({MediaType.APPLICATION_JSON})
public Response create(TimeLogging entity) {

    try {
        LoginUtil.check(usersDAO.checkLogin(getSessionID()));
        service.process(entity);
        return usersDAO.create(entity);
    } catch (SecurityException e) {
        return Response.status(Response.Status.FORBIDDEN).build();
    } catch (CreateException ex) {
        return Response.status(Response.Status.BAD_REQUEST).build();
    }

}
项目:libreacs    文件:OuiMapBean.java   
public java.lang.String ejbCreate(String oui, String mappedoui) throws CreateException {
    if (oui == null) {
        throw new CreateException("The field \"oui\" must not be null");
    }

    setOui(oui);
    setMappedoui(mappedoui);

    return null;
}
项目:libreacs    文件:DeviceProfileBean.java   
public String create() {
    try {
        save(Ejb.lookupDeviceProfileBean().create(name));
        return "created";
    } catch (CreateException ex) {
        setErrorMessage(ex.getMessage());
    }
    return null;
}
项目:sistra    文件:ConsultaPADEJB.java   
/**
    * @ejb.create-method
    * @ejb.permission role-name="${role.todos}"
    * @ejb.permission role-name="${role.auto}"
    */
public void ejbCreate() throws CreateException {
    log.info("ejbCreate: " + this.getClass());
    try
    {
        javax.naming.InitialContext initialContext = new javax.naming.InitialContext();

        ROLE_AUTO = (String) initialContext.lookup( "java:comp/env/roleAuto" );         
    }
    catch( Exception exc )
    {           
        log.error( exc );
        throw new CreateException( exc.getLocalizedMessage() );
    }
}
项目:libreacs    文件:ATMErrorsStatsBean.java   
public org.openacs.ATMErrorsStatsPK ejbCreate(Integer hostid, Timestamp time, int type) throws CreateException {
    setHostid(hostid);
    setTime(time);
    setType(type);

    return null;
}
项目:libreacs    文件:Application.java   
public static void setFirmwarePath(String firmwarePath) throws CreateException {
    app.firmwarePath = firmwarePath;
    app.setProperty(PROPERTY_FIRMWAREPATH, firmwarePath);
}
项目:sistra    文件:PantallaDelegate.java   
private PantallaFacade getFacade() throws NamingException,CreateException,RemoteException {
    return PantallaFacadeUtil.getHome().create();
}
项目:swan    文件:Service.java   
public void process(Document entity) throws CreateException {
    Project project = (Project) projectDAO.find(entity.getProject().getId(), false);
    entity.setProject(project);
    process(entity.getDefaultAnnotations());
}
项目:sistra    文件:ExpedienteDelegate.java   
private ExpedienteFacade getFacade() throws NamingException,CreateException,RemoteException
{
    return ExpedienteFacadeUtil.getHome( ).create();
}
项目:sistra    文件:ConfiguracionDelegate.java   
private ConfiguracionFacadeLocal getFacade() throws NamingException,RemoteException,CreateException {               
    return ConfiguracionFacadeUtil.getLocalHome().create();
}
项目:sistra    文件:AuditaDelegate.java   
private AuditaFacade getFacade() throws NamingException,CreateException,RemoteException 
{
    return AuditaFacadeUtil.getHome().create();
}
项目:sistra    文件:CuadroMandoInicioFacadeEJB.java   
/**
    * @ejb.create-method
    * @ejb.permission unchecked = "true" 
    */
public void ejbCreate() throws CreateException 
{
    super.ejbCreate();
}
项目:sistra    文件:ProcesoBackupFacadeEJB.java   
/**
    * @ejb.create-method
    * @ejb.permission unchecked = "true"
    */
public void ejbCreate() throws CreateException {
    super.ejbCreate();

}