Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account
List archives

Creating a file

XPATH Child query
(18 lines)
Apache Sling GWT Integration version 3.0.0 Released
(28 lines)
Jul 29, 2010
Audrey Colbrant
Audrey Colbrant
Hi,

I am trying to create a file from server side following some examples, but
no way, the file is not created.
I have had a look to server logs but I don't find any error and the source
code is not throwing anything. 

Here the piece of code:
            Node root = session.getRootNode();
            Node userRoute=root.getNode("content/myProjectNode");
            
            Node fileNode = userRoute.addNode("myFile.gpx", "nt:file"); 
            Node resNode = fileNode.addNode("jcr:content", "nt:resource");


            resNode.setProperty("jcr:mimeType", "text/xml"); 
            resNode.setProperty("jcr:encoding", "UTF-8");
           
resNode.setProperty("jcr:lastModified",Calendar.getInstance().getTimeInMillis());

            resNode.setProperty("jcr:data",new
ByteArrayInputStream(myString.getBytes()) );

Does anybody find something wrong?

Thanks in advance,

Audrey



Reply
Tags: codeserverfilecreate
Messages in this thread
Creating a file
reply Re: Creating a file
(38 lines) Jul 29, 2010 12:07
reply Re: Creating a file
(37 lines) Jul 29, 2010 12:12
reply Re: Creating a file
(12 lines) Jul 30, 2010 04:00
reply Re: Creating a file
(16 lines) Jul 30, 2010 04:15
reply Re: Creating a file
(30 lines) Jul 30, 2010 04:39
reply Re: Creating a file
(44 lines) Jul 30, 2010 04:46
reply Re: Creating a file
(15 lines) Jul 30, 2010 05:03
reply Re: Creating a file
(42 lines) Jul 30, 2010 07:51
Similar Threads
Creating a new XML rule
Hi,

I am trying to create a new rule, which can be defined in xml-rule file
also. The rule is extension to the existing call-param-rule in which we
can
pass the constant parameters (mainly string constants) which is currently
not possible with the call-param-rule.
After googleing I found the steps to do it which are:


   - Update the DTD. You should add an element type for your rule. The
   element should have an attribute corresponding to each of the rule's
   initialization parameters.
   - Define an ObjectCreationFactory
   - Extend DigesterRuleParser , and override the addRuleInstances()
method
   to add the rules for parsing your new element.

I did all the three steps but still I am not able to call the method with
string constants which I am defining in the rule-xml. I am getting the
values of parameter as null.

Attachments:
*digester-rules.dtd* (This is the updated dtd with the new element added
as
call-constant-param-rule. So step 1 is done.
*UpdatedRuleParser.java* (This java file defines the ObjectCreationFactory
(ConstantParamRuleFactory) and also extends the DigesterRuleParser.
*_xelerator_config_rule.xml* (XML file which defines the digester rules).
*_xelerator_config.xml *(XML document which needs to be parsed).
*ConstantParamRule.java* (Extended rule file)

What is it which i am missing or doing wrong.

Thanks in advance.

--wadi


Creating key spaces on the fly
Hi everyone,

I'm trying to use Cassandra to replace a RDBMS.

My application handles domains. And, for every domain it creates a new DB
with a pre-defined set of tables.

After reading the documentation, I assume that this should be handled on
Cassandra by creating new key spaces.

Could I know if this is possible? Or if I'm wrong, could you point me to
the
correct approach?

Thanks in advance.



Tharindu


Error while creating object
Hi All,

I getting the following error while creating the object in AMQ,

#0  0x002cd777 in apr_atomic_add32 (mem=0x95123ec, val=4294967295) at
atomic/unix/mutex.c:78 
    #1  0x016208b8 in
decaf::util::concurrent::atomic::AtomicInteger::decrementAndGet
(this=0x95123e8) 
        at decaf/util/concurrent/atomic/AtomicInteger.cpp:69 
    #2  0x015de038 in decaf::lang::ArrayPointer<unsigned char,
decaf::util::concurrent::atomic::AtomicRefCounter>::reset ( 
        this=0xbfa95928, value=0x95130a8 "\177", size=4) at
./decaf/util/concurrent/atomic/AtomicRefCounter.h:68 
    #3  0x015ddc5c in InetAddress (this=0xbfa9591c, hostname=@0xbfa95954,
ipAddress=0x16604bb "\177", numBytes=4) 
        at decaf/net/InetAddress.cpp:79 
    #4  0x015daff7 in Inet4Address (this=0xbfa9591c, hostname=@0xbfa95954,
ipAddress=0x16604bb "\177", numBytes=4) 
        at decaf/net/Inet4Address.cpp:34 
    #5  0x015dc073 in __static_initialization_and_destruction_0
(__initialize_p=<value optimized out>,  
        __priority=<value optimized out>) at
decaf/net/InetAddress.cpp:39 
    #6  0x016371b6 in __do_global_ctors_aux () from
/usr/local/lib/libactivemq-cpp.so.12 
    #7  0x01161b11 in _init () from /usr/local/lib/libactivemq-cpp.so.12 
    #8  0x00811573 in call_init () from /lib/ld-linux.so.2 
    #9  0x00811683 in _dl_init_internal () from /lib/ld-linux.so.2 
    #10 0x0080388f in _dl_start_user () from /lib/ld-linux.so.2 
    
What could be the cause of this error or what i am doing wrong.
Please let me know your inputs.

Thanks,
Manu




Javadocs fixing/creating
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi dev

Are you aware of
http://maven.apache.org/plugins/maven...in/fix-mojo.html?

This will create (depending on the properties you set on CLI) missing
javadocs on in the source files. Properties can also be configured in
each project pom.xml.

I suggest to fix at least ClassComments for now. Resulting is shown in
sample below.

WDYT?

Following will e.g. fix the ClassComment and add a missing @author tag:

mvn javadoc:fix -DdefaultAuthor="<a
href=\"mailto:d### @directory.apache.org\">Apache Directory
Project</a>"
- -DfixTags="author" -DfixFieldComment=false -DfixMethodComment=false
-Dforce

like

Index:
ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapAsyncConnection.java

Creating a directory fails
I don't see anything out of the ordinary here, seems like its not honoring
the type as a directory but as a file any ideas?

err: //bind::slave/File[/var/named/chroot]: Failed to generate additional
resources using 'eval_generate': Cannot manage files of type
characterSpecial

file { '/var/named/chroot':
    ensure    => directory,
    owner     => named,
    group     => named,
    mode      => 0755,
    require   => Package['bind-chroot'];
}





Creating two instances in code
Hello,

I'd like to make some changes to cassandra so that when starting up a node
in a cluster, another node starts in another cluster. That requires that
the two nodes have different configurations, but DatabaseDescriptor (where
I think all the config reading is done) seems to load everything
statically when the class is loaded. The configuration path seems to
reside in System.getProperties(). Can you suggest a way for me to build a
second node with a different configuration path in the same code?

Unfortunately, I cannot simply launch two different cassandra instances on
the same computer, as I want the second node to have access to information
from the first node, such as node load for the first cluster and such
(plus even running two separate cassandra instances on the same node seems
to require workarounds and hacks).

Alexander Altanis


Problems creating admin users
Hi,

using couchdb 0.11.0 on Ubuntu 10.04 I get the following error message
when
trying to add a new admin user vía Futon:

Signup error: {gen_server,call, [couch_query_servers,
{get_proc,{doc,<<"_design/_auth">>, {1,
[<<4,216,98,51,179,37,75,181,165,61,207,113,3,
249,127,194>>]},
{[{<<"language">>,<<"javascript">>},
{<<"validate_doc_update">>,
<<"function(newDoc, oldDoc, userCtx) {\n if ((oldDoc || newDoc).type
!=
'user') {\n throw({forbidden : 'doc.type must be user'});\n } // we only
validate user docs for now\n if (newDoc._deleted === true) {\n // allow
deletes by admins and matching users \n // without checking the other
fields\n if ((userCtx.roles.indexOf('_admin') != -1) || (userCtx.name ==
oldDoc.name)) {\n return;\n } else {\n throw({forbidden : 'Only admins may
delete other user docs.'});\n }\n }\n if (!newDoc.name) {\n
throw({forbidden
: 'doc.name is required'});\n }\n if (!(newDoc.roles && (typeof
newDoc.roles.length != 'undefined') )) {\n throw({forbidden : 'doc.roles
must be an array'});\n }\n if (newDoc._id !=
'org.couchdb.user:'+newDoc.name) {\n throw({forbidden : 'Docid must be of
the form org.couchdb.user:name'});\n }\n if (oldDoc) { // validate all
updates\n if (oldDoc.name != newDoc.name) {\n throw({forbidden :
'Usernames
may not be changed.'});\n }\n }\n if (newDoc.password_sha &&
!newDoc.salt)
{\n throw({forbidden : 'Users with password_sha must have a salt. See
/_utils/script/couch.js for example code.'});\n }\n if
(userCtx.roles.indexOf('_admin') == -1) { // not an admin\n if (oldDoc) {
//
validate non-admin updates\n if (userCtx.name != newDoc.name) {\n
throw({forbidden : 'You may only update your own user document.'});\n }\n
//
validate role updates\n var oldRoles = oldDoc.roles.sort();\n var newRoles
=
newDoc.roles.sort();\n if (oldRoles.length != newRoles.length) {\n
throw({forbidden : 'Only _admin may edit roles'});\n }\n for (var i=0; i
<
oldRoles.length; i++) {\n if (oldRoles[i] != newRoles[i]) {\n
throw({forbidden : 'Only _admin may edit roles'});\n }\n };\n } else if
(newDoc.roles.length > 0) {\n throw({forbidden : 'Only _admin may set
roles'});\n }\n }\n // no system roles in users db\n for (var i=0; i <
newDoc.roles.length; i++) {\n if (newDoc.roles[i][0] == '_') {\n
throw({forbidden : 'No system roles (starting with underscore) in users
db.'});\n }\n };\n // no system names as names\n if (newDoc.name[0] ==
'_')
{\n throw({forbidden : 'Username may not start with underscore.'});\n }\n
}">>}]}, [],false,[]}, {<<"_design/_auth">>,
<<"1-04d86233b3254bb5a53dcf7103f97fc2">>}}]}

However I can login vía Futon using the previously entered credentials
but
there is no corresponding user file added to the "_users" table. It seems
that the "_auth" validation function prevents me from adding a new user to
the "_users" table.

How can I fix this?


Creating a Cassandra cluster under Windows XP
We have a VPN with PC’s running Windows XP SP3.

I want to define a Cassandra cluster on two PC’s in the VPN:
192.168.80.234
and 192.168.80.12.

I can ping from 192.168.80.12 to 192.168.80..234 and vice-versa.

I download and install Cassandra 0.6.2

Why doesn’t the cluster cluster?

I configure 192.168.80.12 to be the seed, as follows:



*<Storage>*

*  <ClusterName>Lookin2</ClusterName>*

*  <AutoBootstrap>false</AutoBootstrap>*

*  <Seeds>*

*      <Seed>192.168.80.12</Seed>*

*  </Seeds>*

*  <ListenAddress>192.168.80.12</ListenAddress>*

*  <!-- internal communications port -->*

*  <StoragePort>7000</StoragePort>*

*  <ControlPort>7001</ControlPort>*

*  <ThriftAddress>192.168.80.12</ThriftAddress>*

*    <!-- Thrift RPC port (the port clients connect to). -->*

*  <ThriftPort>9160</ThriftPort>  *

*  <ThriftFramedTransport>false</ThriftFramedTransport>*

*</Storage>*





I configure 192.168.80.234 to be a non-seed node, as follows:

*<Storage>*

*  <ClusterName>Lookin2</ClusterName>*

*  <AutoBootstrap>true</AutoBootstrap>*

*  <Seeds>*

*      <Seed>192.168.80.12</Seed>*

*  </Seeds>*

*  <ListenAddress>192.168.80.234</ListenAddress>*

*  <!-- internal communications port -->*

*  <StoragePort>7000</StoragePort>*

*  <ControlPort>7001</ControlPort>*

*  <ThriftAddress>192.168.80.234</ThriftAddress>*

*    <!-- Thrift RPC port (the port clients connect to). -->*

*  <ThriftPort>9160</ThriftPort>  *

*  <ThriftFramedTransport>false</ThriftFramedTransport>*

*</Storage>*



(All other values in the two storage-conf.xml files are default values
from
the 0.6.2 installation.)





I start up Cassandra on 192.168.80.12, then start up Cassandra on
192.168.80.234.



On 192.168.80.234, I see the following in the DOS console:





*C:\apache-cassandra-0.6.2\bin>cassandra -f*

*Starting Cassandra Server*

*Listening for transport dt_socket at address: 8888*

* INFO 19:01:49,687 Auto DiskAccessMode determined to be standard*

* INFO 19:01:49,984 Replaying
\var\lib\cassandra\commitlog\CommitLog-127523519217*

*1.log*

* INFO 19:01:50,031 Creating new commitlog segment
/var/lib/cassandra/commitlog\C*

*ommitLog-1275235310031.log*

* INFO 19:01:50,093 LocationInfo has reached its threshold; switching in a
fresh*

*Memtable at
CommitLogContext(file='/var/lib/cassandra/commitlog\CommitLog-127523*

*5310031.log', position=173)*

* INFO 19:01:50,093 Enqueuing flush of Memtable(LocationInfo)@700852*

* INFO 19:01:50,093 Writing Memtable(LocationInfo)@700852*

* INFO 19:01:50,296 Completed flushing
C:\var\lib\cassandra\data\system\LocationI*

*nfo-1-Data.db*

* INFO 19:01:50,328 Log replay complete*

* INFO 19:01:50,375 Saved Token found:
51560289722671854279455339870443755117*

* INFO 19:01:50,375 Saved ClusterName found: Lookin2*

* INFO 19:01:50,390 Starting up server gossip*

* INFO 19:01:50,421 Joining: getting load information*

* INFO 19:01:50,421 Sleeping 90000 ms to wait for load information...*

* INFO 19:03:20,421 Joining: getting bootstrap token*

*ERROR 19:03:20,421 Exception encountered during startup.*

*java.lang.RuntimeException: No other nodes seen!  Unable to bootstrap*

*        at
org.apache.cassandra.dht.BootStrapper.getBootstrapSource(BootStrapper*

*.java:120)*

*        at
org.apache.cassandra.dht.BootStrapper.getBalancedToken(BootStrapper.j*

*ava:102)*

*        at
org.apache.cassandra.dht.BootStrapper.getBootstrapToken(BootStrapper.*

*java:97)*

*        at
org.apache.cassandra.service.StorageService.initServer(StorageService*

*.java:356)*

*        at
org.apache.cassandra.thrift.CassandraDaemon.setup(CassandraDaemon.jav*

*a:99)*

*        at
org.apache.cassandra.thrift.CassandraDaemon.main(CassandraDaemon.java*

*:177)*

*Exception encountered during startup.*

*java.lang.RuntimeException: No other nodes seen!  Unable to bootstrap*

*        at
org.apache.cassandra.dht.BootStrapper.getBootstrapSource(BootStrapper*

*.java:120)*

*        at
org.apache.cassandra.dht.BootStrapper.getBalancedToken(BootStrapper.j*

*ava:102)*

*        at
org.apache.cassandra.dht.BootStrapper.getBootstrapToken(BootStrapper.*

*java:97)*

*        at
org.apache.cassandra.service.StorageService.initServer(StorageService*

*.java:356)*

*        at
org.apache.cassandra.thrift.CassandraDaemon.setup(CassandraDaemon.jav*

*a:99)*

*        at
org.apache.cassandra.thrift.CassandraDaemon.main(CassandraDaemon.java*

*:177)*

* *

*C:\apache-cassandra-0.6.2\bin>*









In system.log, I see the following:



*INFO [main] 2010-05-30 19:01:49,687 DatabaseDescriptor.java (line 232)
Auto
DiskAccessMode determined to be standard*

* INFO [main] 2010-05-30 19:01:49,984 CommitLog.java (line 172) Replaying
\var\lib\cassandra\commitlog\CommitLog-1275235192171.log*

* INFO [main] 2010-05-30 19:01:50,031 CommitLogSegment.java (line 50)
Creating new commitlog segment
/var/lib/cassandra/commitlog\CommitLog-1275235310031.log*

* INFO [main] 2010-05-30 19:01:50,093 ColumnFamilyStore.java (line 357)
LocationInfo has reached its threshold; switching in a fresh Memtable at
CommitLogContext(file='/var/lib/cassandra/commitlog\CommitLog-1275235310031.log',
position=173)*

* INFO [main] 2010-05-30 19:01:50,093 ColumnFamilyStore.java (line 609)
Enqueuing flush of Memtable(LocationInfo)@700852*

* INFO [FLUSH-WRITER-POOL:1] 2010-05-30 19:01:50,093 Memtable.java (line
148) Writing Memtable(LocationInfo)@700852*

* INFO [FLUSH-WRITER-POOL:1] 2010-05-30 19:01:50,296 Memtable.java (line
162) Completed flushing
C:\var\lib\cassandra\data\system\LocationInfo-1-Data.db*

* INFO [main] 2010-05-30 19:01:50,328 CommitLog.java (line 175) Log replay
complete*

* INFO [main] 2010-05-30 19:01:50,375 SystemTable.java (line 164) Saved
Token found: 51560289722671854279455339870443755117*

* INFO [main] 2010-05-30 19:01:50,375 SystemTable.java (line 179) Saved
ClusterName found: Lookin2*

* INFO [main] 2010-05-30 19:01:50,390 StorageService.java (line 326)
Starting up server gossip*

* INFO [main] 2010-05-30 19:01:50,421 StorageService.java (line 387)
Joining: getting load information*

* INFO [main] 2010-05-30 19:01:50,421 StorageLoadBalancer.java (line 365)
Sleeping 90000 ms to wait for load information...*

* INFO [main] 2010-05-30 19:03:20,421 StorageService.java (line 387)
Joining: getting bootstrap token*

*ERROR [main] 2010-05-30 19:03:20,421 CassandraDaemon.java (line 195)
Exception encountered during startup.*

*java.lang.RuntimeException: No other nodes seen!  Unable to bootstrap*

*               at
org.apache.cassandra.dht.BootStrapper.getBootstrapSource(BootStrapper.java:120)
*

*               at
org.apache.cassandra.dht.BootStrapper.getBalancedToken(BootStrapper.java:102)
*

*               at
org.apache.cassandra.dht.BootStrapper.getBootstrapToken(BootStrapper.java:97)
*

*               at
org.apache.cassandra.service.StorageService.initServer(StorageService.java:356)
*

*               at
org.apache.cassandra.thrift.CassandraDaemon.setup(CassandraDaemon.java:99)*

*               at
org.apache.cassandra.thrift.CassandraDaemon.main(CassandraDaemon.java:177)*

* *

Why doesn’t the cluster cluster?


x-net] Creating a provider based on OpenSSL
  Hi all,

I'm currently investigating the possibility of implementing a JSSE 
provider wrapping OpenSSL. This has a couple of obvious advantages:
  - The onus of code maintenance and bug fixing in a security sensitive 
area is moved outside of Harmony.
  - New protocols can be integrated into the Harmony provider with 
minimal effort (updating dependencies rather than implementing them 
ourselves).

Really I'm sending this mail as a heads up, but would be interested to 
know if anyone has any experience/opinions in this area. In particular, 
I'd be interested in ideas on:
  - the best way to setup OpenSSL as a dependency - precompile the 
libraries and make them available for download or compile them at build 
time on the user's machine.
  - how to tie in the Java x-net APIs to the OpenSSL APIs.

Any comments/suggestions welcome.

Regards,
Oliver





Re: Creating a libRedis / refactoring global variables
On Tue, Jul 27, 2010 at 10:05:37AM -0700, Jak Sprats said:
 How are you gonna handle multiple threads doing background dumps (in
 parallel), or writing to the AOF file(in parallel).

Well, the original plan wasn't to make Redis multi threaded, just to 
allow dlopen-ed plugins. 

So the short answer is: I'm not.

Longer answer: once the separation is done it might be possible to go in 
a wrap various operations with a mutex (probably wrapped in a macro so 
that multithreading is a compile time option). 

But that's in the future.









Best practise handling request and creating new document?
Hello,

I'm trying to find out, how I can create new documents from a web formula
request using just CouchDB.

I'm not going to submit a <form> using client side JavaScript and
for example an AJAX HTTP PUT request. I'm going to send the form directly
to CouchDB and let it handle the data and create new documents.

I'm new to CouchDB and currently I'm just seeing a solution in using
shows:
http://books.couchdb.org/relax/design-documents/shows

This show "book" prints out the title of an existing document if its
given. Shows a "New book" form if no existing document is given and prints
out the title if the form is submitted.

{
  "book": "function(doc, req) {
     if( req.query.title ){
         return req.query.title;
     }
     else if( doc )
         return doc.title;
     else
         return '<form><input name=\"title\"><input
type=\"submit\"></form>';
     
     }"
}

Instead of printing out the title I'm going to validate it and create a
new document with it. How can I do that? Whats the best practise, should I
perhaps using something else than a show?

I did not found the JS API documentation, exists one?

Thanks in advance!
Philipp




Re: wsdl2java - creating List return type
I have a slightly different use case now - I want wsdl2java to generate a
method that takes an argument and returns a List. I have tried several
options but cannot make it to work.

This is what I'd like wsdl2java to generate:

public List<Order> getOrders(OrderCriteria orderCriteria);

This is the WSDL that I have tried:

<xsd:element name="GetOrders" type="tns:OrderCriteria" />

<xsd:element name="GetOrdersResponse" type="tns:Orders" />

<xsd:complexType name="OrderCriteria">
    <xsd:sequence>
        <xsd:element name="FromDate" type="xsd:date" />
        <xsd:element name="ToDate" type="xsd:date" />
    </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="Orders">
    <xsd:sequence>
        <xsd:element name="Order" type="tns:Order"
            minOccurs="0" maxOccurs="unbounded" />
    </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="Order">
    <xsd:sequence>
        <xsd:element name="Id" type="xsd:long" />
        <xsd:element name="CreationTime" type="xsd:dateTime" />
        <xsd:element name="Status" type="tns:OrderStatus" />
    </xsd:sequence>
</xsd:complexType>

<message name="OrdersRequest">
    <part name="OrdersRequest" element="acnt:GetOrders" />
</message>

<message name="OrdersResponse">
    <part name="Orders" element="acnt:GetOrdersResponse" />
</message>

<operation name="GetOrders">
    <input message="tns:OrdersRequest" />
    <output message="tns:OrdersResponse" />
</operation>

However wsdl2java wraps the returned list in a wrapper object:

public Orders getOrders(OrderCriteria ordersRequest);

public class Orders {
    protected List<Order> order;
}

How can I change my wsdl to return an unwrapped list?

Thanks.
Naresh




Created: (AMQNET-264) Creating a session using a destination that was used before causes consumer op
Creating a session using a destination that was used before causes consumer
options to be lost

Urgent help needed in creating new directive in http.conf.
Hi All,

We want to introduce a new feature in apache which is required by our
company. For which we need to add a directive in httpd.conf or
http-ssl.conf.

But I am clueless from where to start.

Can anyone help me to from where I can start?



Thanks

Matty.